Better AC sensing circuit for ADC conversion

Thread Starter

Hasan2019

Joined Sep 5, 2019
199
The processor I use is the one in the Arduino Uno R4 boards. I know that there are some fans of the Atmega processors on this forum, but I left 8-bit processors behind in 2013, and have never looked back. 32-bit just makes the maths so much simpler, especially if writing in assembler, and ARM code looks an awful lot like Atmega code which makes it easier to transition.
I started ARM cortex M0 type DSP or MCU from 2014 may be, small Korean companies pushed me a lot, most of them had projects with STM32, I screwed up many times with Firmware because people developed and leaved frequently, did not understand where to start with. Even if I tried a lot with different MCUs, I don't have much skill set to write hard-code, but I did modification. This is some thing easy for my low budget personal project.
 

Thread Starter

Hasan2019

Joined Sep 5, 2019
199
If you use a small mains stepdown tranformer, you can then use the Arduino to read the AC voltage without rectification.
All the math can be done in the arduino (as Jerry-Hat-Trick has been describing). Use an opamp input buffer, bias the AC input signal at 1/2 Vcc, and feed to the arduino analog input.
eT, besides LTspice lib you are really helpful. If you post a similar circuit it will be understandable.
 

drjohsmith

Joined Dec 13, 2021
1,612
late into this,
circuit from house power monitor,

as others have mentioned,
simple 230v to 3v0 transformer
some zener across secondary to prevent spikes and keep things positive,

on secondary, one side earth, other into arduino.
the waveform is a half wave, but over sample this in arduino ,
 

Thread Starter

Hasan2019

Joined Sep 5, 2019
199
late into this,
circuit from house power monitor,

as others have mentioned,
simple 230v to 3v0 transformer
some zener across secondary to prevent spikes and keep things positive,

on secondary, one side earth, other into arduino.
the waveform is a half wave, but over sample this in arduino ,
May be or may not you are suggesting this simple circuity,

AC-voltmeter-using-Arduino-simulation-285V.png
 

Ian0

Joined Aug 7, 2020
13,144
You can get a half-supply-centred voltage from a transformer without an op-amp like this:
IMG_2117.jpegBoth R1 are the same value, and both R2 are the same value.
. . . But one thing you can’t do is use the transformer to supply anything else, otherwise it will mess up the accuracy.
That’s why I prefer the ZMPT101, a small mains transformer is £3, but a ZMPT101 is only about 30p.
Be very sceptical about 1.5VA transformers, because they are horribly non-linear as they seem to be run permanently in saturation using the winding resistance to limit the current (but the 1.6VA toroids are excellent)
 

Thread Starter

Hasan2019

Joined Sep 5, 2019
199
You can get a half-supply-centred voltage from a transformer without an op-amp like this:
View attachment 361566Both R1 are the same value, and both R2 are the same value.
. . . But one thing you can’t do is use the transformer to supply anything else, otherwise it will mess up the accuracy.
That’s why I prefer the ZMPT101, a small mains transformer is £3, but a ZMPT101 is only about 30p.
Be very sceptical about 1.5VA transformers, because they are horribly non-linear as they seem to be run permanently in saturation using the winding resistance to limit the current (but the 1.6VA toroids are excellent)
@Ian, this circuit is definitely an easiest one and it has less number of component. But don't you care about current in secondary? Lets say its 220V to 3V conversion The resistors aren't with high wattages ? You have another 3.3V refence VCC. I also want to know why some people use diode bridge for rectification or does the ripple need to be in consideration. Perhaps you are trying to figure out that the input node should have a stable analog voltage. Someone else has suggested a bit different circuit, In this rough schem. the ADC would have to find the peak to peak value to calculate the RMS, but at least there's no diodes.

Mains 01-02-2026.png

Does it also OK to you?
 

Jerry-Hat-Trick

Joined Aug 31, 2022
828
Final thought. If you are looking just to display the voltage how about using a resistive divider to drop the voltage and build the processor, display and other components into a transparent plastic box with no output to the outside world?
 

drjohsmith

Joined Dec 13, 2021
1,612
@Ian, this circuit is definitely an easiest one and it has less number of component. But don't you care about current in secondary? Lets say its 220V to 3V conversion The resistors aren't with high wattages ? You have another 3.3V refence VCC. I also want to know why some people use diode bridge for rectification or does the ripple need to be in consideration. Perhaps you are trying to figure out that the input node should have a stable analog voltage. Someone else has suggested a bit different circuit, In this rough schem. the ADC would have to find the peak to peak value to calculate the RMS, but at least there's no diodes.

View attachment 361598

Does it also OK to you?
Re ripple you ask about why some say rectification.
Your original post was about achieving a DC level , for which rectification is required , hence people answered your question.

But as is often true in engineering , when step back is taken , then there might be better ways of achieving what you want.

So instead of full wave rectification, assuming +ve and -ve parts of the mains are similar enough for you, then half wave rectification is practical

Also question of to use transformer or not.
You could use 1:1 , and resistor voltage drop either on the secondary or after rectification.

Or you could use a 230 v to ,3v transformer , and do away with voltage divider resistors

Again , with transformer , rectification is easier
But your Arduino is over sampling the mains frequency , so it's easy to use simple rectification and filtering in the code to achieve the effective DC level. Fewer components .

I'm certain there are other ways as well. Thinking of may be capacitive divider direct off the mains , etc all.

Which is best for your application is at the heart of engineering, knowing which way to go !
Things like quantity , where sold , regulations

Hope it goes well
 

Thread Starter

Hasan2019

Joined Sep 5, 2019
199
Re ripple you ask about why some say rectification.
Your original post was about achieving a DC level , for which rectification is required , hence people answered your question.

But as is often true in engineering , when step back is taken , then there might be better ways of achieving what you want.

So instead of full wave rectification, assuming +ve and -ve parts of the mains are similar enough for you, then half wave rectification is practical

Also question of to use transformer or not.
You could use 1:1 , and resistor voltage drop either on the secondary or after rectification.

Or you could use a 230 v to ,3v transformer , and do away with voltage divider resistors

Again , with transformer , rectification is easier
But your Arduino is over sampling the mains frequency , so it's easy to use simple rectification and filtering in the code to achieve the effective DC level. Fewer components .

I'm certain there are other ways as well. Thinking of may be capacitive divider direct off the mains , etc all.

Which is best for your application is at the heart of engineering, knowing which way to go !
Things like quantity , where sold , regulations

Hope it goes well
Well said @drjohsmith , yes looks like DC level achieving is a fact. I am looking also for a true RMS value correction. Lets think about 230 v to 11v transformer. For less component @Ian0 is right may be and my last circuit will also work. But here is a circuit that could give a good result, if we dont use bridge rectifier.

voltage-circuit2.png
 

Ian0

Joined Aug 7, 2020
13,144
Several capacitively coupled circuits have been suggested. Whether they are suitable depends a lot on whether the phase on the signal is important or just the amplitude.
It is suprising how large the coupling capacitor needs to be to avoid any phase errors, and if the capacitive reactance is important in the calculation then the tolerance of capacitors needs to be taken into account.
 

Ian0

Joined Aug 7, 2020
13,144
But don't you care about current in secondary?
I would like as little current as possible in the secondary, as all it can do is introduce errors in measurement due to the resistance of the transformer windings. If that is a known value, it can be factored in.

The only rectifying circuits I would consider would use the op-amp "perfect diode" circuit, as any others will introduce errors due to the unknown voltage drop and effective resistance of the diode.
 

eetech00

Joined Jun 8, 2013
4,706
@Ian, this circuit is definitely an easiest one and it has less number of component. But don't you care about current in secondary? Lets say its 220V to 3V conversion The resistors aren't with high wattages ? You have another 3.3V refence VCC. I also want to know why some people use diode bridge for rectification or does the ripple need to be in consideration. Perhaps you are trying to figure out that the input node should have a stable analog voltage. Someone else has suggested a bit different circuit, In this rough schem. the ADC would have to find the peak to peak value to calculate the RMS, but at least there's no diodes.

View attachment 361598

Does it also OK to you?
No.
The 3VAC signal should be shifted so that the pk-pk value spans the ADC input range.
A 220VAC-3VAC mains transformer is not easy to find. It would easier to find one with a 6, 9, or 12 VAC output.
If this is for your voltage stabilizer, input/output linearity of the input signal conditioner is more important, since the measured signal will be read by the arduino to drive relays, that switch autotransformer taps, based on the measured AC input voltage level.
 

Thread Starter

Hasan2019

Joined Sep 5, 2019
199
No.
The 3VAC signal should be shifted so that the pk-pk value spans the ADC input range.
A 220VAC-3VAC mains transformer is not easy to find. It would easier to find one with a 6, 9, or 12 VAC output.
If this is for your voltage stabilizer, input/output linearity of the input signal conditioner is more important, since the measured signal will be read by the arduino to drive relays, that switch autotransformer taps, based on the measured AC input voltage level.
Well said @eT, you saw in my LTspice simulation we had difficulties making the main transformar when I wanted to implement LM324, that simulation is also warkable. If you look in this post you can find( #16 post) 2 suitable circuit those are opto coupled, one is more realistic I would say. But if we think about *True Vrms* then last #28, #29, and #32 circuits are helpfull. There is some true RMS detecting Chips and sensors available in market but may be expensive, In simulation proteus I am avoiding Autotransformer. At this moment, 8 to 3 line decoder SPICE design work is paused.
 

eetech00

Joined Jun 8, 2013
4,706
Well said @eT, you saw in my LTspice simulation we had difficulties making the main transformar when I wanted to implement LM324, that simulation is also warkable. If you look in this post you can find( #16 post) 2 suitable circuit those are opto coupled, one is more realistic I would say. But if we think about *True Vrms* then last #28, #29, and #32 circuits are helpfull. There is some true RMS detecting Chips and sensors available in market but may be expensive, In simulation proteus I am avoiding Autotransformer. At this moment, 8 to 3 line decoder SPICE design work is paused.
Why do you need "True RMS"? You aren't computing power. You just need to be able to accurately determine the value of the voltage of the AC input signal.
 

drjohsmith

Joined Dec 13, 2021
1,612
I would like as little current as possible in the secondary, as all it can do is introduce errors in measurement due to the resistance of the transformer windings. If that is a known value, it can be factored in.

The only rectifying circuits I would consider would use the op-amp "perfect diode" circuit, as any others will introduce errors due to the unknown voltage drop and effective resistance of the diode.
you mention accuracy,
do we know what accuracy the OP is requiring ?
do we knkw is this absolute or relative change they are after ?
 

Ian0

Joined Aug 7, 2020
13,144
you mention accuracy,
do we know what accuracy the OP is requiring ?
do we knkw is this absolute or relative change they are after ?
There was mention of a 10-bit ADC, that's 1 part in a 1000, or 0.1%, so I was assuming somewhat better than 1% ?
 

drjohsmith

Joined Dec 13, 2021
1,612
There was mention of a 10-bit ADC, that's 1 part in a 1000, or 0.1%, so I was assuming somewhat better than 1% ?
yeh,
thats the pic standard ADC I seem to remember ,
wonder if the OP needs that resolution , it wont change the ADC, but would affect the solution the select me thinks , well spoted .
 
Top