Calculate (Setting) Acquisition and Conversion Timing of ADC

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,I am using Atmega168 , i want convert 1 volts 50hz AC signal to digital using ADC in the MCU.could you please tel me how to calculate the sampling rate,Cycle length,How many samples in 50 HZ cycle?
Is there any application in AVR for ADC coding,
so that i can able to understand,how to set the acquisition and conversion time to the samples that has to be converted to digital.

Please reply me as soon as possible.

Thanks,
prabu

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It all depends on your needs.

What do you want to do with the samples?
Signal analysis like distortion measurement?
RMS measuring, frequency measurement?

Hardware:
A 1V sine signal has it´s peaks at +1.4V and -1.4V. Mind that the AVR is not able to convert negative signals.
You can lift the sine up to (maybe 2.5V).
If now the ADC sees 2.5V it represents 0V.
3V represents 0.5V and
2V represent -0.5V

Klaus
********************************
Look at: www.megausb.de (German)
********************************

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MegaUSBFreak wrote:
Mind that the AVR is not able to convert negative signals.
You can lift the sine up to (maybe 2.5V).
If now the ADC sees 2.5V it represents 0V.
3V represents 0.5V and
2V represent -0.5V

How to lift the sine up ?

for example i am having Peak to peak voltage of 1 volt.
should this sing lift up and how much?

Actually, i want to calculate the current in the single phase line,for that i used current transformer.using burden resistor in the secondary of CT, i am getting 1 volts peak to peak voltage at maximum current of 10 amps.

i want to calculate the rms value of the current.
how to set the sampling time all those things?
will this 1v peak to peak is directly given to MCU ADC pin?

or before we have to do sing up and how?

Thanks,
prabu

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

How to lift the sine up ?

Feed it into an instrument amp like the INA121.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
should this sing lift up and how much?

because sine is a symmetrical signal i recommend to lift the zero line of the sine up to half of your ADC input range.
What ADC input range dou you have?

Quote:
i want to calculate the rms value of the current.

You know how to calculate RMS? over what time? how often? What resolution and accuracy? (see example below)

Do you expect pure sine or distorted sine?

There are ready made "true RMS converters" doing much of hardware and software for you. Maybe use one of this chips?

Quote:
will this 1v peak to peak is directly given to MCU ADC pin?
or before we have to do sing up and how?

As said before and as stated in the datasheets:
* the abs. max. input voltage of any AVR pin is (GND-0.3V) to (VCC+0.3V). Look into the datasheets for the correct values.
* The max decodeable input voltage for a ADC input pin is GND to VRef.

So some depend on your circuit:
* What is your VCC voltage?
* What is your VRef?

But a sine allways has negative halfwaves. These go below GND if not lifted up. Therfore my answer is you MUST lift it up.

Sampling rate:
If you want to do the RMS calculation within your AVR then i recommend to sample 2^n times in one period, where n is an integer number in the range of 2 up to 8.

Example:
if you want to display the RMS value of a 50Hz much distorted sine, then i recommend to sample at least 32 times per period.
(this gives a sample rate of 50Hz x 32 = 1600 Hz - then you need an analog antialias filter at about 500Hz).

3 times a second means you could use 15 full period to calculate. This means you can read in 32 x 15 = 480 samples
square them all immediately and add the values up.
After all 480 samples devide the value by 480 and calculate the squareroot of it. This give the hard_to_calculate but true RMS value.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks ,really nice...
but need few clarifications..

Quote:
So some depend on your circuit:
* What is your VCC voltage?
* What is your VRef?

VCC--5volts
Vref--1.1 volts

Quote:

this gives a sample rate of 50Hz x 32 = 1600 Hz - then you need an analog antialias filter at about 500Hz).

why we need 500hz filter?
and how u decided that 500HZ filter i mean how to calculate this antialias filter for our requirement?

Quote:

3 times a second

how 3 times a second?..

thanks,
prabu.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is it easier to teach a programmer electrical engineering, or is it easier to teach an engineer programming? Life is a giant puzzle. Some old overpaid EE on one side of the ocean with 30 years of experience gets laid off when his job gets sent overseas, some new engineer half way around the world gets hired, assigned to an engineering and programming task that has the spec written in Greek, and they chat to each other over an intercontinental teletype.
Surreal.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
why we need 500hz filter?
and how u decided that 500HZ filter i mean how to calculate this antialias filter for our requirement?

google for "antialias filter" or "nyquist"

This has been discussed here many times. Also you can find this information with google.
Before designing a device with ADC you have to learn the basics about ADC.
Short: You need to get rid of frequencies above 1/2 sampling frequency with an analog low pass filter in front of the ADC.

Quote:
how 3 times a second?..

I don´t even know if you want to display/calculate it 3 times a second. You don´t say much what you really want to do.
So I took "3" in my example.
However this is only my example - and you have to decide what is good for your project.

But if you want to know how to start a measurement 3 times a second then:
* first you have to decide if you want it to be 3.00 times a second or it can vary (maybe 2.5 up to 3.5 times a second)
* If you need it 3.00 times a second then best is to use a timer
* If the "3" is not that imprtant then start a measurement immediately after finished the one before.

Klaus
********************************
Look at: www.megausb.de (German)
********************************