Best way to read 0-14V signal with mbed

30 Sep 2011

Hi All,

Anyone set up the mbed to read a voltage source 0-14V and convert it to a 1-100% signal measurement? I want to do it the simplest way possible... Voltage divider , External IC... etc...

I suspect the analog in pin would be used in the end?

Thanks

Tim

01 Oct 2011

Timothy,

For the simplest way check here http://www.electronics2000.co.uk/calc/potential-divider-calculator.php try r1 = 470 ohms and r2 = 120 ohms, that should give you 2.8V FS which is 1/5th of 14v which you can scale in software. Not knowing your 14v supply current you may need 10* those values. One other point, measure across r2 to make sure the voltage is correct before conecting to your analog input pin, you could also replace r2 with a pot, so maybe r1 = 4700 ohms and variable resistor 2200 ohms then you can trim. To get closer to 2.8v or whatever voltage you prefer.

Edit: Check the mbed manual to see the parameters for the analog pin.

Good Luck,

Dave.

08 Nov 2011

David, Thank You... This is what I was thinking also. But you have validated my thoughts. Cheers! Tim

09 Nov 2011

Just a word of caution. 23mA will flow through the above values.

Personal I would recommend 4K7, and 1K2, with 10 to 100 nf across the bottom resistor.

Hope this is helpful.

Ceri

09 Nov 2011

I glanced at the data sheet, and offer a couple of points:

there is a note that when in ADC mode, the analog inputs are not 5v tolerant, so be sure your divider does not permit the voltage on the ADC pin to exceed 3.3v at the extreme. [Elsewhere there is a max voltage spec that is higher, but it is safer to limit it as noted]

You mention 14v, which is common in automotive. If this happens to be your environment, be aware there can also exist very high voltage spikes. Some additional protection may be warranted if that is your environment, possibly including this transient and reverse voltage protection.

09 Nov 2011

You could connect a 3.3 V zenerdiode across the bottom divider resistor and/or increase the values of the divider resistors by another factor of 10 (47k and 12k) which will reduce the surges during spikes even more. Or use a more modern variety of surge protection:

http://www.littelfuse.com/data/en/Data_Sheets/Littelfuse_TVS_Diode_Array_SPA_SP03-3_3.pdf

These respond within nanoseconds to voltage spikes.

09 Nov 2011

a 3.3 volt zenner will affect the top end of your voltage range,

if you look at my traces:

Green is Vin -12 to 45 volts, Red is simple divider, Teal 4.7 volt zenner (note rounding on top 10 - 15% of range) also can go -0.7 negative. Blue improved protection circuit, with sharp clipping > 3.3 Volts.

/media/uploads/ceri/diode_protection.jpg

You could achive the 2.8 Volts with a 2.8 Volt Zenner, powerd from 5V rail.

Hope this is usefull

Ceri

09 Nov 2011

Thank you all for your response. This is for an automotive application so the warning about power spikes is valid. Based on all of your input I will use a 4K7 and 1K2 as the divider. Adding a 2.8V Zenner should provide the approprate protection to the mbed.

Is it possibe that leakge through the zenner will impact the dividers accuracy?

Tim

09 Nov 2011

In a (non mbed) automotive application I set the high end at 16 Volts instead of 14, most modern cars have their alternator running at 14.4 Volts nowadays and although my '72 Beetle's alternator is set for 13.8 Volts I like to have a bit of headroom :-) And talking about spikes: try filtering the noise of an old ignition system (with breaker points) or the mechanical regulator (which I replaced by an adjustable solid state version)...

09 Nov 2011

Please note, the 2.8 zenner, is for a rail, the excess Volts to be absorbed ,

Not as the clamp! Look at circuit.

Ceri

09 Nov 2011

Hi Ceri,

Yes I understand what you are saying... the 2.8 zenner would connect downstream of R1, upstream of R2, and go to ground. That way it would dump any excess voltage greater then 2.8V from the V divider.

Tim

09 Nov 2011

Timothy,

A lot of activity all good stuff. You may want to lookup a divice called a transorb in a bid to protect your mbed in an automobile environment, a quick google should do the trick.

Ceri,

You are partially correct, when the voltage reaches the zenner diode turn on point it can be said that the voltage is being clamped, but only in that condition. Second point the voltage is not absorbed in a physical sense, the zenner diode when turned on is conducting, but if too much current flows it will get hot, then the air around it will absorb some of the heat. Just another form of energy.

Dave.

09 Nov 2011

Dave, I plugged in transorb into google and the first 25 hits were related to transorbital lobotomy... I'm like.. "Wow, this is a tough crowd!" LOL Just kidding... I did find the device you referred to. Always leaning... Thanks for the lead. Oh, As far as the mbed itself... It is being powered from a 6V power supply from the car designed to run sensors... So I'm pretty confident that voltage source is smooth... Even the mbed is running cool. Tim

10 Nov 2011

Timothy,

I like your sense of humour. It wasnt just the mbed power source, given the above comments you are plugging an adc pin into a vehicals electrical power supply via a few passive components. Under a fault condition and you choose to use a zenner diode make sure it can dissipate maybe a watt or 2 and use a fast fuse as indicated above.

Dave.

10 Nov 2011

OK.. What the heck... I dummy up a quick circuit on my breadboard. Make a V divider where R1 = 4K7 and R2 = 1K... I adjust my power supply voltage to R1 so that I have exactly 2V in between R1 & R2. I then add a 2.4V Zener NTE-5000A on the outlet of R1 to ground. I retest the voltage in the divider expecting to still see 2V... But it had dropped to 1.5V? Why is the Zener passing current before it sees 2.4V?

10 Nov 2011

It is depending on several manufacturing characteristics but a zener is not a absolute reference

http://www.electronics-tutorials.ws/diode/diode_7.html

17 Nov 2011

David Fletcher,

Is this a good IC for the protection we spoke about?

http://www.vishay.com/docs/88940/88940.pdf

Do you know of any through hole TSV diodes that will protect a 3.3V max?

Tim

23 Nov 2011

Tim,

Sorry for the delay in comming back I have had my head firmly stuck around an stm32f100, stm32f103 and the new M4 stm32f407.

I think your best way forward would to be to consider the vehical supply as your prime focus, so this is where you would need to place your filter or Transzorb, as your ADC pin will see only a ratio of the applied vehical supply. Using a 3.3v zenner or transzorb on the ADC pin (maybe a bit of an overkill) will then only protect against a catastrophic failure which should not happen if a fast low amp fuse is fitted on the vehical supply side and using a suitable transzorb (14v) or voltage/current limmit device. Keep in mind if the supply voltage is greater than 13.8v then it is indicating a charge fault or maybe an incorrect battery has been fitted (24v)this also applies if you are reading 100% ie 2.8v or 3.3v on the ADC pin.

The prime source of all problems will be the vehical supply.(With the exception of actualy reading the ADC pin.)

Dave

23 Nov 2011

No problem David, I appreciate your response... Here's the challenges I've been having.

I tried to put a 3.3V zener on the voltage divider but I found it would leak enough current that it messed up the operation of the V divider. After some research I read that low voltage zeners have significant leakage.

Then I went looking for a Transorb and most everything i read says they are not well suited for logic level voltages. I could find no example of Transorb being used as logic level protection.

I ended up doing something odd... I placed an LED between the 3.3V zener and ground. The added resistance provided by the led to the back side of the zenner causes it to hold and allow my V divider to work properly. When voltage at the divider did exceed 3.3 volts it does open. The led does not light as there is not enough current. But it does pass the current overflow from the zener...

I cranked my signal power all the way up to 40V and the voltage in the divider never went over 3.5V... And down in normal 12-14V signal range the divider is working as expected giving me 2.8V at a 14V signal...

I was reading elsewhere to do the following to protect an adc pin... Set up your V-divider and simply place a 150K resistor from the divider to the ADC pin. The author says that although the divider voltage could go well above the pin limit, that the current would never be enough to hurt the pin because of the 150K resistor...

I do not know enough about what really would hurt the adc pin on the mbed... Whether it's just any high voltage or an ecessive current of anything > X?...

If I could protect the adc pin with the 150K resistor that is what I would choose over what I'm doing now.

Tim

--

24 Nov 2011

Tim,

The LCP1768 is 5v tolerant on most of its pins, and depends on the chosen function a pin will only tolerate 3.3v. So no matter how well meaning the author is it is always best to stay with the spec.

Its good that you have found one of the problems with zenner diodes the next is just as bad. Zenner diodes have always been known for noise in fact they are or were used when correctly biased, in white noise generators. You seem to have something up and running so leave that part of the circuit for now. Check my last comments about the incoming vehical supply and using some form of filter or maybe a transzorb around 14 volts.

Forget the 3.3v Transzorb, dont worry about the current on the ADC pin, your divider is current limiting, current will only flow where there is a path so dont apply a high voltage and create one.

24 Nov 2011

Tim,

I did a quick google and the first one I looked at is this link http://linuxcar.sone.jp/reg.en.html

Take a look at the circuit, the front end upto the regulator, to see what is required for a filter and have a good read of the text. You dont need the regulator.

Dave.

24 Nov 2011

Tim,

Just to sum up the filter components from the link above.

BNX002-01 DC filter. I dont know if this component has stripboard pin space.

150uH inductor. (This is 150 micro-Henrys)

DO-15 TVS (Transient suppressor diode) the DO-15 is the thro-hole type.

You may also need the electrolytic capacitor.

Google the above parts they can all be found in the uk.

Dave.

24 Nov 2011

Thanks for all your help Dave. Much appeciated.

Have a great day friend...

Tim