Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic16f628a - Ra4 Open Drain Output

Status
Not open for further replies.

fenderman

Member
Hi all,

I'm looking to use the RA4 pin of a 16F628A as an output, unlike most of the other outputs which can source an LED current, this has an open drain requirement. I was planning on tying this output to VDD (+5v) via an 820R LED limiting resistor, and inverting the logic for the drive of the pin.
I can't see any problem with this but thouht I'd like confirmation that this would be acceptable before I get the soldering iron out.
Thanks,
Roy
 
Last edited:
Hi Bill,
Thanks for your reply.
I'm just driving a standard LED (around 6mA), but as the other outputs are all sourcing the LEDS via 'on board (PCB)' 820R resistors wired directly from the PCB to the LEDs, with all the cathodes tied to 0v, I did'nt want to have an odd one where the LED would have been sourced from the VDD and an external resistor and 'sank' via the Open Drain as this would have caused problems in the LED panels, so hence the thought that I'd effectively drive the LED via an 820R resistor to the LED and to 0v, with the open drain pin connected to the junction of the LED Anode and the Resistor.
Hence when the Output is 'ON' the LED would be 'shorted' and be 'OFF'.
Fortunatly (more by luck than planning), the PCB I designed does have the facility already to accomodate this 'mod' without any additional tracks/or link wires.
Thanks for your confirmation, it is appreciated .... I have done it now, and it works fine.
Roy
 
Oops,

Forgot to mention, the output RA4 Open Drain pin on a PIC16F628A already is implemented to do the 'invert' of the logic, so operates in TRUE logic.

The only thing to be aware of here, is that when the PIC first fire's up, (and especially if you are using the Start Up Delay), the output is ON until the first initialisation / drive to PORTA, hence you do get a 'blip' on the output from a HIGH to a LOW.
Not a problem on LEDS etc, but may be a problem if driving into other logic.
 
Oops,

Forgot to mention, the output RA4 Open Drain pin on a PIC16F628A already is implemented to do the 'invert' of the logic, so operates in TRUE logic.

The only thing to be aware of here, is that when the PIC first fire's up, (and especially if you are using the Start Up Delay), the output is ON until the first initialisation / drive to PORTA, hence you do get a 'blip' on the output from a HIGH to a LOW.
Not a problem on LEDS etc, but may be a problem if driving into other logic.

If you write 0x10 to PORTA (all LEDs off I assume) before you change the TRIS register then the problem should disappear.

Mike.
 
Cheers Bill,
I was going to do this, but as I indicated in a previous post, I wanted to retain identical LED external circuitry, where all the other LEDS are being sourced from the outputs (via the on board resistors), and all the cathodes are taken to 0v. This was the reason for 'shorting' the LED with the output as this maintains identical LED wiring externally.

Thanks for the suggestion Pommie,
I've not tried it yet, but I'll stick a storage scope on it tomorrow and see what happens ... I'll report back the findings accordingly.

Roy
 
I hadn't realised you were shorting the LED with the output, I assumed the output grounded the LED. My suggestion wont work with your current configuration.

Thinking about it, your method is quite ingenious and makes the logic simpler. A high output always turning the LED on even though RA4 is OC. Clever.

Mike.
 
What I would do...But I guess there is a reason why you don't want to change the circuitry?

EDIT: AHHH thanks Pommie, now I see why he wants it that way. Good Idea, think I will turn some of my LEDs around then..lol

-BaC
Then turn all your LEDs around.
 
Last edited:
Are you saying that people shorted out incandescent bulbs to turn them off? :confused:

No :D

But shorted out all sorts of things in electronics, an obvious example being shorting the input to a transistor out to turn it off - but there have been many such uses over many years.

For a pretty identical example check the bottom of my page at
 
Damned that learning curve!

Cheers Nigel m8,
-BaC

It's a standard technique, and has been used for many decades, long before micro-controllers or LED's :D

Nigel Goodwin said:
No

But shorted out all sorts of things in electronics, an obvious example being shorting the input to a transistor out to turn it off - but there have been many such uses over many years.

For a pretty identical example check the bottom of my page at
Cybot Motor Driver Board
 
Cheers All,
The primary reason for sourcing the LED's and 'shorting' the one on the RA4 is that all the LEDS (over 200 of them) are already installed and wired, as these units are replacing the existing driver circuits which was pure TTL logic which were very old and there were no replacement parts available.
My 'Brief' was to come up with something to replace the driver circuits, and have ample replacement spare part capability, hence I chose the PIC16F628A as this was my first venture into PICS, but have broken the cardinal rule of design, and did'nt read the data sheet properly ...
However, the PCB I designed has multiple functions and can be configured for either 12 inputs / 12 outputs or 6 of each, hence a 12 channel combo board, with 'on board' pull up resistor SIL networks and driver resistor positions, reset circuits and Tx/Rx comms, which fortunately allowed the function of the RA4 circuit to be implemented 'as though it was designed that way' ... so there are no links, mods to the board etc.


Pommie,
I did try your suggestion, but did'nt expect it to work, which it did'nt.
I think the reason is that when the system is first powered, the RA4 output is high impedence, and hence the LED (and its resistor/anode junction) are 'HIGH' so the LED is ON, there is an inherent delay in the PIC starting up (even without the programmed 72ms start up delay).
Hence you do get thes short 'ON' time until the PIC initialises.

As Nigel indicated, I have been doing this for years with Micros especialy using transistors/switches to discharge capacitors on Micro Reset circuits before we had WDT chips available.

Thanks for all your posts ....

Roy
 
Ahhh, That is how they made Supervisory Circuits in the day. Wicked info, learning something new 10 times a day so I am loving this.

I love the fact that I can get people with tons of experances and tricks and tips if you will.

Thank you very much guys!

-BaC
As Always You Can't Beat Experience...

Cheers All,
As Nigel indicated, I have been doing this for years with Micros especialy using transistors/switches to discharge capacitors on Micro Reset circuits before we had WDT chips available.

Thanks for all your posts ....

Roy
 
Hi Fenderman,

I need use RA4 as I/O port to run DAC by outputing a DIN accompanied by FS, SCLK. but how to make RA4 to do general I/O port?
I don't understand
The only thing to be aware of here, is that when the PIC first fire's up, (and especially if you are using the Start Up Delay), the output is ON until the first initialisation / drive to PORTA, hence you do get a 'blip' on the output from a HIGH to a LOW.
.
"Not a problem on LEDS etc, but may be a problem if driving into other logic."
What does it mean?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top