PDA

View Full Version : Maixium voltage on a input pin



Rob Martin
- 4th April 2004, 11:27
I'm playing with a pic in a car and wondered what is the most reliable method of taking 12volt inputs into a pic? Would I be best using optocouples (I have 11 x 12volt inputs) or can I just pass it though a 1k resistor as I do a the moment?

Rob

skeezicks
- 4th April 2004, 18:39
You may clamp the inputs with some 5 Volt zeners but that can get spendy. Your opto-coupler approach sounds reasonable. The problem with resistors is that they don't provide spike immunity and the pic may get damaged.

Melanie
- 5th April 2004, 12:38
Your maximum input voltage should not exceed Vdd, however a small tollerance (say 5-10%) won't harm.

See also the answer I just posted on "How to use VRef". Adjust your Resistor values accordingly so your maximum vehicular voltage (about 15v on an average modern vehicle give or take) never exceeds 5v when scaled down. A 3:1 reduction ratio would be about right.

Zeners are cheap (only a few cents) use in series with say a 10K Resistor. Don't forget to stick say a 100nF across the Zener as they're noisy devices.

You can also use a transistor as a buffer... but you're adding that and couple of Resistors so you're increasing your parts count.

Opto isolators are overkill especially if you don't need actual isolation.

Melanie

Calco
- 7th April 2004, 11:08
Hi,

Just thought I'd add my thoughts.

I have a product that fits to an automotive type end device, initially I used opto-isolators to monitor 12v inputs.
I found them to be uneccesary in the end, also they where prone to behaving differently in different pcb's for some reason..

Anyway I digress, my current production units all employ a 78L05 voltage regulator with a 100R resistor between the 5v output and the PIC's input.

This approach worked out cheaper and uses less board space than the opto-isolated version.

Hope this helps


Darryl...

Rob Martin
- 7th April 2004, 12:19
Darryl

Are you saying you use 1 x 7805 per input?
I'm looking at bringing in 8 inputs so I'd need 8 x 7805's
Is the switching time of these suitable?
I found a company that sells a 4 port opto isolator (£3) Melaine's idea of Zeners seems a good idea but increases the component count.

All ideas Welcome

Rob

Calco
- 7th April 2004, 12:29
Hi Rob,

Yes, that would be about the size of it.
the L variety are pretty small... 4 together are still smaller than a conventional 4 way opto-isolator, If you pack them neatly enough you can probably fit 5 in the space of a 4 way opto.
They are amazingly good at handling transients and spikes aswell as they can inherently operate at up to around 30volts.
They fail safe generally aswell, ie if the input voltage exceeds the limit the output generally clamps to zero (ish) thus no damage is passed onto the PIC.

It may not be suitable for your application, Its just another thought in the melting pot.

My units are fitted externally to a vehichle in all weathers and Ive had non returned as faulty to date so they are relatively robust.

I believe they have even attached them to 24v vehicles with no changes to the circuit and still they are super reliable.

Hope this helps

Regards

Darryl...

Rob Martin
- 7th April 2004, 17:12
Sorry for all the postings but Ive tried searching the list and can't find the answer.

I'm writing a word to the eeprom on a 16c648 like this

TestWrite var word
TestRead var word

TestWrite = 12345


write 0, TestWrite dig 0
write 1, TestWrite dig 1
write 2, TestWrite dig 2
write 3, TestWrite dig 3
write 4, TestWrite dig 4

This works fine


But when I want to read the bytes back in and write them is fails, I'm assuming that the command byte2 doesn't exist, so how do I do it?

Read 0, Testread.byte0
Read 1, Testread.byte1

Fails from here
Read 2, Testread.byte2
Read 3, Testread.byte3
Read 4, Testread.byte4

Rob

Calco
- 7th April 2004, 17:57
Hi Rob,

Simple one this, I can undertand your approach however it is less complicated than you are making it..

Try this.

TestWrite var word
TestRead var word

TestWrite = 12345


write 0, TestWrite.byte0
write 1, TestWrite.byte1


Read 0, Testread.byte0
Read 1, Testread.byte1

.....

Testread should now be 12345.

You dont need to seperate the value into seperate digits.
Imagine if you will the word value as its 16-bit binary number..
Byte.0 is the lower 8 bits and Byte.1 is the upper 8 bits

When you read the two values back the software cleverly adds the two values and fills the variable with the correct figure.

Hope this helps.

Regards

Darryl

Rob Martin
- 7th April 2004, 18:36
Darryl

Very well expained.

I posted this here by miskate and deleted it straight away so not sure how you come to see it unless the system was to quick for me and emailed you instantly.

I played with just using byte0 & Byte1 and got the correct answer but couldn't understand how it worked.
I did a search of the lst and could find nothing which expalined that it's recombines the values.
Likewise my PBP manual & the online version yielded very little.

Regards

Rob

jmgelba
- 7th April 2004, 20:52
The only problem i see with the use of the 7805 series voltage regulator is its min and max operating tempratures. Min of 0 deg C and max of 85 deg C is not suitable for an automotive environment. You need -40 deg C to +125 deg C.

Try a LM2937ET-5.0 or, a LM2954AIT-5.0 if you require an output voltage tolorence of 1%. You will need i/p and o/p caps with both parts or you will see near supply voltages at the output. I have used everything from 0.1uf to 330uf at the output on both parts and it always works fine. Remember to spec your input cap with a minimum of 35v.

Here is an example of what i am using on a tyre pressure control system for a semi:-

LM2954AIT-5.0
AAvid heatsink 592502B034
input cap - 220uF 50v Panasonic EEVFK21H221P
output cap - 330uF 25v Panasonic EEVFK1E331P

All available from www.digikey.com

Probably overkill but safe as houses.

Demon
- 21st April 2008, 07:13
The only problem i see with the use of the 7805 series voltage regulator is its min and max operating tempratures. Min of 0 deg C and max of 85 deg C is not suitable for an automotive environment. You need -40 deg C to +125 deg C.

Try a LM2937ET-5.0 or, a LM2954AIT-5.0 if you require an output voltage tolorence of 1%. You will need i/p and o/p caps with both parts or you will see near supply voltages at the output. I have used everything from 0.1uf to 330uf at the output on both parts and it always works fine. Remember to spec your input cap with a minimum of 35v.

Here is an example of what i am using on a tyre pressure control system for a semi:-

LM2954AIT-5.0
AAvid heatsink 592502B034
input cap - 220uF 50v Panasonic EEVFK21H221P
output cap - 330uF 25v Panasonic EEVFK1E331P

All available from www.digikey.com

Probably overkill but safe as houses.



Sadly the LM2954AIT is not longer available at DigiKey, I checked both the Canadian and US pages, even for LM2954 without success. (I just checked for the LM2937 and it is available)

Gonna search and see what else they have with automotive specs.


EDIT: It's not obvious searching for a voltage regulator for an automotive application on DigiKey, it's not part of the description. The fact that each manufacturer uses a different naming standard for the part series does not help either.

Also, using a 5V voltage regulator isn't going to help my case. I'd like to sense signals from various sensors on an old car, they are fed from the 12V battery. Even if I can lower the VREF from 12V to 5V, I won't be able to use the same technique for the signal from the sensor which can vary between 0-12V.

Archangel
- 21st April 2008, 09:09
The only problem i see with the use of the 7805 series voltage regulator is its min and max operating tempratures. Min of 0 deg C and max of 85 deg C is not suitable for an automotive environment. You need -40 deg C to +125 deg C.

Try a LM2937ET-5.0 or, a LM2954AIT-5.0 if you require an output voltage tolorence of 1%. You will need i/p and o/p caps with both parts or you will see near supply voltages at the output. I have used everything from 0.1uf to 330uf at the output on both parts and it always works fine. Remember to spec your input cap with a minimum of 35v.

Here is an example of what i am using on a tyre pressure control system for a semi:-

LM2954AIT-5.0
AAvid heatsink 592502B034
input cap - 220uF 50v Panasonic EEVFK21H221P
output cap - 330uF 25v Panasonic EEVFK1E331P

All available from www.digikey.com

Probably overkill but safe as houses.
L78L05AB -40 to 125 C.
http://www.alldatasheet.com/datasheet-pdf/pdf/STMICROELECTRONICS/78L05.html

Acetronics2
- 21st April 2008, 09:59
Hi,

There's the other way ...

use what's inside the Pic ... the clamp diodes !!! just use a series resistor to limit input current to 10-20µA ( 500µA max continuous ... )

see AN521c for direct mains ( ! ) to Pic interfacing. That's OFFICIAL !

and if you want ... add 2x 1N4148 diodes parallelled to the clamping diodes !!!

no need regulators or complex circuitry !!!

Alain

Demon
- 21st April 2008, 10:21
Hi,

There's the other way ...

use what's inside the Pic ... the clamp diodes !!! just use a series resistor to limit input current to 10-20µA ( 500µA max continuous ... )

see AN521c for direct mains ( ! ) to Pic interfacing. That's OFFICIAL !

and if you want ... add 2x 1N4148 diodes parallelled to the clamping diodes !!!

no need regulators or complex circuitry !!!

Alain



Merci Alain.

Ok:

- 2 parallel 5M resistors on the input pin (AN521 suggested a backup just in case).
- a pair of backup diodes on the input pin as well.

And now the noob question, the PIC will be powered by a 5V circuit, the signal from the sensor is powered on a 12V circuit, where do the backup diodes go to? The 12V cicuit or the 5V circuit?

The clamping diodes within the PIC go the the 5V circuit, I would assume the backup would go to the same place, just want to be sure.

This would greatly simplify my life 'cause it gets real complicated real quick trying to use op amps like the LM239, I got that idea from another tutorial.

Acetronics2
- 21st April 2008, 10:34
Merci Alain.

Ok:

- 2 parallel 5M resistors on the input pin (AN521 suggested a backup just in case).
- a pair of backup diodes on the input pin as well.

And now the noob question, the PIC will be powered by a 5V circuit, the signal from the sensor is powered on a 12V circuit, where do the backup diodes go to? The 12V cicuit or the 5V circuit?

The clamping diodes within the PIC go the the 5V circuit, I would assume the backup would go to the same place, just want to be sure.

This would greatly simplify my life 'cause it gets real complicated real quick trying to use op amps like the LM239, I got that idea from another tutorial.

Hi, Robert

No need for 5M if 12v signal ... just (say 45v ... automobile std. "power clamping" )

40v / 50µA .... 1M in series

diodes are - of course- between PIC input and power rails ( 5v and gnd )

IF using external clamp diodes, series resistor can be somewhat lowered :

using Schottky diodes ( Vf ~ .3v ) will easily allow 1 mA, (the internal clamping diodes won't have to conduct, then ... )

so, the resistor could be as low as 47k ... limiting input noise capture !!!

Alain

Demon
- 21st April 2008, 10:41
I'm reading the app note again and the part about alternating voltage bugs me. It says that "a 115 VAC 60 cycle sine wave will traverse from 0 to 2V in 32ms", what about 12VDC? Wouldn't that be on instantly so to speak? The car alternator may work with AC but it distributes DC to the car electrical system.

The other thing is the clamping diodes, they shut off over VDD and below VSS. That's fine to protect the PIC but that would interfere with my application. The car sensor works on 12V, I can't just stop measuring at 5V, I need "see" the remaining 7 volts or else I will get only a partial reading?

Let's use the fuel gauge as an example, the fuel tank would read from empty up to 40% full or so and then the meter would top out, no?

The only thing I can think of it to divide the car voltage by 4 and do the same thing with the signal voltage. That way I won't be comparing apples and oranges and I will be able to use the PIC ADC properly. My car battery is about 12.? charged and 14.? with the alternator charging. Let's use 16V as a maximum in case of a surge, divide by 4, that brings it down to 4V, well within the 5V limit of the PIC. I can still place a safety diode on top of that to protect at 5V too.

EDIT: Oh, and that spare 1V translates into another 4V buffer, that means it would be safe up to an absolute maximum 20VDC.

Acetronics2
- 21st April 2008, 10:59
Hi, Robert

I think we mixed DIGITAL and ANALOG inputs ...

here you want 0 > 12 v to be 0 > 5 v !!!

so, you need a voltage DIVIDER ...

see Darrel's site for such an application :

http://www.pbpgroup.com/modules/wfsection/article.php?articleid=25

Everything explained ...

Alain

Demon
- 21st April 2008, 11:08
Hi, Robert

I think we mixed DIGITAL and ANALOG inputs ...

here you want 0 > 12 v to be 0 > 5 v !!!

so, you need a voltage DIVIDER ...

see Darrel's site for such an application :

http://www.pbpgroup.com/modules/wfsection/article.php?articleid=25

Everything explained ...

Alain


Yup, the signals from the sensors will be analog. Interesting tool, I added it to my favourites. There is a comment at the bottom of that page that puzzles me though:

"Do not use the Zener diode (D1) for analog circuits. It will adversely affect the readings.
It can be useful for protection of Digital Inputs though."

So, since I've lowered the voltage to an acceptable level for the PIC, then there should not be any need for extra clamping diodes, no?

Acetronics2
- 21st April 2008, 11:15
So, since I've lowered the voltage to an acceptable level for the PIC, then there should not be any need for extra clamping diodes, no?

It's an automotive environment ( remember the 45v ??? ) ... use clamping diodes instead of the Zener ... they won't disturb the divider.

Alain

mackrackit
- 21st April 2008, 11:57
In post #19 and #28 of this thread http://www.picbasic.co.uk/forum/showthread.php?t=6809&highlight=zener
Melanie talks about the zener.