interfacing inputs at safe levels.

springer

New Member
can someone please point me to a general guide for interfacing 'abnormal' inputs to pic's, as most of the online docs i've found only deal with digital or outputs.

my specific problem is that i have a 3 wire 12v dc fan, with a tacho. the tacho, according to my dmm is a +ve 8v pulse at a frequency proportional to the speed. this i would like to 'safely' interface to a pic (don't care what type)
more importantly, i need to understand the maths behind it, and what type of circuit to use when.
thanks....
 

BeanieBots

Moderator
As there really isn't such thing as a 'general' input, it's hard to point you to a 'general' guide.
8v pulses from a 12v fan seems very odd.
How sure are you about it? Could it be an "open collector" output?

If it REALLY IS 8v pulses, then no problem. Simply use a potential divider.
You need to get the 8v pulses down to 5v pulses to go into the PICAXE safely.
If your divider is made from R1 & R2, then V' (the voltage at the join and R2 is the lower resistor) is given by V'=V*R2/(R1+R2).
using 'prefered' values, something like 3k3 & 4k7 would be a fair choice giving about 4.7v pulses which a PICAXE running on a 5v Vcc would be quite happy with.
 

hippy

Ex-Staff (retired)
Microchip Application Note AN521 is a good starting place for PICmicro's / PICAXE's where it states, "High voltages can be applied directly to the chip inputs as long as they are current limited".

This is an Application Note detailing direct connection to AC mains voltages. While that is seriously not recommended for people who are not suitably qualified, trained or experienced the technique can be applied to lower voltages and is in fact used to allow the PICAXE to connect to a +/-12V RS232 serial port for download.

As to the maths, that's touched upon in the Application Note; basically reduce the current to below the permitted injection current. In practice the current can often be reduced well below the maximum permitted and still be read correctly.

Alternatives include level converters, voltage dividers and other tricks. There is currently another thread in the forum disccusing this issue which would be worth seeking ot.
 

BeanieBots

Moderator
Good point gbrusseau, certainly in the right 'ball park' for that to be the case.
I was thinking maybe open collector with a sloppy or weak/(leakage) pull-up being pulled down by the meter but I think your suggestion fits better.
 

jglenn

Senior Member
A simple way to do that is a series 1K to a 5.1V zener diode, anode grounded.

Has the advantage of being a normal diode too, so it clamps any negative input to -.7V.

Maybe a less than 1K, say 470 ohm. We use this idea to step down 277V ac signals, but you need a power resistor, and bigger zener.
 

Ralpht

New Member
Sounds like one of those fans you typically get with PC's these days, where the motherboard measures and displays the fan speed. Often used to control the fan speed as well when overclocking the CPU etc.

The resulting 8V is exactly what I would expect as well and gbrusseau got it spot on.

The suggestion by jglenn is the simplest fix for the problem, only I would use a 4.7V Zener, not 5.1V.

A 1K resistor from 5V to the Cathode of the diode with the Anode to Gnd. Take your 4.7 volts off the Cathode.

If you can get your hands on a CD4504 Hex CMOS level shifter, that will also do the job perfectly. Give it both VDD (up to 20V) on pin 16 and VCC on pin 1.

You can then select level shifting in either direction. Usefull if you have more than fan etc. The 8V pulses will be shifted down to 5V safely/
 

hippy

Ex-Staff (retired)
If it is a 12V signal, I'd use a 22K series R, same as is used in the download interface which is itself designed for a 12V input. This limits the injection current to around 500uA.
 
Top