Author Topic: Measuring Current in a Datalogger - shunts and amplifiers etc.  (Read 14839 times)

0 Members and 1 Guest are viewing this topic.

SparWeb

  • Global Moderator
  • Super Hero Member Plus
  • *****
  • Posts: 5452
  • Country: ca
    • Wind Turbine Project Field Notes
Measuring Current in a Datalogger - shunts and amplifiers etc.
« on: December 28, 2010, 08:26:48 PM »
Thought I'd ask for some suggestions on circuits that amplify the tiny voltage drop across a current shunt - enough to make it readable in a data logger.  I've been fussing about with op-amps to amplify the signal but if there's a better way I'd appreciate a few hints!  Anyone who's already tackled the problem may not need the explanation below, but I thought I'd just tell the whole story and maybe others can learn with me.

Starting at the beginning:

The data logger I'm using now has a problem measuring current.  Not a fatal problem, but I want more reliability than it can now provide.  The microcontroller in the data logger isn't sensitive enough to read the changes in voltage on a normal shunt - the mV voltage drop across a shunt will throw an ammeter needle to full swing - but barely count a couple of data points on the microcontroller.  The solution has been to use a shunt with about ~0.1 Ohm resistance - basically a home-made resistor.  Shunts typically have resistance of  milliOhms.  Using a much higher resistance gives my datalogger the amplification it needs to be able to read the voltge drop.  This "resistor" is also sensitive to ambient temperature and being home-made, it probably suffers from variable resistance in the screw terminals.  Basically I can pretend I'm logging good data but I don't fool myself for long.  The other problem with the datalogger is that it needs a "low-side shunt".  I prefer a properly grounded system.

I was working on a re-design of my datalogger, adding a few features, and then I came around to the problem of reading a shunt.  I need to pick up those few mV across the shunt, and amplifying them somehow so that the PIC microcontroller can read the difference in a meaningful way.

The PIC can convert an analog signal between 0-5V into a digital number between 0 and 1024.  From what I've seen it's a linear relationship so 2.5V = #512 and so on.  The input voltage has to go up by about 5 mV to make the number tick up from #512 to #513.  But as I just pointed out, a shunt doesn't need to drop voltage much to make an ammeter needle swing, only a few mV, so the entire range of current (say 0A - 50A) will only take up a handful of data points from the PIC's point of view.

To use all those data points in the PIC, I need to amplify the signal.  By a factor of 100 or so.  My idea so far has led me to op-amps, but I'm not finding circuit designs that do what I want.  I've also tried to develop my own op-amp circuits, capable of reading the voltage across the shunt and amplifying it, but the all come out VERY twitchy.  Breathe wrong on a trim potentiometer and the gain shoots up or down.

I'd share a circuit diagram but I'm afraid to display the depth of my ignorance!  Instead I'll try to summarize the numbers I'm trying to work with:

Battery voltage              = 24-28V (normal range to expect)
Absolute maximum Volt   = 32 V   (to not fry the electronics)
Practical minimum Volt     = 24 V   (doesn't have to be accurate below this)

Range of current to read = 0-40A   (accurately +/- 0.1 or 0.2 Amperes)
Maximum current to read = 50A      (safe limit)

Shunt   0-50A   @  0-50mV   (some typical part that can be found easily)

Datalogger Inputs:
   1   Battery voltage   (eg 28V)
   2   Shunt high-side voltage (eg 28.05V to detect 50 Amps)
   3,4,5   wind speed, RPM, etc., etc.

The PIC microcontroller can only work up to its Vcc (5V or so) so this defines the range that must be targeted by the amplifier.  Ideally, the amplifier would send out a 0v signal when there is not current, and the PIC will read it as #0.  Then as current increases (say 20A) then the amplifier spits out a voltge of 2.0V and the PIC will get about #256 or so, on up to 50A through the shunt and the amplifier's output has risen to a maximum of 5V and the PIC input reads #1024.

The circuit I've designed runs the battery voltage through a 1:5 voltage divider for reference (about 4.5V) and the shunt high-side voltage through a similar divider that I can calibrate with a potentiometer.  Because of the stepped-down voltages even the voltage drop across the shunt is reduced.  This is where I seem to be having problems with the op amp because the input differential is too small to calibrate.  Amplified 100X the shunt can sweep from, say 2.5V to 4.5V but only if I get the components JUST PERFECT.  No 2% tolerance allowed.  More like 0.1%...

Is there a better way?
No one believes the theory except the one who developed it. Everyone believes the experiment except the one who ran it.
System spec: 135w BP multicrystalline panels, Xantrex C40, DIY 10ft (3m) diameter wind turbine, Tri-Star TS60, 800AH x 24V AGM Battery, Xantrex SW4024
www.sparweb.ca

rossw

  • Hero Member
  • *****
  • Posts: 834
  • Country: au
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #1 on: December 28, 2010, 08:46:37 PM »
Is there a better way?

First things first.

Working with small voltages requires reasonable care and thought. Sometimes a change in aproach can help.

1. Chopper-stabilised amplifiers. These can REALLY help you get the most out of small DC voltages without all the bias and zero-drift that often plagues high-gain DC amplifiers.

2. If you don't want to go to that extent, consider using proper "instrumentation amplifiers" (the "right" animal for the job) rather than trying to force an opamp to do a job it isn't really suited to.

3. Avoid the whole issue of shunts and use one of the (many) hall-effect current sensors available. Most of these already include chopper-stabilised amplifiers and enough gain to directly drive your 0-5V input. They also have (virtually) no resistance, so power loss and heat are a non-issue. Their downside is noise, but depending on your application, you may be able to filter it (either analog or in software) to get enough precision for your needs.

Boondocker

  • Full Member
  • ***
  • Posts: 193
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #2 on: December 28, 2010, 09:27:33 PM »
I'm using a hall sensor from Allegro, part no. ACS752, to measure amperage.  No issues, it tracks extremely close with  Watt up Doc meter.

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=ACS752SCA-050-ND.


Janne

  • Full Member
  • ***
  • Posts: 244
  • Country: fi
  • Turbiini
    • My image gallery
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #3 on: December 29, 2010, 03:30:24 AM »
Hi,

If you're going forward with the shunt resistor, I'd recommend using a dedicated shunt amplifier for the job. For example, TI139 from texas instruments would allow you to have the shunt on the + line, avoiding the headache of having multiple "ground" potentials gives you. TI139 has offset voltage of 1mV, I suppose it would still be acceptable in this application. You can drive the PIC's adc directly from it, with the addition of a resistor and a capacitor to smooth the output.

Nothing's as easy as drilling a hole in the wrong place

Rover

  • Hero Member
  • *****
  • Posts: 788
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #4 on: December 29, 2010, 06:50:34 AM »
I've had good luck using amp100 hall sensors. They are  little more expensive, but incredibly simple to use. In my application I double loop the current carrying wire (12 AWG) through the sensor to increase sensitivity and bring he measurement range down to 0 to 50A. No op amp needed just straight to you ADC. I'd recommend going with a higher resolution ADC if possible, say 12 bit, to get more steps 0-4096

http://www.amploc.com/AMP%20Series.pdf
Rover
<Where did I bury that microcontroller?>

madlabs

  • Hero Member
  • *****
  • Posts: 686
  • Country: us
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #5 on: December 29, 2010, 10:58:44 AM »
I use the ADS7XX series of Hall effect current sensors. about 8 USD each, work great.

Jonathan

Flux

  • Super Hero Member Plus
  • *******
  • Posts: 6275
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #6 on: December 29, 2010, 12:06:35 PM »
For rough measurements cheap shunts are ok but you will need to think carefully with amplifiers when you have more than one shunt to deal with. Most decent amplifiers are good enough for this application and there are many instrumentation amps that are more than adequate but with multiple shunt you will have lots of problems with commom mode interference . We had to use isolators in large industrial applications and that is far too expensive for here.

If you are into serious measurement beyond the accuracy of fairly mundane op amps then you will be into the region of precision shunts ( not calibrated bits of copper wire)

Good quality shunts are so expensive that for this application that the hall effect transducers will likely work out cheaper and with far less problems. These take a fair bit of standby power so you may need to think if the system needs to supply these ( especially small systems). If you can run the meteorology from the mains then this is no real issue.

Logging data and getting answers is simple but if you want a correct answer then you may have to do a lot of work and cross checking. The world is plagued with digital readings to 4 decimal places but inherently inaccurate to 10s of % sometimes.
Flux

TomW

  • Super Hero Member Plus
  • *******
  • Posts: 5130
  • Country: us
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #7 on: December 29, 2010, 12:26:39 PM »
The world is plagued with digital readings to 4 decimal places but inherently inaccurate to 10s of % sometimes.
Flux

Yes, an important point!

Resolution is not the same as accuracy.

Tom

SparWeb

  • Global Moderator
  • Super Hero Member Plus
  • *****
  • Posts: 5452
  • Country: ca
    • Wind Turbine Project Field Notes
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #8 on: December 29, 2010, 01:21:28 PM »
Thanks everyone for the suggestions!

I definitely have been considering the Allegro sensors, and I find them "close" to what I need.  I must have had an old datasheet or something because the one I see on the website today is much much more detailed than the one I had for the ACS 758.  I also didn't see the Amploc before so I'll see what's available.  I'm still a bit uncomfortable with the idea of sending the current through a tiny black IC and expecting it to come out the other side - open circuit the wind turbine and it's game over.

I won't be using the mains power to keep the datalogger running.  I want it to run off the battery (24-28V).  I've been thinking of various ways to make it "sleep" and "wake up" only when needed.  The op-amps don't seem to draw much power when they aren't doing anything.  Of course adding more amps and increasing complexity increases the drain on the battery.  With solar and wind in my system, I have a daily recharge anywhere between 20 and 100 Amp-hours, so this isn't the highest priority.  If the datalogger relies on a lap-top computer to store data, then its power demand will be much greater.  I've played around with a small EEPROM, but my eyes glaze over quickly when the instruction books go into memory addresses and so on.

Internet searches have led me to instrument amplifiers and the Texas Instrument jobbies, too.  I'll spend more time looking at them because at the time they didn't rise above the noise.

Looking into the Wikipedia article on "chopper-stabilized amps" gave me a description of the problem I've got here, and I recognize some of the terminology better now too.  If, as you say, the Hall sensors probably have choppers inside them and do the whole job in one package, then you could say I'm doing this for the sake of education - you could also say I'm reinventing the wheel!

I guess all my fuss would be for nothing, if I can't calibrate my equipment and rely upon it to stay calibrated.  I am looking for as little error as possible, not just precision for its own sake, as Flux pointed out.  The game is not really to make it as complicated as possible!

Thanks again. 
No one believes the theory except the one who developed it. Everyone believes the experiment except the one who ran it.
System spec: 135w BP multicrystalline panels, Xantrex C40, DIY 10ft (3m) diameter wind turbine, Tri-Star TS60, 800AH x 24V AGM Battery, Xantrex SW4024
www.sparweb.ca

Tight Yorky

  • Newbie
  • *
  • Posts: 15
  • Country: gb
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #9 on: December 29, 2010, 01:52:31 PM »
Hello SparWeb,

I have read your post relating to battery monitoring and have jumped the same hurdle myself, as many of the other guys on this forum probably have.

I'll attempt to pass on a few pointers from a few of my unsuccessful, burnt circuits ...

If you elect to use Op-Amps in this type of application ensure the type used is a single rail / rail to rail type of device. A type I have used with success is the MC6002. The reason for the use of a rail to rail type is the way the PIC references it analogue to the 0v rail. These devices also avoid having to provide a +ve / 0V / -ve in your circuit.
When trying to use a non rail to rail device down to your 0V rail, it simply does not work correctly.

When using a shunt resistor, the circuit is trying to measure a differential voltage across it. This does mean you do not have to locate the shunt at the 0V end of the battery. For example, if the shunt is connected to the 24V terminal with the current is passing through it to the load, then one side of the shunt is at 24V the other side is at 23.9V. The differential voltage is 0.1V.
Although the description above points towards a "Differential Amplifier" circuit, the actual circuit is a "Two Op Amp Instrumentation Amplifier". Have a look on the web for examples. Don't forget to bring the battery voltages down to a value that can be handled by the op-amp using potential dividers.

Just one bit of advice about these sort of circuits, always do your power rating calcs (P=IV, P=I2R, P=V2/R) to ensure your design is realistic. Just noting your operating parameters relating to the shunt of 0.1 Ohm to take 50A. This would result in a 250 W rating for the resistor with a large volt drop. Perhaps prove a circuit works prior to investing in a milliOhm shunt.

Hope the above assists and avoids you reaching for the fire extinguisher.

Regards.
Clive.

jimovonz

  • Sr. Member
  • ****
  • Posts: 339
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #10 on: December 29, 2010, 03:20:14 PM »
I'm still a bit uncomfortable with the idea of sending the current through a tiny black IC and expecting it to come out the other side - open circuit the wind turbine and it's game over.

Hi Sparweb,

I would definitely go for the hall effect sensor. I have used the Allegro sensors for a number of applications including the same as yours and have had no problems. Your comment above regarding the high voltages with an open circuit wind turbine and destroying the 'tiny black IC' don't apply to the hall effect sensors as the current path through the IC is isolated from the other pins (typically thousands of volts) - it is only magnetically not electrically coupled. It should quite happily handle your typical open circuit wind turbine! If you are not so familiar with the techniques used to amplify such signals and the inherent problems then I am certain that using the appropriate Allegro hall effect sensor (or similar) will give you a good result for far less effort.

Rover

  • Hero Member
  • *****
  • Posts: 788
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #11 on: December 29, 2010, 04:36:32 PM »
Sparweb,

No black box, here is a pic of sensors box (excuse the mess). On the right are 4 amplocs with the double wire loop, on the left a MAX 186 ADC 8 channel, that they feed. I find using more than one is nice so that I can seperate out differennt charging and loads.

As far as power consumption the , my whole monitor (micro,LCD,amplocs,ADC,RF transmitter, clock) take little, ~1W at most , just make sure to "sleep" whatever is not in use if it has the capability.

As far as noise, from my Halls, none that I could measure with my tools

As far as accuracy, I calibrate against as of good as of unit as I have , and adjust in code as necessary.




« Last Edit: December 29, 2010, 04:43:44 PM by kurt »
Rover
<Where did I bury that microcontroller?>

SparWeb

  • Global Moderator
  • Super Hero Member Plus
  • *****
  • Posts: 5452
  • Country: ca
    • Wind Turbine Project Field Notes
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #12 on: December 30, 2010, 01:44:13 AM »
Rover:
EXACTLY.  How soon can you have a new one ready for me?   ;D 

Jim,
Yeah you saw the other side of the coin: an open-circuit turbine blowing through the insulation in the IC.  My perspective was of an overheated / thermally stressed IC cracking its internal shunt and causing the WT to go open-circuit.  Either way it's a disaster of course.  But I take it from your experience and description of the products that there is enough "meat" to pass 50 Amps through one of those little tabs, so I shouldn't really be worrying about it.  Fingers crossed?  The Amploc version gets around the problem of interrupting the wire altogether so I'm leaning toward those ones.

Clive,
You describe the problem well.  You may be surprised to learn that the datalogger I have now does rely on a ~0.1 ohm shunt and it definitely does get hot at 20+ amps!  Also, I've confirmed that there is a 2 to 3 volt drop across that resistor just like Ohm's law says there should be - so the turbine is actually running a couple of volts higher voltage than normal and turning a bit faster too!  Minor effects in the big picture, but altogether it's not an ideal way to collect "good" data about what the turbine is doing.
I have already decided that I do not want a "low-side" shunt - yet another compromise I've put up with for long enough.

This is working out well and I can see a path through the maze now.  Thanks again!   8)
No one believes the theory except the one who developed it. Everyone believes the experiment except the one who ran it.
System spec: 135w BP multicrystalline panels, Xantrex C40, DIY 10ft (3m) diameter wind turbine, Tri-Star TS60, 800AH x 24V AGM Battery, Xantrex SW4024
www.sparweb.ca

Rover

  • Hero Member
  • *****
  • Posts: 788
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #13 on: December 30, 2010, 08:29:17 AM »
Sparweb

"Rover:
EXACTLY.  How soon can you have a new one ready for me?     "

Figure a year  ;D, I'm in the process of building a new one around a different micro, its been taking me  a year as other projects sneak into my head and steal time :)

I'll be using the same metering methods in the new one , but I also need to reduce the clutter (as seen in the picture), the current one started out as a prototype/concept  that has been in service now for almost 2 years 24/7

Rover
<Where did I bury that microcontroller?>

Boondocker

  • Full Member
  • ***
  • Posts: 193

SparWeb

  • Global Moderator
  • Super Hero Member Plus
  • *****
  • Posts: 5452
  • Country: ca
    • Wind Turbine Project Field Notes
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #15 on: December 31, 2010, 06:16:34 PM »
Hey those really are the right things for the job.  I don't know what to do with a surface-mount SOIC chip, but I wouldn't have to, if I get the kit from APRS.

I just placed an order for the Amploc sensors.  I'm trying those out first.
No one believes the theory except the one who developed it. Everyone believes the experiment except the one who ran it.
System spec: 135w BP multicrystalline panels, Xantrex C40, DIY 10ft (3m) diameter wind turbine, Tri-Star TS60, 800AH x 24V AGM Battery, Xantrex SW4024
www.sparweb.ca

SparWeb

  • Global Moderator
  • Super Hero Member Plus
  • *****
  • Posts: 5452
  • Country: ca
    • Wind Turbine Project Field Notes
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #16 on: January 14, 2011, 03:30:02 PM »
...Still waiting for delivery....

No one believes the theory except the one who developed it. Everyone believes the experiment except the one who ran it.
System spec: 135w BP multicrystalline panels, Xantrex C40, DIY 10ft (3m) diameter wind turbine, Tri-Star TS60, 800AH x 24V AGM Battery, Xantrex SW4024
www.sparweb.ca

BrianSmith

  • Jr. Member
  • **
  • Posts: 94
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #17 on: January 16, 2011, 08:44:23 PM »
I built a little PCB to measure current / volts / rpms for some logging.  Here is a pdf of the front end schematic that has a nice INA270/1 current measuring IC from TI that is doing a good job for me and pretty low cost. It measures current across a shunt. It can measure on the high side upto 70-80V if memory serves.   FYI.

* mygenlog_sch.pdf (21.82 kB - downloaded 469 times.)

* mygenlog_pcb.pdf (22.75 kB - downloaded 353 times.)



SparWeb

  • Global Moderator
  • Super Hero Member Plus
  • *****
  • Posts: 5452
  • Country: ca
    • Wind Turbine Project Field Notes
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #18 on: January 17, 2011, 11:11:23 AM »
Brian,
It's simple and I like it.  What Vcc does the INA chip use?  I should go find the datasheet.
I recognize the input measurement circuits, though I never thought of using a half-wave rectifier to do it like that.  It would be interesting to try because I still seem to have some noise on the RPM circuit that I do use (opto-isolator).

Thank you!


Rover,

How long did it take you to recieve the sensors from Amploc?
I'm still waiting...
No one believes the theory except the one who developed it. Everyone believes the experiment except the one who ran it.
System spec: 135w BP multicrystalline panels, Xantrex C40, DIY 10ft (3m) diameter wind turbine, Tri-Star TS60, 800AH x 24V AGM Battery, Xantrex SW4024
www.sparweb.ca

commanda

  • Hero Member
  • *****
  • Posts: 731
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #19 on: January 17, 2011, 02:55:43 PM »
Brian,
I recognize the input measurement circuits, though I never thought of using a half-wave rectifier to do it like that. 

Thank you!


If I may answer for Brian here.  D1 & D2 are protection diodes. They stop the node from going above or below the supply rails. Same as built in to most IC's.

Amanda

Rover

  • Hero Member
  • *****
  • Posts: 788
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #20 on: January 17, 2011, 04:13:05 PM »
SParWeb, might have been a week ot 2 on the amplocs.

They give you tracking or anytihing?

Last time I had to email for something they were pretty responsive.
Rover
<Where did I bury that microcontroller?>

BrianSmith

  • Jr. Member
  • **
  • Posts: 94
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #21 on: January 17, 2011, 10:48:04 PM »
Yes, the diodes are just there to protect the input to the processor.  They keep the input voltage within a diode drop of either GND or VCC and are tougher and lower voltage if you go schottky than whats inside the IC.

As far as the INA270 - INA271 - they run off of 2.7V - 18V.  They are made for unidirectional current measurement, so they need to be between the rectifier and the battery.  Fixed gains of 14 or 20 depending on the model, and have provisions for filtering if you want to average out the generator AC portion of the rectified current.

SparWeb

  • Global Moderator
  • Super Hero Member Plus
  • *****
  • Posts: 5452
  • Country: ca
    • Wind Turbine Project Field Notes
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #22 on: January 18, 2011, 04:45:08 PM »
No worries from Amploc.  It arrived today.  Yes a bit later than I expected, but the shipping time they write on the website is probably "USA-only", so I ned to learn to be more patient.

Now I have two competing possibilities.  I think I can sneak them both into my current (no pun intended) datalogger, meaning I can try them both out at the same time, at the expense of one or the other input channels.  And then compare...

Lots to think about and try, thanks again all!
No one believes the theory except the one who developed it. Everyone believes the experiment except the one who ran it.
System spec: 135w BP multicrystalline panels, Xantrex C40, DIY 10ft (3m) diameter wind turbine, Tri-Star TS60, 800AH x 24V AGM Battery, Xantrex SW4024
www.sparweb.ca

Tight Yorky

  • Newbie
  • *
  • Posts: 15
  • Country: gb
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #23 on: January 21, 2011, 08:43:17 AM »
Hi Sparweb,

Good to hear you got your delivery.
I, for one, would be very interested to hear about your progress with these Amploc devices. I have never used any thing like this before. Normally a CT or a shunt resistor.
Hope your experimenting goes well.

Regards. Clive.

SparWeb

  • Global Moderator
  • Super Hero Member Plus
  • *****
  • Posts: 5452
  • Country: ca
    • Wind Turbine Project Field Notes
Re: Measuring Current in a Datalogger - shunts and amplifiers etc.
« Reply #24 on: January 21, 2011, 10:41:02 AM »
Me too, I'm eager to get at it, but VERY busy so I hope you don't mind waiting a bit.  In the middle of building a few other RE "black boxes" and hoping to have them working before experimenting wiht the datalogger again.
No one believes the theory except the one who developed it. Everyone believes the experiment except the one who ran it.
System spec: 135w BP multicrystalline panels, Xantrex C40, DIY 10ft (3m) diameter wind turbine, Tri-Star TS60, 800AH x 24V AGM Battery, Xantrex SW4024
www.sparweb.ca