Using LM358 instead of LMV321 op amp

Thread Starter

Spike52468

Joined May 4, 2022
3
I am creating a solar generation monitor using this circuit, which I found here, as a starting point:
LMV321.JPG
I found that the LMV321 is unobtainable, so after researching found that the LM358 is an acceptable substitute. So my adjusted circuit diagram using the LM358 looks like this:
LM358 in circuit.JPG
My question is, have I done the conversion correctly, because I have built this circuit on a protoboard and the voltage reading is wildly erratic, swinging up to 6 volts peak to peak, a few times a second, on 240 volts in the UK.
 

Attachments

Thread Starter

Spike52468

Joined May 4, 2022
3
It spikes around 3 volts either side of the mains voltage. I don't know where this erratic behavior is coming from. My plug-in kwh-o-watt meter shows a steady voltage. It makes a mockery of power calculations. But I just wanted to be sure I was using the LM358 correctly.1.JPG
 

dendad

Joined Feb 20, 2016
4,637
Maybe add a series resistor (1K?) from the opamp out to the common 1/2V point, with a 10uF cap from there to 0V for better decoupling?
And a series R (1K?) from each reading point to the Arduino with a 100nF cap from Arduino input to 0V to help get rid of the high frequency noise.
 

Ian0

Joined Aug 7, 2020
13,131
You don't need an op-amp - this circuit will centre the output on half supply.
One thing you DO need is a protection resistor between the output of the CT and the A/D input. Otherwise, whenever the is a surge (inrush current) on the mains the output of the CT will blow up your Arduino. The two 10k resistors will achieve that at the same time as biassing the input to half supply.CDC4600A-6EFE-4ACD-AA6F-E06F28D95B7E.jpeg
 

MrAl

Joined Jun 17, 2014
13,702
I am creating a solar generation monitor using this circuit, which I found here, as a starting point:
View attachment 266431
I found that the LMV321 is unobtainable, so after researching found that the LM358 is an acceptable substitute. So my adjusted circuit diagram using the LM358 looks like this:
View attachment 266433
My question is, have I done the conversion correctly, because I have built this circuit on a protoboard and the voltage reading is wildly erratic, swinging up to 6 volts peak to peak, a few times a second, on 240 volts in the UK.
Hello,

Referring to the lower part of your schematic, can you actually do that? I dont think so.
I am talking about the connection between the output of the current transformer and the Arduino input.

If you connect an AC voltage source to an Arduino input, the negative excursions will blow the lower ESD protection diode and thus the chip.
Also, if the voltage goes over about 5.5 volts it can blow the upper ESD protection diode, and take the chip out with it also.
The usual way to handle this is to place a somewhat large value resistor between the source output and the Arduino input. That limits the current into the pin when the voltage exceeds the recommended value range. The resistor has to be sized to keep the current through those two diodes low enough so those diodes do not get an over current and burn out.
Probably better though is to add your own external protection diodes along with that series resistor, then a second series resistor between your protection diodes and the Arduino input. That will surely limit the current to a safe level and not stress the internal diodes.
For a single resistor, 10k would work probably depending on the voltage range of the output of the current transformer.
For the external diode setup, maybe 2k from current transformer to external diodes, then 1k from diodes to input, but you should do some calculations to verify these values.

I havent looked at the rest of the circuit yet.
 

Alec_t

Joined Sep 17, 2013
15,117
If you connect an AC voltage source to an Arduino input, the negative excursions will blow the lower ESD protection diode and thus the chip.
But here the reference voltage is 2.5V, not 0V, so a 5V peak-to-peak output from the current transformer would be ok.
 

dendad

Joined Feb 20, 2016
4,637
I agree with @MrAl about the input protection needed. For the design I've made, there are always added diodes with the series resistor. And a bypass cap to knock some of the noise off.
It does not hurt to "over engineer" protection as the main thing is reliability. You need to be able to cope with a gross overload condition, like a fault on your mains load causing a brief very high signal before the fuse blows. My industrial control designs have mostly stood the test of time as in that environment is a very tough one, and reliability is paramount. Something going very wrong is to be expected.
 

Thread Starter

Spike52468

Joined May 4, 2022
3
The AC/AC adapter is a Kreco KRE-0900951L, rated at 9v on the label but my meter gives the output at 11 volts, that seems to be normal with these adapters. I've not got a CT or its wiring connected at the moment, just trying to get the voltage section working right first. It may just be a poor quality adapter giving a jumpy output. Maybe I'll try a different one.

The CTs I'll be using are SCT013 50A / 1V, which the data sheet says don't need an external burden resistor as it's already built in
 

ag-123

Joined Apr 28, 2017
294
LM(V)321 and/or LM358 doesn't handle a lot of power, it is more like in the milliamps at the output stage, check the specs.
So it won't be able to handle the loads from the AC transformers. you would need extra stuff like a (power) transistor at the op amp output.

if you simply want the stepped down (dc) voltages, an easy way is to make a rectifier
https://www.allaboutcircuits.com/technical-articles/an-introduction-to-rectifier-circuits/
if the loads is small, the output is likely close to the peak ac voltages, at the stepped down end.
this is much easier and you can feed it to the Arduino input, use a resistor divider to step it down further to the safe range of course.
 
Last edited:

MrAl

Joined Jun 17, 2014
13,702
But here the reference voltage is 2.5V, not 0V, so a 5V peak-to-peak output from the current transformer would be ok.
Ok but still have to be careful that the 5v peak to peak does not go up too much for any reason or the chip blows out.
 

DickCappels

Joined Aug 21, 2008
10,661
Points are starting to repeat. To summarize:
He is measuring current and the LM358 is making a low impedance reference at 2.5 volts
An alternate means of applying the 2.5 volt reference proposed by @Ian0 is in post #7, making the LM358 redundant.
Per @dendad in post #12 It is a good idea to provide overload protection to the input of the A-to-D

Such a protection circuit is shown below. It might also be sufficient (Given that this is an AVR) to merely use a 10k resistor in series with the input and let the input clamp diodes take the clamping current.

Edit: Replaced circuit. For an analog input I would use a resistor of 10k.
1651863090553.png
 
You may want to use a split bobbin transformer to reduce or eliminate interwinding capacitance as a source of noise, which is what it looks like to me. I confess I don't know what this circuit is supposed to measure.
 

JLambert

Joined Apr 17, 2020
4
The LM358 is NOT an acceptable substitute for the LMV321 in this circuit.
Primary reason: the LMV321 can perform "rail to rail" .. the LM358 can not (it requires a minimum of 1.5v of head room from positive and negative power rails). if any signals (in or out)) is below 1.5v or above 3.5v - assuming room temp (using 5v power rail).. the LM358 will not perform as intended. Over the extended temperature range things only get worse.
The issues and alternative solutions mentioned by others are valid, but the simplest, most direct solution .. use a different op amp.

another issue: most DVMs are not suited for trouble shooting this circuit.
 
The LM358 is NOT an acceptable substitute for the LMV321 in this circuit.
Primary reason: the LMV321 can perform "rail to rail" .. the LM358 can not (it requires a minimum of 1.5v of head room from positive and negative power rails). if any signals (in or out)) is below 1.5v or above 3.5v - assuming room temp (using 5v power rail).. the LM358 will not perform as intended. Over the extended temperature range things only get worse.
The issues and alternative solutions mentioned by others are valid, but the simplest, most direct solution .. use a different op amp.

another issue: most DVMs are not suited for trouble shooting this circuit.
OR raise the rail voltage for the op amp. Max Headroom!
 
Top