Pages: [1] 2   Go Down
Author Topic: Current sensing: Amplifier?  (Read 2072 times)
0 Members and 1 Guest are viewing this topic.
Washington
Offline Offline
God Member
*****
Karma: 30
Posts: 780
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am looking for a way to measure DC current on a positive rail.
The current will be in the range of 0-5Amps and the more precision the better (down to 50Ma or better).
I was thinking of using a 0.02 ohm resistor which, if my calculations are correct would give me
Code:
20mV / Amp
2uV / 1mA
As you can see, these are very low voltages.

I was thinking of using a opamp in differential mode. Since I am new to OpAmps (even newer then I am to mosfets smiley-wink ) I do not really know the circuit or resistor values required would be to give me 1V / Amp reference to ground.

Also scaling the voltage 50x is quite a bit of gain. Is it possible to do this without too much noise?

Using an bigger Rsense resistor would not be an option since the maximum tolerable drop is about 150mV at 5 amps draw.

Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 44
Posts: 2811
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thats EASY just place the sense resistor before the regulator or the VR voltage feedback after the resistor. This is done to subtract the Sense Resistor voltage drop from the output voltage the other advantage of that connection is that you can use a larger value sense resistor... 10mA to 5A should be fairly easy @ 5% accuracy over the range. The prime disadvantage of pre regulator sensing is that the op-amp inputs have to be able to swing to the positive supply rail, in post regulator sensing the opamp is fed from the main supply... sometimes a small supply is generated just for the sense feedback  amplifier. Draw me a circuit and I will look at it and If I can I will try to simulate it for you. there is another thought and that is LCD ammeters are sold on Ebay. A 4 1/2 digit device (~$15.00) would be accurate to 10 ma easily. I am a GREAT fan of purchased items where ever possible falling back to construction only where the OTS item is wrong, size, range, price and availability... For a laugh go look up a MAX471/2. I think that either device will work for you. They might well be out of production but they ARE available. There are also the Allegro ACS7XX devices. I need to go get dinner but I will look when I get back. Both the Maxim and Allegro devices are bi-polar in output, the Maxim thing has I think a sign output as well... More Later

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Offline Offline
Edison Member
*
Karma: 9
Posts: 1010
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was thinking the same: there are special ic's that are designed for high-side current sensing. They are like normal OpAmps, but they are able to have a higher voltage on the inputs than their own supply voltage. They will give you an accurate value.

The analog inputs of the Arduino are 10-bits. 5A in 10-bits is 5mA resolution.

You could also use a hall current sensor.
http://www.lucadentella.it/en/2011/11/29/sensore-di-corrente-con-arduino/?utm_source=rss&utm_medium=rss&utm_campaign=sensore-di-corrente-con-arduino
But that's less accurate, and they will give false readings if placed next to magnetical field from a transformer or switching power supply or speaker.
But it's very cheap and very easy to use.
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 44
Posts: 2811
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On the allegro site you will find this part...ACS714ELCTR-05B-T it is a high side current sensor that is bi-lateral, it will sense current in both directions at 185/mV/A. This value can apparently be scaled to 100mV/A easily for simpler scaling to amperage. The output is 1/2 Vcc and for the '714 Vcc is 5V... there are 3V3 parts available but the granularity of the measurement would tend to make them less manageable for an Arduino or at least require a 12 bit A/D.
The Max471 is a sensor W/O a sense resistor and the Max472 is the same part with a 3A measuring range W/Sense resistor, both are "Not Recommended For New Designs"
(The caps are from the first page warning about being a discontinued part...) and can be purchased on Ebay for 5 - 10 dollars, maxim also makes several current sensors... I haven't yet looked for them... I did look for the ACS714... No Joy. Now it's your turn... Want to buy a LM338 Steel... 1.2 to 32 V out A 5A? linear and a great space heater... But a real Quick and Dirty 0 to 35V out supply regulator (0 V out requires a -1.2 V reference which is also not any issue to create a neg supply a TIL431 and 2 resistors. Probably better to find a Buck-Boost converter and have to live with ~80% Efficiency... @ 50 W out it would be 10W lost as heat.

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Washington
Offline Offline
God Member
*****
Karma: 30
Posts: 780
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok let me give more information.
I am trying to design from scratch a variable lab power supply with variable stabilize voltage and variable current limiting.
Using a prebuilt amperage meter is not an option because the MCU need to know the current draw and act upon it.
I am thinking of using a microcontroller driven non-isolated switching design. I know I am reinventing the wheel but no IC solutions give me the versatility that direct software control can provide. I did a breadboard test with a few BJT and the results were almost jaw dropping. Voltage was within 30mV of what it was set to, loads between 0 and 300 mA caused less then 20mV of change and transient response was acceptable and could be improved with software adjustment. There was some ripple but filtering was crude.
It even worked well at settings below 1v.

I want to scale the design up and I think something very usable could be produced and run variable voltage with ~2-3 amp output.
On the allegro site you will find this part...ACS714ELCTR-05B-T it is a high side current sensor that is bi-lateral, it will sense current in both directions at 185/mV/A. This value can apparently be scaled to 100mV/A easily for simpler scaling to amperage. The output is 1/2 Vcc and for the '714 Vcc is 5V... there are 3V3 parts available but the granularity of the measurement would tend to make them less manageable for an Arduino or at least require a 12 bit A/D.
With 185 mV / A, it seems like it would waste alot of the ADC resolution since there would be no currents over ~5A. .185 * 5 = 0.925. 0.925 is significantly less the 5v full scale of the ADC.
Quote
The Max471 is a sensor W/O a sense resistor and the Max472 is the same part with a 3A measuring range W/Sense resistor, both are "Not Recommended For New Designs"
(The caps are from the first page warning about being a discontinued part...) and can be purchased on Ebay for 5 - 10 dollars
I am not too concerned about being discontinued since I only need 1-2.
Quote
, maxim also makes several current sensors... I haven't yet looked for them... I did look for the ACS714... No Joy. Now it's your turn... Want to buy a LM338 Steel... 1.2 to 32 V out A 5A? linear and a great space heater... But a real Quick and Dirty 0 to 35V out supply regulator (0 V out requires a -1.2 V reference which is also not any issue to create a neg supply a TIL431 and 2 resistors. Probably better to find a Buck-Boost converter and have to live with ~80% Efficiency... @ 50 W out it would be 10W lost as heat.
The LM338 does not really meet the requirements I need. It would be controlled with an analog potentiometer which means its less stable and not easily controlled in software which is required for this application. Also implementing variable current limiting would be difficult. Furthermore, I need it to be to operate from 0-1.2 i.e. 1.2 is not low enough. I am going to have a switchable voltage divider on the analog input for when the voltage is greater then 5v, otherwise run it straight through for more precision on lower voltages. I will have a zener clamp on the analog inputs to protect it during the time it takes the divider to kick in. I am thinking of using one microcontroller that runs in a tight loop for regulation then using another microcontroller that monitors button presses, the rotary encoder, updates the LCD and watches current draw then sends commands to the regulator MCU. This way it does not drop regulation during handling button events etc... I plan to use first two voltage regulators, one to regulate the +18v input to +15v and another to regulate the +15 down to 5v for the MCU and other logic circuits.

I welcome your opinion.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might want to watch Dave Jones blogs about designing a lab power supply:

http://www.eevblog.com/2011/11/28/eevblog-221-lab-power-supply-design-part-1/

(more episodes follow)

He goes into a lot of detail about how he controls the voltage and current, and senses the current.
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 44
Posts: 2811
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

both of your comments about the acs thing are wrong 100mV/A would give you 10 mv/100 ma @ 4.88MV/step for a 5v reference you would have the +/- 50 ma accuracy you spec'd if the output was set to 150mV/A you would be down to about +/- 30 mA accuracy and with a 1.1V Vref you could have mA accuracy easily all of this without a scaling amplifier... and as to the LM338 Steel (TO3 Metal 5A regulator... just tie a 200 300 ohm resistor from out to adjust and connect a dc voltage from ground to the adj pin and the output voltage will be 1.25V below the Adj pin voltage. can be sensed by the arduino and regulated by the arduino  up to about 3.75 volts you would need to use a scaling amplifier as the analog write only goes to 5 V, as for the current control of either just control the voltage for a constant voltage or the voltage for a constant current, one or the other, usually the voltage feedback is used and current feedback is ignored. In CC mode Current is held constant by controlling the applied voltage.

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Offline Offline
Edison Member
*
Karma: 9
Posts: 1010
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The reference can be set to 1.1V : http://arduino.cc/it/Reference/AnalogReference

Your idea sounds very good. I would even be possible to program voltage or current ramps for testing.
Or program a certain voltage for a certain time.
Perhaps you could add a temperature sensor on the transistor or a temperature sensor inside the device.
Perhaps you could add a command interface via the serial connection and for logging.

What are your plans for a display and knobs ? A potmeter for variable voltage and buttons for digital preprogrammed voltages perhaps ?
Logged

Washington
Offline Offline
God Member
*****
Karma: 30
Posts: 780
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

both of your comments about the acs thing are wrong 100mV/A would give you 10 mv/100 ma @ 4.88MV/step for a 5v reference you would have the +/- 50 ma accuracy you spec'd if the output was set to 150mV/A you would be down to about +/- 30 mA accuracy and with a 1.1V Vref you could have mA accuracy easily all of this without a scaling amplifier...
I forgot about the 1.1V reference. This sounds like a good idea and I will probably go with it.
Quote
and as to the LM338 Steel (TO3 Metal 5A regulator... just tie a 200 300 ohm resistor from out to adjust and connect a dc voltage from ground to the adj pin and the output voltage will be 1.25V below the Adj pin voltage. can be sensed by the arduino and regulated by the arduino  up to about 3.75 volts you would need to use a scaling amplifier as the analog write only goes to 5 V, as for the current control of either just control the voltage for a constant voltage or the voltage for a constant current, one or the other, usually the voltage feedback is used and current feedback is ignored. In CC mode Current is held constant by controlling the applied voltage.

Honestly, I feel like I am still going to go with the original plan because I am looking for alot of flexibility.
I want it to operate in "hybrid" mode where it is at a set constant voltage until it exceeds the current limit, then it will scale back the output voltage until it is within the current limit.
Basically constant voltage until the current hits threshold, then constant current.

I realized the Allegro is only available in surface mount packages. I can still make it work but it will take some effort.
Bed time now...
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Washington
Offline Offline
God Member
*****
Karma: 30
Posts: 780
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The reference can be set to 1.1V : http://arduino.cc/it/Reference/AnalogReference
One issue with using the 1.1v reference is I will not only be measuring current but also voltage which will range 0-5.
I guess I will have to switch to the 5v reference before measuring voltage then back to the 1.1v reference before measuring current.
Is it safe to apply voltages over Vref? Like 5v with the 1.1v reference set?
Quote
Your idea sounds very good. I would even be possible to program voltage or current ramps for testing.
The versitility of a software controlled power supply is amazing.
Quote
Or program a certain voltage for a certain time.
I was thinking of this.
Quote
Perhaps you could add a temperature sensor on the transistor or a temperature sensor inside the device.
I was thinking about this if I could get the core circuit going (missing some parts right now).
A temperature sensor could turn on a small fan at once level and do a protection shutdown at another level.
Quote
Perhaps you could add a command interface via the serial connection and for logging.
A serial interface for logging, debugging and control could be useful and I will think about implementation.
Quote
What are your plans for a display and knobs ? A potmeter for variable voltage and buttons for digital preprogrammed voltages perhaps ?

I was thinking of a rotary encoder to set the voltage, lock button to prevent accidental changes, output enable/disable button, HD44780 LCD to display voltages and current and monitor status, programmable current limit, programmable voltage limits so you do not apply for example 9v to a 5v circuit.
Various status LEDS to indicated fault, power and output status.
Peizeo electric buzzer for button feedback and protection faults. And to build the thing into some sort of case.
This is one of the biggest electronic projects I have ever planned.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Offline Offline
Edison Member
*
Karma: 9
Posts: 1010
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice to read that we think alike.

A cheap HD44780 LCD display is rather slow. If you can read for example the current only 3 times a seconds, that might be too slow.

The analogReference can be switched from 5V to 1.1V and back. No problem.
You need to wait for about 20ms for the voltages to become stable after swithing the analog reference.
That delay is not implemented in the Arduino library, you have to use delay() in your own code.
Reading 5V with 1.1V reference is okay, but the value of analogRead() will soon be the maximum of 1023. But no harm is done.
Logged

Washington
Offline Offline
God Member
*****
Karma: 30
Posts: 780
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A cheap HD44780 LCD display is rather slow. If you can read for example the current only 3 times a seconds, that might be too slow.
3 times/s might be enough but I do not want to waste all the microcontrollers processing time updating the LCD display.
Any suggestions?
Quote
The analogReference can be switched from 5V to 1.1V and back. No problem.
You need to wait for about 20ms for the voltages to become stable after swithing the analog reference.
That delay is not implemented in the Arduino library, you have to use delay() in your own code.
20mS is a bit long for my taste but I think I can use strategic delays to get some work done during the 20mS like monitoring buttons and knobs.
Quote
Reading 5V with 1.1V reference is okay, but the value of analogRead() will soon be the maximum of 1023. But no harm is done.
This is not really a problem.

I am also thinking how to send data from one atmega to another? I2C? SPI? UART?
I need to send a 2 byte data string on occasion to the regulator atmega with updates to the regulation voltage.
BTW the bloody server ate my last post with a #500 internal server error
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 44
Posts: 2811
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah it ate mine this morning too... always with one of my "Short Missives"... I hate to type as my hands are arthritic and painful. This happens often enough that I have taken to copying messages to the clipboard from time to time... just for luck. Seems to work as the only time the crashes happen to me is with a full page of text, un-copied. Magic, I guess

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Washington
Offline Offline
God Member
*****
Karma: 30
Posts: 780
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah it ate mine this morning too... always with one of my "Short Missives"... I hate to type as my hands are arthritic and painful. This happens often enough that I have taken to copying messages to the clipboard from time to time... just for luck. Seems to work as the only time the crashes happen to me is with a full page of text, un-copied. Magic, I guess

Doc
Or Murphy's law at work smiley-wink

On another topic, what would recommend to transmit data between to MCUs?
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Offline Offline
Edison Member
*
Karma: 9
Posts: 1010
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Communicate with other ATmega, SPI I2C UART, you can use them all. SPI is the fastest and most used for this. UART is to be able to test the modules seperately with a serial terminal.

That 20ms delay is when there is an 100nF on Aref. That 100nF is according to the datasheet for best analog result. If you leave it as it is, perhaps no delay or a very small delay is okay.
Logged

Pages: [1] 2   Go Up
Jump to: