Go Down

Topic: Protecting Arduino inputs from external inputs (Read 8607 times) previous topic - next topic

MalcolmV8

I have some projects, usually automotive, where I'm monitoring a 0-5 volt input from a car.  Like say the TPS (throttle position sensor) or the MAF (mass air flow sensor) etc.  It works great and puts no load on the car's sensors so as to not alter the signal the car's ECU is getting.
However I'm wanting to build in some protection in case of an accidental miss-wiring under the hood such as accidentally connecting to a 12 volt source.  My thought was to use a 5.1 volt zener diode on the input at the arduino.  If my understanding is correct it'll have no current draw and place no load on the various 0-5 sources under the hood that I monitor.  However if I make a mistake and hook it to a 12 source the zener diode will then shunt the extra voltage and save the arduino from frying at that moment.  While that is happening I don't care that there is now a load on the circuit as it's incorrectly wired at that moment.

Does that sound right to you guys?  Or should I be going about this a different way?

Thanks
Malcolm

Paul__B

What you need to be looking at, is resistors in series with the inputs.  If the resistors are large enough (say, 47k,) the internal input diodes in the Arduino will look after it just fine.

On the other hand, you are talking about analog inputs, and I am not sure what their internal impedance is in that mode (it is of course, tens or hundreds of megohms as digital inputs) - perhaps you should research that?  I believe however that this is only of importance during the A-D conversion, so putting a capacitor on the input after the resistor would stabilise the voltage during that conversion - and in addition, filter noise.

The obvious alternative is to use something like an LM324 (quad) op- amp as both an impedance buffer and a scaling amplifier, operating from the Vcc of the Arduino.

(I am getting déjà vu here - I seem to recall giving the same answer - on another board - many years ago!)

Tobbera

Hi!

Could you please explain how you monitor these sensors without altering the signal the car's ECU is getting?

Regards
Tobias


[...] I'm monitoring a 0-5 volt input from a car.  Like say the TPS (throttle position sensor) or the MAF (mass air flow sensor) etc.  It works great and puts no load on the car's sensors so as to not alter the signal the car's ECU is getting.[...]
Thanks
Malcolm
I sell on Tindie
https://www.tindie.com/stores/Tobbera/

MalcolmV8


What you need to be looking at, is resistors in series with the inputs.  If the resistors are large enough (say, 47k,) the internal input diodes in the Arduino will look after it just fine.


I'm not sure how that would help me?  The current flow is so tiny it's neglagent and I don't see there been a voltage drop across the resister to protect me against the 12 volts?  Or am I misunderstanding?  If there is indeed a voltage drop then isn't that going to affect my 0-5 monitoring in normal circumstances?


On the other hand, you are talking about analog inputs, and I am not sure what their internal impedance is in that mode (it is of course, tens or hundreds of megohms as digital inputs) - perhaps you should research that?  I believe however that this is only of importance during the A-D conversion, so putting a capacitor on the input after the resistor would stabilise the voltage during that conversion - and in addition, filter noise.


I haven't had much problems with noise.  A small amount in certain circumstances but I addressed that in the coding logic of how I work with those inputs so it hasn't been an issue.


The obvious alternative is to use something like an LM324 (quad) op- amp as both an impedance buffer and a scaling amplifier, operating from the Vcc of the Arduino.


I know of LM324 but not really how to use it.  Impedance buffer sounds useful but not sure I'd need a scaling amplifier?  The 0-5 volt output from the car is perfect for what I need.  How does this address my over voltage situation at the input of the arduino?

So was there anything wrong with my 5.1 volt zener diode solution?  It sounds like it would work perfectly to me.


(I am getting déjà vu here - I seem to recall giving the same answer - on another board - many years ago!)


Probably another car guy out there.  I'm new to Arduino so still figuring this stuff out.  Thanks for your help.

shooter

the zener is fine,you will need a resistor before the zener to protect it,like 47kiloohm
paul deelen
shooter@home.nl
making controls with codesys PLC and arduino

dc42


I'm not sure how that would help me?  The current flow is so tiny it's neglagent and I don't see there been a voltage drop across the resister to protect me against the 12 volts?  Or am I misunderstanding?  If there is indeed a voltage drop then isn't that going to affect my 0-5 monitoring in normal circumstances?


The point is that the microcontroller in the Arduino microcontroller already has 2 diodes connected to each pin, one to protect it against negative voltages, the other to protect it against voltages greater than Vcc (i.e. greater than +5V). The limitation is that these diodes are only good for about 2mA at most. By connecting a 47K resistor between your sensor and the input, you ensure that the sensor output would have to reach nearly 100V before that 2mA is exceeded.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Paul__B


I'm not sure how that would help me?  The current flow is so tiny it's neglagent and I don't see there been a voltage drop across the resister to protect me against the 12 volts?

And that is the point.  Under normal circumstances, the impedance of the Arduino input is so high that there will be negligible current flow in the 47k resistor and negligible voltage drop.  There are however, internal diodes in the Arduino that prevent the voltage from exceeding Vcc or going below ground by conducting current to Vcc or ground respectively.  When your input voltage goes outside these limits, there will be a voltage across the 47k resistor, but at for example, 12 volts, there will then be 5V on the input and 7V across the resistor.   That current will be limited by the resistor to 150 microamps and this should not be a problem for the Arduino.  It is very doubtful that there is any advantage to adding a 5.1V Zener.


I know of LM324 but not really how to use it.  Impedance buffer sounds useful but not sure I'd need a scaling amplifier?  The 0-5 volt output from the car is perfect for what I need.  How does this address my over voltage situation at the input of the Arduino?


If you do not need scaling, then you just connect your input voltage through a 47k resistor to the "+" or non-inverting input of one op-amp and the output - which of course goes to the Arduino - through another 47k resistor to the "-" or inverting input.  As the LM324 is running from the same 5V as the Arduino, its output cannot exceed that.  There is a problem however - the LM324 cannot drive its output to the full supply voltage anyway, so you probably need something like a LMC6482 or LMC6484.

MalcolmV8



The point is that the microcontroller in the Arduino microcontroller already has 2 diodes connected to each pin, one to protect it against negative voltages, the other to protect it against voltages greater than Vcc (i.e. greater than +5V). The limitation is that these diodes are only good for about 2mA at most. By connecting a 47K resistor between your sensor and the input, you ensure that the sensor output would have to reach nearly 100V before that 2mA is exceeded.


OK so I drew out what I think we're talking about here.  The diagram on the left is all you're saying I need to do?  Simply place a 47K resistor in line of the input like that and I'm protected?  And this does not affect the 0 - 5 volts I'm reading?  The Arduino is still going to see the same voltage as before?

Now if I was to add the zener (which it sounds like you guys are saying is not required at all) it would be added like the diagram on top right or bottom right?  I'm thinking top right.


Paul__B


OK so I drew out what I think we're talking about here.  The diagram on the left is all you're saying I need to do?  Simply place a 47K resistor in line of the input like that and I'm protected?  And this does not affect the 0 - 5 volts I'm reading?  The Arduino is still going to see the same voltage as before?

Pretty much.  Each input.


Now if I was to add the Zener (which it sounds like you guys are saying is not required at all) it would be added like the diagram on top right or bottom right?  I'm thinking top right.

Indeed.  The resistor prevents too much current getting through to the Arduino either way, whereas your "bottom right" wiring would provide no protection whatsoever.  The Zener is merely supplementing - by paralleling - the two diodes already in the Arduino.

MalcolmV8

Thanks.  I'll do some bench testing tonight.  I won't test much over 13.5 ~ 14 volts but as long as that doesn't fry my arduino I'll be happy :)

MalcolmV8

Well I did some testing.  I put the 47K resistor in line of my input A0.  The measured counts were very minimally affected.  About 1 ~ 2 counts so that's good.

Now for testing the over voltage condition.  I know you guys said it would protect up to 100 volts but I wasn't going to chance that.  My lead acid battery was measuring around 13.2 volts so I used that.  I used my DVM to measure the actual voltage at the Arduino pin and it was 5.9 volts.  The Arduino still works and does not appear to have received any damage but isn't 5.9 volts a bit high?  Although when I measured the voltage on the 5+ volt pin of the arduino I see 5.25 volts there.

It makes me wonder if I do indeed need that 5.1 zener diode there as well to protect the input?  Or am I just been over paranoid?

Paul__B

5.9 volts is 0.65V over 5.25V, 0.65V being the voltage drop of a silicon diode - which is what is, internal to the chip, limiting the voltage.  That is precisely what you would expect.

The point is that the current which is feeding that diode is negligible,  It is not going to heat any part inside the chip, and 5.9 volts is not going to break down any insulation.

Coding Badly


Given the cost of replacing an engine controller, shouldn't you be more concerned about protecting the other side from a wiring mistake?

MalcolmV8


5.9 volts is 0.65V over 5.25V, 0.65V being the voltage drop of a silicon diode - which is what is, internal to the chip, limiting the voltage.  That is precisely what you would expect.

The point is that the current which is feeding that diode is negligible,  It is not going to heat any part inside the chip, and 5.9 volts is not going to break down any insulation.



That's great news.  Thanks.  So I'm all good.

MalcolmV8



Given the cost of replacing an engine controller, shouldn't you be more concerned about protecting the other side from a wiring mistake?



I'm not sure I follow.  I'm not applying voltage to the car's ECU.  I'm only monitoring some outputs.

Go Up