Forum Rule: Always post complete source code & details to reproduce any issue!

1. ## Measure mV

Hi all,
I have function generator (Joy-it JDS6600 lite) and I want generate sine wave 0,02V RMS = on generator I have to setup 0.06V because 0.06 is peak-peak, then divided 2 to have 0-peak and multiply by 0,707 (RMS). So for 0.02V RMS I have to setup 0.06V peak-peak. I hope this is ok.
Now I read 4096 samples. Every sample every 50micros via ADC. ADC has only positive values = on plotter I can see half sine.
When I try find max value = 0-peak then I can see 0.024.

I need to measure volts in RMS - I want to see on Serial monitor value 0.02V - any idea how to do it? Thanks!

My code:

Code:
```#include <ADC.h>
#define AVERAGING 8
#define RESOLUTION 12
float volt = 0;
float mmax = 0;
int k;

void setup() {
Serial.begin(115200);
}

}
}

delay(100); // wait for usb serial to finish
delay(1);
do {

}

void loop() {

for (k = 0 ; k < ADCSAMPLES; k++)
{
volt = adcbuffer[k] * (3.3 / 4095);
if(volt > mmax)
{
mmax = volt;
}
}
Serial.print("0 - Peak: "); //I will print 0-peak value
Serial.println(mmax,4);
mmax = 0;
delay(1000);

}```

2. You need to shift the signal to mid-way between the voltage rails. The negative voltages cannot be measured by the ADC,
and if more than 0.3V or so could damage the chip permanently.

Normally a capacitor and 1:1 voltage divider are used to shift the voltage to mid-rail, and a series resistor can improve
robustness to over-voltage.

3. Can you expand on that, perhaps with a diagram. I googled but got nothing like you explained.

You can find one similar to MarkT's suggestion on this audio library design tool page. Look at the right side documentation column and scroll down to Hardware.

https://www.pjrc.com/teensy/gui/?info=AudioInputAnalog

This circuit is slightly more complex. The first 47K resistor at the input can be omitted if your signal already has a well defined DC level. The other extra parts try to filter away noise which may be present from the power supply. If you don't care about that, just 1 capacitor and 2 resistors can do the same thing.

The downside to this circuit is it acts as a high pass filter. Usually that's fine if you wish to measure a sine wave or other signals which well are above the filter frequency. Choosing the capacitor large enough lets you get the filter frequency low, so it's usually not an issue.

But if you want to measure DC or very low frequencies, here is another way.

https://www.pjrc.com/control-voltage...log-input-pin/

Using just 3 resistors is simple, but if your signal source isn't strong (technically speaking, low impedance) the resistors can create a load which causes inaccuracy. You can find a link on that page to old forum conversation about how to do it better (but more work, more complexity) with opamps.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•