Forums

small (3A) AC current measurement

Started by Luis Perez November 25, 2011
On Nov 28, 11:42=A0pm, Luis Perez <lp.guan...@gmail.com> wrote:
> On 27 nov, 22:40, NT <meow2...@care2.com> wrote: > > > > > On Nov 27, 10:04=A0pm, Luis Perez <lp.guan...@gmail.com> wrote: > > > > On 27 nov, 18:18, Joerg <inva...@invalid.invalid> wrote: > > > > > NT wrote: > > > > > On Nov 27, 4:54 pm, Luis Perez <lp.guan...@gmail.com> wrote: > > > > >> On 26 nov, 16:18, Joerg <inva...@invalid.invalid> wrote: > > > > > [...] > > > > > >>>> This would be for both, allowing me to keep a constant tempera=
ture
> > > > >>>> more precisely, and monitoring how the resistance drops back t=
o room
> > > > >>>> temperature according to different environmental conditions. B=
ut for
> > > > >>>> now I'm more concerned with getting the initial circuit workin=
g.
> > > > >>>> Can't wait to see voltage, current and resistance on my laptop=
's
> > > > >>>> screen in "real time". It's gonna be quite an achievement! heh=
e.
> > > > >>> Well, good luck :-) > > > > > > You've got rid of the excess opamps, but T20 is redundant, and I > > > > > reckon there's a diagram mistake with D4. Psu regulation isnt nee=
ded
> > > > > for the opamp(s). > > > > > That depends. If Luis uses one of those newfangled 5V opamps he nee=
ds
> > > > regulation. A LM324 doesn't need regulation. But ... then I would n=
ever
> > > > drive the ADC pin directly with that. One spike on the input and th=
e
> > > > opamp would try to drive the ADC pin to 10V or so. Not sure whether=
the
> > > > ADC input would survive that. At least that needs to be lokked at. > > > > > [...] > > > > > -- > > > > Regards, Joerg > > > > >http://www.analogconsultants.com/ > > > > Thanks, > > > > Heh, you know some spanish, don't you? > > > > What you mean with grounding at the top of T16? Forgot to ask that in > > > my last post. I've wired as I understood it, for you to see in this > > > last schematics: > > > >https://docs.google.com/viewer?a=3Dv&pid=3Dexplorer&chrome=3Dtrue&srci=
d=3D0Bz...
> > > > But you're obviously right, one of the problems is that ground is > > > floating. I would even use a rectifier just to get the ground > > > reference on T26, can't wait to see this on the breadboard and play > > > with it, hehe. > > > > I've simulated it a little bit more, and have changed the values such > > > that input to the opamp will never exceed it's supply voltage, which > > > is going to be 5V that it'll share with the mcu from the 7805 (unless > > > greater voltage would be better). > > > > As you also said large resistors are evil for accuracy, would it be > > > better to scale down the voltage divider as much as possible then? > > > > The mcu is an atmega164. It shouldn't have a problem driving the opto > > > with 1K resistor, or even less. > > > > I've corrected the short on the triac, have mirrored it (did it to > > > save space but looked really odd), and added the shunt. I've also > > > uploaded an image of what ltspice has to say about the opamp > > > subcircuit (blue trace being opamp's output, and green voltage at the > > > voltage divider): > > > >https://docs.google.com/leaf?id=3D0BziRtOXljuLhNTg1MTViNjktNjVjYi00NmF=
j...
> > > > Regards, > > > How is shorting T16 going to work? Do you really think a mains > > transformer is cheaper than a transistor & zener? > > > NT > > Thanks, I'll look for info on that and how it should be used.
Simple V reg: -----+-------+ | | | | R | | | | | +-----(<) Tr | |______ Vout | Z | | -----+-------- Ov Drop all the voltage you want with that. A C across Z cuts noise, if needed. NT
Luis Perez wrote:
> On 27 nov, 22:46, Joerg <inva...@invalid.invalid> wrote: >> Luis Perez wrote: >>> On 27 nov, 18:18, Joerg <inva...@invalid.invalid> wrote: >>>> NT wrote: >>>>> On Nov 27, 4:54 pm, Luis Perez <lp.guan...@gmail.com> wrote: >>>>>> On 26 nov, 16:18, Joerg <inva...@invalid.invalid> wrote: >>>> [...] >>>>>>>> This would be for both, allowing me to keep a constant temperature >>>>>>>> more precisely, and monitoring how the resistance drops back to room >>>>>>>> temperature according to different environmental conditions. But for >>>>>>>> now I'm more concerned with getting the initial circuit working. >>>>>>>> Can't wait to see voltage, current and resistance on my laptop's >>>>>>>> screen in "real time". It's gonna be quite an achievement! hehe. >>>>>>> Well, good luck :-) >>>>> You've got rid of the excess opamps, but T20 is redundant, and I >>>>> reckon there's a diagram mistake with D4. Psu regulation isnt needed >>>>> for the opamp(s). >>>> That depends. If Luis uses one of those newfangled 5V opamps he needs >>>> regulation. A LM324 doesn't need regulation. But ... then I would never >>>> drive the ADC pin directly with that. One spike on the input and the >>>> opamp would try to drive the ADC pin to 10V or so. Not sure whether the >>>> ADC input would survive that. At least that needs to be lokked at. >>>> [...] >>>> -- >>>> Regards, Joerg >>>> http://www.analogconsultants.com/ >>> Thanks, >>> Heh, you know some spanish, don't you? >> Not really but I wish I could. What I do know is the important stuff >> such as margarita and cerveza :-) >> > > Hahaha, nice! Those are actually important words when in hollidays. > You can also say "birra" for cerveza. >
Interesting. I thought that birra was Italian.
>>> What you mean with grounding at the top of T16? Forgot to ask that in >>> my last post. I've wired as I understood it, for you to see in this >>> last schematics: >>> https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0Bz... >>> But you're obviously right, one of the problems is that ground is >>> floating. I would even use a rectifier just to get the ground >>> reference on T26, can't wait to see this on the breadboard and play >>> with it, hehe. >> A few comments: The triac gate is still shorted. T20 is also now shorted >> ... tsssst ... *POOF* :-) >> >> Run the ground at U56 pin 2 over to the top of T16 and get rid of the >> two other lines. U56: The shunt drops only a very low voltage so you >> don't need the R40/R44 divider. Get rid of R56, there should be no >> resistors in an opamp supply. But provide a 0.1uF bypass capacitor tight >> at the opamp. Also several of those at the MCU. Reduce R60 and increase >> R2 until you get the desired full scale rading for current. >> >> 1k for R150 sounds too high, not enough current, but I don't know what >> type U60 is. >> >> Also, now you have a current reading but the voltage monitoring has >> somehow disappeared. Ha desaparecido. >> > > Ok. I didn't have much time today, haven't been arround. > > There's nothing wrong using an lm324. I've got some arround I can > employ for this, so I've added an lm7812 to power the opamps (is it > ok, or is even better to rectify and use the 24V?), connected the > ground to (now) T2 as you said, and finally removed the sort on the > triac. >
Rectified 24V would be 34V, plus tolerance and spikes. Too much for a 7812 and for a LM324. You could use a resitors-zener-transistor regulator to get that to 12-25V.
> Also, I was looking at the lm78xx datasheet, and I was wrong. The > regulators accept up to 35V, but still an 7805 would get too hot off > the 24V I reckon. Perhaps the 78012 (if being kept) would dissipate > "acceptably" and T1 can be removed, never tried so far. >
A 24V transformer when running without load and a high line voltage (night time, et cetera) can easily put out 30V. Rectified that is over 42V ... tzzzt ... *BANG*
> For the half an hour I could spend on this today, I couldn't make > LTspice show any variations in the output signal by playing with the > opamp's gain after having removed the voltage divider though. >
That isn't normal, something must be wrong. But I think I know why, see at the end of the post.
> Given now is powered above mcu's vcc, a biasing stage will be needed > at each output to make it match. But it's fine as the lm324 stil has > spare ones. >
This is one reason why an opamp that is designed for the same supply voltage as the MCU is better: It cannot overdrive the MCU pins. And you save parts because you can use the same supply.
> This is the last version of the schematics: > > https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0BziRtOXljuLhMzliNDg4MGMtNzY2OC00NzM1LTllMWMtMjYxYzQ5ZDVkMDky&hl=es >
It doesn't look quite right yet. Some comments: The ground line from U4 pin 2 needs to go to the left side of R_Shunt. And we now have the reason why LTSpice didn't work: The positive input of both opamps is shorted to ground. The upper opamp would now measure current but must amplify more. I think you said max load is 2A, so that's 2.8A peak. Let's say 3A. 0.01ohms will then drop 30mV. If the ADC wants 2V input range (don't know, you'd have to calculate that) this needs an amplification of 66.6. Right now you only have 11. So R5 needs to be much larger. Also the LM324 has too much offset error here. Best would be to use a RR (rail-to-rail) opamp that can be supplied 5V like your MCU, and has a low offset voltage. Under 1mV or something like that. It'll cost more but not much. The lower opamp would measure voltage but must be connected to the lower end of R_Load. It must get a divider because 24V times 1.41 is too much. Also, it needs a diode in front of that divider because the opamp should never see a negative input. -30mV for the other opamp is usually ok (but check its datasheet first), more than -300mV is normally not ok. The diode will produce an offset of around 600mV but the MCU can calculate that out. [...] -- Regards, Joerg http://www.analogconsultants.com/
On 29 nov, 01:21, Joerg <inva...@invalid.invalid> wrote:
> Luis Perez wrote: > > On 27 nov, 22:46, Joerg <inva...@invalid.invalid> wrote: > >> Luis Perez wrote: > >>> On 27 nov, 18:18, Joerg <inva...@invalid.invalid> wrote: > >>>> NT wrote: > >>>>> On Nov 27, 4:54 pm, Luis Perez <lp.guan...@gmail.com> wrote: > >>>>>> On 26 nov, 16:18, Joerg <inva...@invalid.invalid> wrote: > >>>> [...] > >>>>>>>> This would be for both, allowing me to keep a constant temperature > >>>>>>>> more precisely, and monitoring how the resistance drops back to room > >>>>>>>> temperature according to different environmental conditions. But for > >>>>>>>> now I'm more concerned with getting the initial circuit working. > >>>>>>>> Can't wait to see voltage, current and resistance on my laptop's > >>>>>>>> screen in "real time". It's gonna be quite an achievement! hehe. > >>>>>>> Well, good luck :-) > >>>>> You've got rid of the excess opamps, but T20 is redundant, and I > >>>>> reckon there's a diagram mistake with D4. Psu regulation isnt needed > >>>>> for the opamp(s). > >>>> That depends. If Luis uses one of those newfangled 5V opamps he needs > >>>> regulation. A LM324 doesn't need regulation. But ... then I would never > >>>> drive the ADC pin directly with that. One spike on the input and the > >>>> opamp would try to drive the ADC pin to 10V or so. Not sure whether the > >>>> ADC input would survive that. At least that needs to be lokked at. > >>>> [...] > >>>> -- > >>>> Regards, Joerg > >>>>http://www.analogconsultants.com/ > >>> Thanks, > >>> Heh, you know some spanish, don't you? > >> Not really but I wish I could. What I do know is the important stuff > >> such as margarita and cerveza :-) > > > Hahaha, nice! Those are actually important words when in hollidays. > > You can also say "birra" for cerveza. > > Interesting. I thought that birra was Italian.
Perhaps it is, I don't really know, but that's it's casual name here.
> > > > > > > > > > >>> What you mean with grounding at the top of T16? Forgot to ask that in > >>> my last post. I've wired as I understood it, for you to see in this > >>> last schematics: > >>>https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0Bz... > >>> But you're obviously right, one of the problems is that ground is > >>> floating. I would even use a rectifier just to get the ground > >>> reference on T26, can't wait to see this on the breadboard and play > >>> with it, hehe. > >> A few comments: The triac gate is still shorted. T20 is also now shorted > >> ... tsssst ... *POOF* :-) > > >> Run the ground at U56 pin 2 over to the top of T16 and get rid of the > >> two other lines. U56: The shunt drops only a very low voltage so you > >> don't need the R40/R44 divider. Get rid of R56, there should be no > >> resistors in an opamp supply. But provide a 0.1uF bypass capacitor tight > >> at the opamp. Also several of those at the MCU. Reduce R60 and increase > >> R2 until you get the desired full scale rading for current. > > >> 1k for R150 sounds too high, not enough current, but I don't know what > >> type U60 is. > > >> Also, now you have a current reading but the voltage monitoring has > >> somehow disappeared. Ha desaparecido. > > > Ok. I didn't have much time today, haven't been arround. > > > There's nothing wrong using an lm324. I've got some arround I can > > employ for this, so I've added an lm7812 to power the opamps (is it > > ok, or is even better to rectify and use the 24V?), connected the > > ground to (now) T2 as you said, and finally removed the sort on the > > triac. > > Rectified 24V would be 34V, plus tolerance and spikes. Too much for a > 7812 and for a LM324. You could use a resitors-zener-transistor > regulator to get that to 12-25V. > > > Also, I was looking at the lm78xx datasheet, and I was wrong. The > > regulators accept up to 35V, but still an 7805 would get too hot off > > the 24V I reckon. Perhaps the 78012 (if being kept) would dissipate > > "acceptably" and T1 can be removed, never tried so far. > > A 24V transformer when running without load and a high line voltage > (night time, et cetera) can easily put out 30V. Rectified that is over > 42V ... tzzzt ... *BANG* > > > For the half an hour I could spend on this today, I couldn't make > > LTspice show any variations in the output signal by playing with the > > opamp's gain after having removed the voltage divider though. > > That isn't normal, something must be wrong. But I think I know why, see > at the end of the post. > > > Given now is powered above mcu's vcc, a biasing stage will be needed > > at each output to make it match. But it's fine as the lm324 stil has > > spare ones. > > This is one reason why an opamp that is designed for the same supply > voltage as the MCU is better: It cannot overdrive the MCU pins. And you > save parts because you can use the same supply. > > > This is the last version of the schematics: > > >https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0Bz... > > It doesn't look quite right yet. Some comments: > > The ground line from U4 pin 2 needs to go to the left side of R_Shunt. > And we now have the reason why LTSpice didn't work: The positive input > of both opamps is shorted to ground. >
Yes, that was something I forgot to correct, but was doing it right on the simulation. When I said I couldn't see any change in the output signal by playing with the gain, I meant in amplitude of the output signal. But I was thinking earlier today what you want is the output signal to follow the input one precisely, instead in squared form as in the previous shot? like this: https://docs.google.com/leaf?id=0BziRtOXljuLhMjk3ZTIzNGQtMWVlZi00NjdlLTg3YWEtZDg4MGRlYjQwNjdm&hl=en_US
> The upper opamp would now measure current but must amplify more. I think > you said max load is 2A, so that's 2.8A peak. Let's say 3A. 0.01ohms > will then drop 30mV. If the ADC wants 2V input range (don't know, you'd > have to calculate that) this needs an amplification of 66.6. Right now > you only have 11. So R5 needs to be much larger. >
Well, the chip has a 10-bit adc which can stand from 0V to it's vcc (5V). I just need to make to make sure the signal fed to it always stays between, say, 10mV and 4.90 or 4.95V. Can adjust a bit more, but the former is because no adc result will ever yield 0, and the latter because I want to leave some room to detect signal clamping (over-current or over-voltage condition). All this is based on 24V * 1.414.
> Also the LM324 has too much offset error here. Best would be to use a RR > (rail-to-rail) opamp that can be supplied 5V like your MCU, and has a > low offset voltage. Under 1mV or something like that. It'll cost more > but not much. >
The ony rail-rail opamps I can savage are lm358's, but I guess they won't be usable either because both have same offset voltage (typ. 2, max 7). Actually, both look quite similar to each other, don't they? besides the rail thing. So, I'll look for some suitable one, and either buy it or ask for samples if I couldn't find it locally. These are the corrected schematics: https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0BziRtOXljuLhODhlMTE1MDItNmM2Zi00OWFhLThmM2QtMjgxOGFjYzU4YmZh&hl=es
> The lower opamp would measure voltage but must be connected to the lower > end of R_Load. It must get a divider because 24V times 1.41 is too much. > Also, it needs a diode in front of that divider because the opamp should > never see a negative input. -30mV for the other opamp is usually ok (but > check its datasheet first), more than -300mV is normally not ok. The > diode will produce an offset of around 600mV but the MCU can calculate > that out. >
Sure, I'll take care of that once I've selected an opamp. Thanks!
> [...] > > -- > Regards, Joerg > > http://www.analogconsultants.com/