12F629 outputs to 0V

Thread Starter

Alex GD

Joined Apr 19, 2020
8
Thanks but... It is really so difficult to understand?
Normal behaviour: Outputs give 5V.
What I need: Outputs give =0V (not open output, but 0V). Imagine that I connect a LED+resistor to the positive and the negative is connected to the output.

Bob says: The output is switched to ground whenever you set it to zero.
I am not talking about the initial configuration, but when running a program. When the output is high, we get 5V, but when the output is low, we get open circuit or 0V???

Thanks again
 

jpanhalt

Joined Jan 18, 2008
11,087
The initial state before power up and for a short time thereafter is undefined. However, all pins come up high-impedance.

I asked a simple question for clarity and you have yet to respond. Without clarity from you, things will get very confused. For example, you said your pins were sourcing and you wanted to change them to sinking. You implied that was being done with just firmware. If that is the case, it is even more important to show how it is wired.

Thanks but... It is really so difficult to understand?
No, it is not difficult and all of us have done it. What are you finding that is so difficult? Again, show us how it is wired.

EDIT: When the output is low, it goes to ground. If you want an open circuit ("tri-state"), you can approximate it by changing the TRIS bit to input and being sure weak pull-ups are disabled.
 
Last edited:

Thread Starter

Alex GD

Joined Apr 19, 2020
8
I explained already how it is wired. Again, a LED with the cathode connected to any PIC output and the anode to a positive with a resistor. Will the PIC supply 0V to light the led or not?
 

MaxHeadRoom

Joined Jul 18, 2013
30,684
ormal behaviour: Outputs give 5V.
What I need: Outputs give =0V (not open output, but 0V). Imagine that I connect a LED+resistor to the positive and the negative is connected to the output.
When the output is high, we get 5V, but when the output is low, we get open circuit or 0V???
Thanks again
Read page 21 of the manual, setting GPIO setting or clearing a output port sets the output high or low. (1 or 0).
Also read up on the TRISIO instruction, both these will show you how the outputs are either set or cleared in order to output a high or low (1 or 0).
Max.
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
I explained already how it is wired. Again, a LED with the cathode connected to any PIC output and the anode to a positive with a resistor. Will the PIC supply 0V to light the led or not?
Yes. When PIC output is cleared (set to 0) that design should allow the LED to turn on.

In post #8 you said,
I am using as a source, I want to use them as sink. I need the output set to ground when enabled, not set to 5V.
I interpreted being used as a "source" to mean your connection was like diagram "B" that I posted.
 

Thread Starter

Alex GD

Joined Apr 19, 2020
8
OK thanks a lot to everybody, I will try tomorrow. The idea is to use PNP transistors (not NPN) to drive higher load at the outputs. I have many of them which I do not use.
 

Thread Starter

Alex GD

Joined Apr 19, 2020
8
Works OK. From every output pin goes to 1K2 resistor and to the base of one PNP transistor (2N2907). Emitter to positive and collector in serial with the load (1W LED) and a resistor of 27 ohm 1W, getting aprox 190 mA. Of course, to get the same results than with a NPN transistor, you must invert the outputs at the program.
Thanks again to everybody.
 
Top