PDA

View Full Version : 16f887 PIC output pin pull to ground



bodgetts
- 19th July 2011, 18:22
Hi,

I have an external LED board that needs a pin to be pulled to ground to begin its flashing routine. If I connect a wire from ground to this pin it works perfectly.

How would I control this from an output pin of the 16f887? When the pin is high it is +5v, when it is low it is 0v but not ground. Do I need to use an inverter, etc?

Thanks for the help

HenrikOlsson
- 19th July 2011, 18:42
Hi,
It sounds as if the two boards are missing a common ground.
The ground of the display board must be connected to ground of the PIC so that they share the same reference.

/Henrik.

bodgetts
- 19th July 2011, 20:10
Thanks for the reply.

The 2 boards do share a common ground. The LED module has 4 pins: +12, GND, Signal 1 and Signal 2. I share the +12 and GND between both boards (+5 is generated through a voltage regulator on each board).

The specs for the LED board say that you must tie Signal 1 or Signal 2 to ground to control it. So if I connect Signal 1 to GND, it will start flashing one way, and Signal 2 to GND will flash another way. If I do both it flashes a 3rd way, and no pins to GND it will just stay off.

If the Signal pins needed to be set High to control them, I would just connect them to the PIC outputs on my main board. How can I make it so that I can control this external LED board from the PIC on my main board? ie. How do I tie the signal pins to ground?

aratti
- 19th July 2011, 20:28
Since your led board works with 12 volts, i would suggest to use an optotransistor as TLP504 to accomplish your goal.
Just Connect the two emitters to ground and the two collectors to signal1 & signal2. The diode side will be controlled via your pic using e 330 ohms resistors on both diodes. Turn on the pic pin where you connected the diode and the corresponding NPN optotransistor will ground your control signal input. Mind you totaly isolated from the 12 volts.


Cheers

Al.

HenrikOlsson
- 19th July 2011, 21:53
If the Signal pins needed to be set High to control them, I would just connect them to the PIC outputs on my main board. How can I make it so that I can control this external LED board from the PIC on my main board? ie. How do I tie the signal pins to ground?
The output concists of two transistors in a push-pull configuration. When the pin is in output mode (controlled by the TRIS register) one or the other of these two transistors will be on. One "connects" the pin to Vdd (+5V) and the other "connects" the pin to Vss (ground).

In order to switch PortB.0 low you can do:

Low PortB.0 ' Switch low
Or the "manual" but prefered way

TRISB.0 'Make PortB.0 an output
PortB.0 = 0 'Switch low

That's it really. Now, there are two things to remember:
1) The pins always come up in input mode meaning you have to switch them to ouputs. This is done thru the TRIS register as shown above but HIGH and LOW handles that for you if you prefer.
2) Some PICs have analog inputs for the ADC and comparators etc on various pins. If the pins you're trying to use has functions like this they will have to be disabled. Withput knowing which PIC and which pins you're trying to use it's impossible to advise further.

bodgetts
- 20th July 2011, 00:32
I managed to get it working, it turns out the specs on the board were not very clear. I could connect the output pins of my PIC directly to the signal and set them low. I thought that maybe I would have to do something tricky, but was dead simple.

Thanks for the help guys.

kenif
- 22nd July 2011, 01:24
In the old days a TTL low was not very low, it only had to be below 800mv.
So an older device (say 74LS04) would give a low of one junction above ground, around 600mv.
These days most devices (like PICs or 74HCT04) are CMOS, so a low is no longer one bipolar junction voltage above ground, but an impedance above ground.
The difference is that now the output behaves more like a resistor to ground (an FET), and the value of the low is a function of the current it's sinking, which means it's typically very, very low. Or, if you prefer to round these numbers down: ground.

bodgetts
- 23rd July 2011, 00:33
Ok, I understand now. Thanks kenif!

Sneaky-geek
- 27th July 2011, 15:37
Hello All,
Without seeing a complete schematic:
Be careful as to how much current you are trying to sink!
Please place a 330 ohm 1/2 watt resistor this limits the current that the pic output is switching to 15 ma. Or use a 200 ohm 1/2 watt to limit current to 25 ma, the MAXIMUM that the pin is rated for.

Just a thought,

Terry K9HA