Hi,

I want to calculate the RMS value of a sine wave that can oscillate between [5, -5]V with an ADC single ended channel.

I know that the minimum voltage a channel can be put to is GND - 0,5V and that the single ended channel can only acquire values between GND and Vref (simplifying).

I don´t want to put almost any electronics in the ADC input, i have no space...
I was thinking of putting a diode with forward voltage around 200mV, so that the door channel wont burn. As i am calculating the RMS value of the wave, half a period will be enough to compute the value and i can take out all samples that correspond to [000000] conversions, probably negative saturations.

What do you think about the idea?
And, do you think its possible to use the pre existent port protection diodes, instead of putting my own diodes?

Best regards

Check out the the section at openenergymonitor.org that describes their hardware setup. Their approach uses a Biasing circuit that results in a positive-only signal for the unipolar ADC in the atmega chip.

There is a similar circuit that I explored in this forum that used a coupling capacitor to remove any dc signal components from the AC signal and then biased it sufficiently to remain positive.

The diode idea is feasible, what you need is a voltage divider formed by a resistor and the diode. During the positive half-cycles the diode should be reverse-biased (anode connected to GND, cathode to ADC pin). During negative half cycles it is forward biased and the resistor drops nearly all of the voltage.

So something like about 10k from input to ADC pin, diode from pin to GND as described.

If you rely on the built-in protection diode you need to be careful to avoid overloading it - perhaps a 33k resistor is safer. Not only can overload overheat and damage the built-in diodes, there is a phenomenon called "latch-up" that can be triggered in CMOS inputs by passing too much current through the diodes (even for a microsecond)... This is why inputs have a min and max voltage spec.

The best external diode choice would be a schottky diode as these have lower forward voltages than the inbuilt protection diodes, but a simple 1N4148 would probably be OK - some testing would help give confidence.

BTW since you only measure half of the cycle you are no longer guaranteed to measure true RMS values if the supply has even harmonics present... probably only a tiny effect, but worth noting.