Digital Meter

What is the minimum and maximum voltage that the ARDUINO MEGA 2560 can sense through its analog pins?

Thanks alot! :slight_smile:

kengwapo:
What is the minimum and maximum voltage that the ARDUINO MEGA 2560 can sense through its analog pins?

Thanks alot! :slight_smile:

That is information best obtained from the AVR datasheet for the mega2560, but from memory the absolute safe voltage limits for the analog input pins (actually same spec for any input pin except the reset pin is from negative -.5vdc to (Vcc + .5vdc), where Vcc is the voltage level powering the chip's Vcc and Avcc pins, which in most arduino boards is +5vdc. The I/O pins all have internal clamping diodes which set the upper and lower voltage limits for the pins.

Lefty

if i input for example an ac voltage with 100mVolts maximum.. can arduino read this? can 1024 samples possible? :slight_smile:
sorry im new to arduino XD

Yes, the Arduino can read 0.1VAC as long as the voltage is within the specifications mentioned earlier by retrolefty. You can sample at roughly 10kHz by default.

I don't know what happens when the voltage is between 0VDC and -0.5VDC though. I suspect 0V = 0 on the ADC and negative voltage is 'undefined' (will probably return 0).

Normally, the 1024-steps are mapped from 0 to 5VDC, so 0.1V is only about 20 steps of resolution for your application. If you need more resolution, then you may be able to use the internal 1.1V ADC reference or you'll probably need the help of some hardware.

If the input voltage source is heavily current-limited, the voltage limit becomes whatever the clamping diodes can safely handle. Significantly more than -0.5 and 5.5v, although I don't know exactly what that limit is. (This is where we will be reminded that Atmel has an example where the AVR directly samples AC mains through a large-value resistor.) Of course it will be bandwidth limited by the effective RC filter, so high-frequency AC is off the table -- but the sampling rate isn't that high anyway

In practice, there's usually a better way.

tylernt:
Normally, the 1024-steps are mapped from 0 to 5VDC, so 0.1V is only about 20 steps of resolution for your application. If you need more resolution, then you may be able to use the internal 1.1V ADC reference or you'll probably need the help of some hardware.

Every step is about 4.88mV? What will happen if i have signal lower than that? Does the arduino board consider it as 0V?

Btw, thank you for the reply :slight_smile:

kengwapo:
Every step is about 4.88mV? What will happen if i have signal lower than that? Does the arduino board consider it as 0V?

Not sure, but I suspect negative voltage is 'undefined' (will probably return 0).

Thanks for the replies, but its a little bit hazy for me.
How can I monitor a half wave rectified AC Voltage signal using arduino mega 2560? How can i monitor its peak value? Can anyone discuss to me the basics? This is a very big help.. :slight_smile:

Btw, another question, i am using SIM900D does this module needs to be powered by 9V 1.5A exactly? or can i use less than 1.5A?

Measuring AC is tricky. If you rectify it, the voltage drop across the rectifier means you lose any signal less than the Vf of the diode. If you don't rectify it, you have to bias the AC signal with DC and measure its distance plus or minus from a reference value that represents the DC bias voltage. Neither is particularly elegant, and each has its arguments for and against.

You could use a diode as a reference voltage generator, capacitively couple the AC signal, bias it with the reference voltage so its center point is the Vf of your rectifier diode, then sample the positive swings... Kind of a PITA, but it would work, with possibly some loss of resolution depending on how well matched the reference diode is to the rectifier.

but its a little bit hazy for me

You are needing to do some self-educating with manufacturers spec sheets. A simple Google of AVR AC ADC PEAK returned multiple PDF resources. Similarly, your SIM900D unit has a full data sheet that lists the product voltage specifications and operating tolerances ... You just need to search, retrieve, and read.

As you know what a half-wave rectified signal is, assuming no filtering (bulk storage) capacitor is involved, a technique would be to have high value resistors in a bias network such that there is an offset voltage applied to the ADC... This is to allow the slightly negative lower part if the half-wave to be biased to 0. The peak would the the largest ADC count over a set time period, said period could be multiple ADC conversions or a single ADC conversion depending on what you wish to measure.

For the average Arduino user, a project as complex as using the SIM900D should be based on a proven reference design and some known good library code - not a project to boot-strap your Arduino knowledge. Plus lots, and lots of research and effort by the builder.

Ray

Serial.begin(9600)

what is 9600?

and i had seen some codes with 255, example:

for (int i=0; i < 255; i++)
{
if (adcCurrent > magI)

  • {*
    _ magI = adcCurrent*;_
    _
    magCountI = i;_
    _
    }*_
    what does this mean?

kengwapo:
Serial.begin(9600)

what is 9600?

In this case, 9600 is a constant or literal that refers to the baud rate of the serial connection -- nine thousand, six hundred bits per second. You'll need to configure the other end of the connection for the same speed.

and i had seen some codes with 255, example:

for (int i=0; i < 255; i++)

what does this mean?

Another constant or literal. In this case, the contents of the for loop will execute as long as the variable i contains a number less than two hundred fifty-five. When the value of i equals or exceeds 255, the for loop stops executing.

why 255? :slight_smile:

Normally, the 1024-steps are mapped from 0 to 5VDC, so 0.1V is only about 20 steps of resolution for your application. If you need more resolution, then you may be able to use the internal 1.1V ADC reference or you'll probably need the help of some hardware.

Actually, the 1024 steps are mapped from 0 to the analog reference voltage. That can be 5.0V (the default on 5.0V boards), 3.3V (the default on 3.3V boards), 1.1 (if using the INTERNAL keyword on the analogReference() call), some other voltage fed into the VRef pin.

kengwapo:
if i input for example an ac voltage with 100mVolts maximum.. can arduino read this? can 1024 samples possible? :slight_smile:
sorry im new to arduino XD

Yes you can read it, you would level shift it to, say, 2.5V using a capacitor to couple to
a mid-voltage resistor divider (you do need to know the impedance and frequency of the
signal to do this properly). However you can't get full scale readings, the ADC is rated to
work down to AREF = 1V or so. If you used the internal 1.1V reference and coupled
the AC to a 0.5V resistor-divider you could get about 20% of full scale from your waveform.

But without knowing more about the application its hard to suggest anything better - it
would be normal to boost the signal with an opamp before sampling.

kengwapo:
why 255? :slight_smile:

The 'for' loop operates on each of the 255 elements in the adcCurrent[] array.

Actually sir my voltage is not fixed, it may vary from 0-5 Volts half wave depending on the line voltage.. What codes can you recommend? :slight_smile: