AC voltage sensor using Rectifier

ci139

Joined Jul 11, 2016
1,989
Last edited:

DickCappels

Joined Aug 21, 2008
10,661
1590585618572.png
LT1078 id recommended if you want linearity almost all the way 0 volts. Otherwise a low leakage opamp such as the TL072 dual opamp is recommended. In this schematic, the ground symbol represents earth ground.

Attachment: AC Voltage detector.asc
 

Attachments

Thread Starter

vars90r

Joined Mar 24, 2020
30
Hello

I did make the circuit on a breadboard. I powered the opamps using rectifier voltage from the same 120Vac I referenced everything wrt ground as you suggested. I got the output. It works great.

When I float the AC voltage while the neutral is connected, I'm getting 1.8V at the output of the opamp? The output of the opamp is zero but It's getting the voltage from the feedback resistor. It's not a big deal, I can have a 2 V offset and read the value. I just want to know why I'm getting this voltage.

I see that you used a unity gain buffer at the end. Is this for isolation or just for more stability?
 

DickCappels

Joined Aug 21, 2008
10,661
The output of the peak detector needs to drive R2 and the ADC so to minimize the loading on the peak detector capacitor and the error it might cause and to present a nice low impedance with which to drive A-to-D the buffer U5 was added.

As for the offset, what are you using as the opamp?
 

Thread Starter

vars90r

Joined Mar 24, 2020
30
I understand. I used LM358 op-amp from TI for this test. I plan on buying LM358P for the actual implementation. It is a 4 circuit opamp, so it saves space on the PCB.

I have 4 AC voltages to sense. So 2 LM358P opamps should do it. One will be used as a peak detector U4 and the other will be used as U5 buffer.
 

DickCappels

Joined Aug 21, 2008
10,661
I don't know where the offset is coming from. Some of it is a limitation on the output voltage range of the LM358/LM324, some is a combination of the input bias current and the input offset (bias) current times the resistance connected to the inputs.

You can probably improve the offset as a function of input offset current by reducing the four resistors by a factor of 10 (the circuit I showed was for a very high impedance, rail-to-rail opamp, the LM358/LM324 has bipolar inputs and much higher bias current.

You can improve on the output stage's dynamic range -helping it get closer to ground by adding a resistor from the output to ground (for example: 1K) to help the output go to a lower voltage.

Similar application with the 1k resistor to ground:
1591383488831.png


The LM324 is the version with four channels.
 

Thread Starter

vars90r

Joined Mar 24, 2020
30
Hello

I ran the setup without Vac, (Just the neutral was connected) for about an hour and the ADC which started off reading 1.5 V went up to 4 V. Also If I first connect Vac then remove it after 5 minutes, the ADC reads 14V for a while. Seems like the capacitor (47u) is storing charge here and when it was just 1V it's gradually charging. Hence the 4V reading.

Dick cappels, Not sure if you are saying the same thing but I put a bleeder resistor across the capacitor.

Now the ADC always reads below 1V when AC is floating and reads a solid 12.5 when it's connected to 120Vac. It's a lot more stable after I put the bleeder resistor(1M).

Sorry LM324 is the four-channel one. I think I copied the same LMU part no twice. I'll buy two of these and should be able to read 4 AC inputs. I'll run the setup again tomorrow just to see if I missed anything.
 

DickCappels

Joined Aug 21, 2008
10,661
No, I was not saying that but you found that there should be. Just put a resistor across the capacitor that gives a suitable time constant. I am sorry I left the bleeder out.

In post #26 I have this snippet from a schematic showing a 1k resistor from the output of the opamp to ground to help the output get closer to ground. That may or may not be necessary.
1591771544267.png

It is probably best to try your bleeder and see if that solves the problem before trying this extra resistor.
 

Thread Starter

vars90r

Joined Mar 24, 2020
30
Hello

I used a bleeder resistor and the charging of the capacitor to 4-5V is not happening anymore. There is still an offset of around 1V which is fine honestly. I ran this setup for 6 hours today and saw 4 ADC reading of 3V. Is the bleeder resistor too high, and its causing delay in discharging the capacitor?

I have attached the final schematic. It doesn't show anything wrong in the simulations but in real life, we never know. I'm just little skeptic about the values of the capacitor and its bleeder resistor. When it was connected to 123Vac, it sometimes read 135Vac. Is this because the bleeder resistor is contributing to the voltage which is being read by the ADC?

Reducing the bleeder resistor is ruining the smoothed output of the capacitor. 1K is too low according to the simulation. ACsensor (2).PNGACsensor (2).PNG
 

DickCappels

Joined Aug 21, 2008
10,661
1591884390626.png
The discharge curve looks a lot like this one above, except it will be upside down. Charging is very fast because it is limited by the resistance of the diode and the opamp's drive capability.

With the values shown on your schematic the discharge time constant is 10 seconds (t = RC). That means it takes 10 seconds for the voltage to move from where it is at any moment by 63% of the way to ground. In theory it will never get to ground but just take that as an amusing fact.

Whether the resistor and capacitor are good values for your application depends upon the how responsive your setup is to changing input and the tolerable droop rate of the detected voltage.

To make the discharge rate twice as much cut the capacitor or resistor in half, etc.
 

ci139

Joined Jul 11, 2016
1,989
don't follow me

using the "quadrature oscillator" (that incase your input is a Sine with fixed frequency) and formula A√(Sin²x+Cos²x)=A -- you may be able to define a better response . . . ! at certain voltage range . . . which in turn means - you'd have to add an auto-ranging input
the arithmetics is easily done by a bunch of 4 quadrant multipliers . . . keeping in mind that in practice the Cos may be a bit lower amplitude than the Sine . . . checking

. . . a Falstad simulation http://tinyurl.com/ycfbdsyg -- the lockup amplitudes must be statistically studied for particular op amp model
 
Last edited:

Reloadron

Joined Jan 15, 2015
7,891
Going back to your first post in this thread:

Hello
I'm trying to implement a rectifier and AC voltage sensor. The rectifier part works just fine. I'm able to power my device without any issues.
Please look at C2 in the screenshot (Circuit schematic). This connector is connected to AC voltages. Vin is a rectifier and the DC part is to power the device.
AC-1 to AC-5 are AC voltages that are sensed at ADC-0 to ADC-4 respectively. AC-6 is the neutral line of all the AC voltages connected to the board.
When AC (1-5) are connected to AC voltage, the device works just fine. No issues at all. But when AC-1 and AC-2 are connected to 120 VaAC while AC (3,4 and 5) are not connected to anything, ADC-0 and ADC-1 read the right value but ADC (2,3 & 4) read 7.5V while they should read 0 V.

I connected all the -ve terminals of the bridge rectifiers to have a common ground but when there is no AC voltage, the respective +ve terminals of the bridge rectifiers reads 58V (+ve is floating while -ve is grounded). Is there any way to fix this? cause my ADC is reading the incorrect value of 7.5V when it should read 0 V.

Thank you
OK, all of your AC neutrals are common. Here is what I don't understand, maybe in this thread or maybe the previous thread I mentioned using a ZMPT101B which comes in a module rather than just the transformer. The modules are less than 1/2" wide and under 2" long. I see them on E Bay for as low as $3.00 USD each and assorted prices on Amazon. The circuit looks like this:
ZMPT101B Schematic.png
All of that on a single small module run from a single 5.0 volt supply. The transformer is a small 1:1 (2 mA : 2mA) Ratio and R11 serves as a simple burden resistor. I remembered I had a few I got several years ago for a project. With isolation I guess I don't see the need for converting to DC? Any micro controller can measure an AC waveform do some math and give an accurate true RMS value. I found one I had and connected it to a simple Arduino. I compared my measured AC values to a Fluke 87 DMM true RMS meter. This is what I was getting.

ZMPT101B Serial Monitor.png

Within a few tenths of a volt after I adjusted the module. Additionally the module includes a 2.5 VDC offset of the AC signal. My AC signal into the uC was right about 1.0 Volt Pk to Pk into my ADC. Unless an ADC can measure below 0.0 V and you want to input AC the AC needs an offset.

Here is a simple plot, as I mentioned the actual waveform on my scope measured about 1.0 Volt Pk to Pk.
ZMPT101B Serial Plot.png

All of this took maybe 30 min and that was to do some code research. In addition to the pictured serial port monitor I also have the mains line voltage displayed on a LCD. I can easily set any threshold I want as to low voltage to make something happen.

These mosules are as low as $2.36 USD on Ebay and I also see them on Amazon. Ebay versions. Amazon versions.

I guess I just don't understand the need for DC? Even at $8.00 per module five modules would cost $40 and you are done. The code is repetitive for all 5 ADC channels. Matter of fact I cheated and used a library. Space? I can lay out 5 modules in the palm of my hand with room to spare. I can't roll my own for the cost involved.

Ron
 

ci139

Joined Jul 11, 2016
1,989
just run the test of what i speculated might work . . . the voltage delay will be greater the 14ms simulated because there will be (1) a squaring circuit (2) a summing stage and (3) the square-root stage + (4) maybe final scaling ... anyway it simulates much better than i was afraid it will
...
sure you might delay your sine and in µC and compute the amplitude = lesser chips and tuning -- but likely an extensive CPU load (for the micro)
Random - Op-Amp - TEST - iZ-8aF-uGxB.png
+ not exactly tuned ic v. Random - Op-Amp - TEST - iZ-8aF-uGxBi.png
 
Last edited:

Thread Starter

vars90r

Joined Mar 24, 2020
30
Hello

The ADC that I'm using doesn't read AC. I have attached the output of the reading that my ADC's are reading. T6 is rectified signal while R2 is not properly rectified. It reads different values every time. Anyhow, the sensor works just fine now. I have been experimenting with different time constants and finally found the perfect pair of C and R so that I can get a very stable output. Just two opamps did the job. A 4 channel opamp costs 38 cents. Hardware is perfect guys. No more changes. I started the board design. It should be done in a day or two.

Last question: (promise)
I'm currently using electrolytic capacitors (100uF) for smoothing the output. On the final PCB board, Shall I just go with Electrolytic or shall I switch to a ceramic capacitor? Both have their pros and cons and I'm debating on this.

circuits.PNG
 

Thread Starter

vars90r

Joined Mar 24, 2020
30
there is another dedicated chip (but i donno about it's settling/response times)
https://www.analog.com/media/en/technical-documentation/data-sheets/AD536A.pdf
Thank you but I don't need the chip. I'm way past looking for chips right now. The hardware setup is working just fine. I have been simulation this since last week. I'm designing the board right now(trying to make it as compact as possible). The only debate right now is to use ceramic or electrolytic capacitors for smoothing. I have attached the schematic to this message. If you can answer that, that would be of a great help.

ISO224sch.PNG
 

DickCappels

Joined Aug 21, 2008
10,661
At first I did not imagine ceramic capacitors were up to 100 uf yet, but found some at Mouser for about $40 each.

You can aluminum electrolytic capacitors should be just fine for your use.
 

ci139

Joined Jul 11, 2016
1,989
possible solution
LM324 - Rect - TEST - 2.pngthis is 2·f rectified input
what you can do with this . . .. is to mux it to 2...4x peak detectors that form 1-st IN prev. OUT buffer in front of the final output buffer
-- there may be an easier way to this all . . .
 

ci139

Joined Jul 11, 2016
1,989
the staircase generator has a feature that it won't hold the level too long but long enough to be compared with your output capacitor voltage
( the staircase basically does the same thing as your AC/DC stage -- if it's fed from rising edge of the sine . . . not sure if i will/can dig out an example for you too fast )
sample and hold circuits fall to similar category
combining (the elements) such may give some solution
((the LM324 LM358 have NPN input stage . . . so they rather increase not decrease your cap voltage))

something simple-stupid

LM324 - Rect - TEST - 2aa.png
 
Last edited:
Top