PDA

View Full Version : PIC16F690 with NE555



xnihilo
- 27th September 2008, 23:21
Well...

I connected portC.4 from a PIC16F690 to a resistor to the BASE lead of a BC182L NPN transistor where the Collector lead is connected to the TRIGGER pin of a NE555 used in monostable mode (this pin is also connected to a 10K weak pull UP resistor).

TRISC.4 is 0 and PORTC.4 is 0 so it will be an output with a logic of 0.

The NE555 is supposed to be triggered when the TRIGGER (pin 2) is pulled low.
As C4 is low because of my TRIS and PORT settings, it should not switch the transistor so the NE555 TRIGGER pin should stay at its pulled up value of 5V.

Actually, when I power up the application, I hear the click of the 5V relay connected to the NE555.

I am wondering what is going on.
When I remove the pic 16F from its socket, the NE555 is not activated, what means that there has to be a positive voltage on the pin C4 when the pic is powered on, just before I can set the TRIS and PORT registers, is that right? Do the I/O pins output a positive voltage when the chip is powered on???
I did not find this in the datasheet or did I miss a line in this datasheet?

Charles Linquis
- 27th September 2008, 23:37
Three questions:

1. Do you have a resistor between the PIC output pin and the base of the transistor?
2. Do you have a pull-down resistor on that output pin?

3. Why do you need the 555 at all? It seems like it would be just as easy to use the PIC as a one-shot to control the transistor to control the relay.

xnihilo
- 27th September 2008, 23:47
Thank you for your reply.

1. Do you have a resistor between the PIC output pin and the base of the transistor?

-> Yes, I call it RB, I calculated the value empiricaly (I have to check on my board if it is a 3.3K or a 4.7K)

2. Do you have a pull-down resistor on that output pin?

-> No I don't...

3. Why do you need the 555 at all? It seems like it would be just as easy to use the PIC as a one-shot to control the transistor to control the relay.

Because I need the MCU to go on doing stuff whle the NE555 is outputing for a specific delay, independently of the MCU. I need the MCU to get rid of the job.

Charles Linquis
- 28th September 2008, 01:12
I would recommend you put a pull-down on the PIC pin. 4.7K or so. That will probably fix your start-up trigger.

And... You could probably find an easy way (such as using a timer interrupt) to allow your PIC to produce a pulse while doing other tasks.

xnihilo
- 29th September 2008, 17:25
Hello.

I thank you for your help. I will try the pull down.

Regqrds.

Melanie
- 29th September 2008, 17:39
The reality is that a PIC I/O's can be indeterminate on Power-On. Set the I/O's as one of the first things you do when you Power-On your PIC. Leaving them set to input (high impedance) may be enough to trip your circuitry.

Charles Linquis
- 29th September 2008, 23:26
Melainie, it is so nice to see you making posts again. We need you!

Melanie
- 30th September 2008, 08:33
You know I can get to like some folks... *smiles* but seriously, don't get too excited... yesterday afternoon was an exception... I was in a meeting with people and a subject that bored the hell out of me... thank God for Wireless Laptops...

xnihilo
- 30th September 2008, 13:29
The reality is that a PIC I/O's can be indeterminate on Power-On. Set the I/O's as one of the first things you do when you Power-On your PIC. Leaving them set to input (high impedance) may be enough to trip your circuitry.

Hello,

Thank you for the answer.

About the pins status at power on, I read in the datashet that it is in undetermined state, as you say. I set PORTA in the program but it seems to be too late because the NE555 already got a logic HIGH from the pin by the time the PORTC register is written.

What is "tripping" a circuitry? (sorry if I sound ignorant).

skimask
- 30th September 2008, 18:35
I set PORTA in the program but it seems to be too late because the NE555 already got a logic HIGH from the pin by the time the PORTC register is written.

What is "tripping" a circuitry? (sorry if I sound ignorant).

That's why you add a pulldown resistor. That way as soon as you apply power, the line is already LOW.

'tripping' - As you've figured out, PIC's pins are INPUT at power up. If nothing is connected to them, or they are connected to something that isn't really 'connected' (i.e. another input to another chip), they'll float, meaning they just kinda hang onto whatever charge is floating around in the air, or maybe they'll get a bit of leakage from the pin next to them, or a bit of leaking across a couple of traces on the PCB...they'll end up doing whatever they want because there's nothing there to pull them either way....so, the charge might get high enough to register as a HIGH at the port latch itself....Orrrrrr....the charge might get low enough to register as a LOW at the port latch itself...Orrrr....it might hang out somewhere in the middle and just by accident get registered as a HIGH or a LOW just by hanging out. The key here is that it's 'Indeterminate', exactly what the books say... You just don't know what it's going to do, so you give it something to do, by adding a little push, a little bit of voltage to go either HIGH or LOW...

xnihilo
- 3rd October 2008, 09:40
Thank you for this crystal clear explanation.
The datasheet is very clear too about the state of the pins at powerup.

I've tied the pin to GND with a 4.7K WPD resistor but still it would be HIGH at power-up.
I moved the PORT (setting it to 0) and TRIS (setting it to input) for this pin right at the top of my source code: it helped. Later in my code the PORT and TRIS registers are set to the right settings (my pin has to be used as output as it outputs a pulse).

Hope this helps others.