Scaling a 0-15V analog signal for max resolution

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Scaling a 0-15V analog signal for max resolution

Postby MartOn » Mon May 14, 2012 10:17 am

Hello
I am going to monitor multiple 12V batteries. These operates from 10.7V to 15V depending on their state.
I have a design now using voltage divider: Batt+->Diode->10k->Ain->5k->Gnd (diode for isolation).
I also have a 5.6V Zener diode from Ain->Gnd and a Cap from Ain->Gnd to handle voltagePeaks/transients. (Measures 5.5V at 30V)

This seems to work in Lab now, but I have a few questions:
1. Will this drain batteries when Arduino is off? (Should make a powerswitch to gnd to make sure it does not drain?)
2. How large Resistors can I use and still get useful data? (Distance from Arduino to Battery will vary from 1M to 10M, but I plan to calibrate each cable to compencate)
2. What Cap would you recommend using and why? (100pF is what I use now)
3. Is there a possibility (with an OpAmp) or something to move the 0 point from 0V to e.g. 9V? (I do not need measuring 0-9V and this is 60% of the ADC scale on the Arduino. I would rather measure 9-15V on the Ain.

Any feedback is welcome.
Thanks
/Frode
MartOn
 
Posts: 20
Joined: Wed Apr 27, 2011 5:33 am

Re: Scaling a 0-15V analog signal for max resolution

Postby john444 » Mon May 14, 2012 1:24 pm

Hi Frode,

MartOn wrote:Will this drain batteries when Arduino is off?

1 Yes.
MartOn wrote:Should make a powerswitch to gnd to make sure it does not drain?

You may not need a switch if you use large value voltage dividing resistors. Depends on how much drain current you can afford. 15-K is a 1-mA load. Not very much for big Lead-Acid batts. 1.5-M is 0.01-mA.

MartOn wrote:How large Resistors can I use and still get useful data

2a Depends. If you are going to measure fairly slowly (as I suspect) then, consider 1-M & 500K.
Otherwise you may need a 1-k source resistance. No need to “calibrate” the cable.
Cable resistance will be much smaller than the resolution of your measurements

MartOn wrote:What Cap would you recommend using and why

2b A 100-pF would be good to reduce noise with a 1-K source resistance.
Place this cap near the Arduino not at the other end of the cable.
Also consider protecting the A/D input with diodes to the 5-V & Gnd rails.
With 1-M source resistance use a .1-uF. This value is needed to provide a low impedance for the A/D if using high value resistors.

MartOn wrote:Is there a possibility (with an OpAmp) or something to move the 0 point from 0V to e.g. 9V?

3 I interpret this question to mean you wish to ignore voltages below 9-volt.
A 9-v zener will take care of this. No need for an op-amp.

Using your current circuit as an example:
You should see 0-v across the 5-k until the batt voltage exceeds 5.6-V (+/- the zener tolerance)
Substitute a 9-V zener for the 5.6-V and you will have what you are asking for.
A 10-V zener will give you 10-15-V for a 5-V change which is more in line with the Arduino’s A/D.

Regular zeners will not propvide 1 part in 1,000 precision. Although, they may be sufficient for your application.
Good luck, John
john444
 
Posts: 407
Joined: Sun Mar 04, 2012 1:42 pm
Location: Claremore, Ok

Re: Scaling a 0-15V analog signal for max resolution

Postby philba » Mon May 14, 2012 2:35 pm

15K ohms means you will have a continuous drain of 15K/12 or 1.25 mA. It's up to you if that's reasonable. If it isn't you can increase the resistors and use an op amp set up as a voltage follower to decrease the impedance. Or, you could set an op amp up as a differential amp to essentially translate the 9-15V range down to 0-Vcc and thus give you more accuracy in the range that is important to you. The advantage of the op amp is you can have significantly lower drain.
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 5:59 pm

Re: Scaling a 0-15V analog signal for max resolution

Postby MartOn » Mon May 14, 2012 4:59 pm

Thanks for you feedback.
john444: I made a circuit based on your tips with a 7.1V Zener and the readings are quite accurate from 10-15V.
I had to change the Voltage divider to 10k->24k. so it divides 0-7V to 0-5V, which makes the current very low.

The current measured at 13V is approx 0.147mA. Is this too small?
Will the signal be very sensitive to noise if I have so low currents?

Also I am wondering is if the Diode protection actually will work. The diodes I use are 1N4148 and they have a forward voltage of 0.61V, so the Analog in goes to max 5.6V before the diode "opens".
Are there any other diodes that work better for protection that may have a lower forward voltage?
I will post my schematic once I have tested some more.

/Frode
MartOn
 
Posts: 20
Joined: Wed Apr 27, 2011 5:33 am

Re: Scaling a 0-15V analog signal for max resolution

Postby john444 » Mon May 14, 2012 9:50 pm

Frode,

I am glad it is working for you.
MartOn wrote:The current measured at 13V is approx 0.147mA. Is this too small?

That low a current may be less than the Arduino would like for reliable & consistent readings.
Your alternatives are -
1 .Use an op-amp, like Philba offered. It adds another part but you gain more control and can take readings as fast as you like.
2 .Use a large cap (0.1-uF) on the A/D input terminals and only take a reading every second or so. At least 3*RC, 10*RC is better.
This only works because your voltage is not changing very quickly and you are not taking readings quickly.

MartOn wrote:Will the signal be very sensitive to noise if I have so low currents?

Not if you use the op-amp or the large cap.

MartOn wrote:Also I am wondering is if the Diode protection actually will work.

1N4148 diodes will definitely work. I usually use 1N4004's only because at one time I bought a lot of them.
The idea is to prevent more than a diode drop greater than the + supply or below GND.
I strongly recommend this kind of input protections. Bad things can happen if that occurs even momentarily.
(Extensive personal experience. One would think that I would learn after it happens more than a couple of times)

MartOn wrote:Are there any other diodes that work better for protection that may have a lower forward voltage?

A Schottky will get you to about ½-V compared to about ¾-V for the 1N4148/1N4000.
Use Schottky if you have them, otherwise use your 1N4148s. It is not worth going to extra effort for the ¼-V.

MartOn wrote:I will post my schematic once I have tested some more.

Great. Others are probably interested also.

John
john444
 
Posts: 407
Joined: Sun Mar 04, 2012 1:42 pm
Location: Claremore, Ok

Re: Scaling a 0-15V analog signal for max resolution

Postby john444 » Mon May 14, 2012 10:28 pm

Frode,

I was looking at some of your numbers and they did not look correct.
MartOn wrote:The current measured at 13V is approx 0.147mA. Is this too small?

13-V (source voltage) minus 7.1-V (zener voltage) = 5.9-V. 5.9-V / 24-K = 0.246-mA.
However, if you used the current range on a digital multi-meter it will have added significant resistance to the circuit.
Instead, use a voltage range on the multi-meter to measure the voltage drop across the resistors and calculate current.

MartOn wrote:the readings are quite accurate from 10-15V.

Yes, they should be. Although, it will not be very linear just above or below the zener voltage.
The transition is not very sharp especially for low voltage zerners. It is referred to as having a 'soft knee'.
You might also consider blue or white LEDs. Series a couple of them to get near 10-V.
They will have a sharper turn-on voltage compared to the zeners.

John
john444
 
Posts: 407
Joined: Sun Mar 04, 2012 1:42 pm
Location: Claremore, Ok

Re: Scaling a 0-15V analog signal for max resolution

Postby MartOn » Tue May 15, 2012 6:08 am

I would prefer to keep my circuit as simple as possible, so I will try with smaller resistors on the voltage divider before I go for the OpAmp solution. to get the current up.

But, then again I will make a OpAmp version also to compare. Especially monitoring my thrusters, I would like to have "fast readings". It is interesting to see the voltagedrop in my cables (From battery to Thruster) when by 10hp bow-thruster boosts off :)

My initial intent, was to also Opto isolate the inputs, to make sure I have proper isolation, but this seems to be very complex, since OptoCouplers are better for digital signals. I have a theory to use a voltage to frequency converter -> Optocoupler -> Freq(in), but the datasheet alone on the V2F chip, made me realize.. Keep it simple, there is plenty of time to make the circuit more complex :D

Thanks alot for great input.

/Frode
MartOn
 
Posts: 20
Joined: Wed Apr 27, 2011 5:33 am

Re: Scaling a 0-15V analog signal for max resolution

Postby MartOn » Tue May 15, 2012 7:28 am

philba wrote:15K ohms means you will have a continuous drain of 15K/12 or 1.25 mA. It's up to you if that's reasonable. If it isn't you can increase the resistors and use an op amp set up as a voltage follower to decrease the impedance. Or, you could set an op amp up as a differential amp to essentially translate the 9-15V range down to 0-Vcc and thus give you more accuracy in the range that is important to you. The advantage of the op amp is you can have significantly lower drain.


I need some assistance with the OpAmp design. I now little about OpAmps. Can someone give an example of a differential amp that will basically translate 9-15V to 0-5V.
Remember that the only "constant" voltage I have is 5V, the battery voltage will vary.

/Frode
MartOn
 
Posts: 20
Joined: Wed Apr 27, 2011 5:33 am

Re: Scaling a 0-15V analog signal for max resolution

Postby philba » Tue May 15, 2012 9:52 am

Here's a simple circuit with calculations.
Image
Image
http://en.wikipedia.org/wiki/Operational_amplifier_applications#Differential_amplifier

As to "constant voltage", I believe that you will be fine as long as the voltage powering the op amp is above max Vout. If you use 5V, you might not see exactly 5V out but you can pick resistors that map 15V into 4.5 or what ever the max possible is. Pick a Vref for the V1 input - zener or adjustable Vref like the tl431
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 5:59 pm

Re: Scaling a 0-15V analog signal for max resolution

Postby MartOn » Tue May 15, 2012 10:17 am

philba wrote:Here's a simple circuit with calculations.
Image
Image
http://en.wikipedia.org/wiki/Operational_amplifier_applications#Differential_amplifier

As to "constant voltage", I believe that you will be fine as long as the voltage powering the op amp is above max Vout. If you use 5V, you might not see exactly 5V out but you can pick resistors that map 15V into 4.5 or what ever the max possible is. Pick a Vref for the V1 input - zener or adjustable Vref like the tl431


I do not understand this. If I use a voltage divider on the reference, the reference will also vary depending on the voltage on the battery. I thought Vref must be constant into the opAmp for the hole range from 10-15V. I also need to scale down, meaning the OpAmp must deamplify the voltage. 15V in should be 5V (or 0V) out and 10V should be 0V (or 5V). The Amplification should be basically 1 (or just below) and it should not amplify until voltage is over 10V (so I can keep the resolution of the ADC to a maximum).

/Frode  
MartOn
 
Posts: 20
Joined: Wed Apr 27, 2011 5:33 am

Re: Scaling a 0-15V analog signal for max resolution

Postby philba » Tue May 15, 2012 10:32 am

that why I suggested the V1 input (reference) be from a zener or voltage ref. You will need to pick resistors that give you what you want but it is possible. I set up a spreadsheet for the formula. With r1 = 20K, r2 = 14K, rf = 20k and rg = 12k. V1 = 9V and V2 varied from 9 to 15V, the mapping is pretty close. 9V is 0 (-.69 clipped) and 15V is 4.85. Further tweaking will get you exactly what you want. Mind you these are theoretical and you will need to play with a real op amp.

clipping is due to the negative voltage on the op amp being 0.

There is a nice little calculator here http://www.bcae1.com/opamp.htm scroll about 2/3 down.
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 5:59 pm

Re: Scaling a 0-15V analog signal for max resolution

Postby MartOn » Tue May 15, 2012 1:19 pm

Thanks for prompt and good answers. A lot faster to ask questions here, than searching on Google :D

There are however a few loose ends in my OpAmp version of this circuit still :)

  • I probably need to limit the out current of the OpAmp before it goes into the Analog In on the Arduino?
  • Do I need the Diode protectors on the analog in when using opAmp powered with 5V? I guess it is not nessecary?
  • In my original VoltageReference version of the circuit, I also had a Diode (first) as a protection for current leakage, I guess this is not necessary either?
  • The Cap for transients, I guess I can keep? Should I make it smaller so I can increase sample rate?
/Frode
MartOn
 
Posts: 20
Joined: Wed Apr 27, 2011 5:33 am

Re: Scaling a 0-15V analog signal for max resolution

Postby philba » Tue May 15, 2012 2:51 pm

It wont hurt to have a series resistor between the opamp and the arduino input but it's not necessary. An AVR pin set to input won't pull much current at all.

It turns out you can't power the opamp from 5V unless you divide the inputs down to <5V. sorry for not being clear. Use a rail-to-rail opamp if you absolutely need the full 0 .. Vcc swing.

Not sure I understand what the diode was doing.

cap for transient? maybe, probably wouldn't hurt.

So, yes, if you use 12-15V to power the op amp, you will want to make sure that it won't output more than Vcc. A zener would be ok.
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 5:59 pm

Re: Scaling a 0-15V analog signal for max resolution

Postby MartOn » Tue May 15, 2012 3:36 pm

philba wrote:It turns out you can't power the opamp from 5V unless you divide the inputs down to <5V. sorry for not being clear. Use a rail-to-rail opamp if you absolutely need the full 0 .. Vcc swing.


Hmm. Does this mean I can not use a OpAmp unless I use a steady 9V supply.
If I have to divide the input down to 0-5V, I am basically back to the voltage divider version I started with, making the OpAmp redundant.
/Frode
MartOn
 
Posts: 20
Joined: Wed Apr 27, 2011 5:33 am

Re: Scaling a 0-15V analog signal for max resolution

Postby philba » Wed May 16, 2012 12:01 pm

I think you can live with the source voltage changing as long as it changes slowly.

You will still have a divider no matter what you do. If you run the output of the divider directly into an ADC pin, you will have to keep the impedance (resistance in this case) below 10K. With an opamp, you can use higher values in your divider and thus reduce the battery drain while still keeping the impedance low.

Also, you wanted better resolution in the voltage range that you cared about, 9-15V. Given the title of your post, I assumed it was the most important thing to you. That is what the differential op amp config will do.
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 5:59 pm

Next

Return to General Project help

Who is online

Users browsing this forum: No registered users and 5 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]