PDA

View Full Version : PIC16F819 locking



Calco
- 21st December 2005, 15:39
Hi,

Iam trying to sort out a 'minor' problem. Iam using a 16F819 with internal oscillator running. I have two relays connected via NPN transistors. The relays are fed from 12volts. The transistors are just basic switching transistors.
The problem is as follows, unit powers up, goes through a brief self test (Flashes 3 leds! a few times), then proceeds to power one of the relays, this works fine. I am using a selector switch connected to other pins to choose one of three options. What iam finding is that quite often the PIC locks up after the relay is powered, it doesnt always happen but it is more often than not. The selector switch ceases to provide the correct output on the LEDs.
I have noticed one thing, that is if I independently power the circuit it works flawlessly. It is only when I use the onboard transformer that the trouble starts. It has ample amounts of current available. The circuit draws 105mA, the transformer is capable of 192mA. I have added additional smoothing capacitors etc and that only seems to make matters worse.

Any suggestions?

Cheers

Darryl

rhino
- 21st December 2005, 17:43
You might want to post the schematic, or code. Are you using fly back diodes for your inductive loads?

markedwards
- 22nd December 2005, 04:05
Darryl,

I have used a number of different pics but the 16F819 is the 1st that I experienced powerup issues. Disabling the power-up timer eliminated my problem. I am controlling 5 relays and pwm a 40 amp motor, close to 100 amps total. I recently passed a battery of emc noise testing with the 16F819.
The power-up timer was frustrating, sometimes it powered up and worked fine, sometimes not. I am not using the master clear reset or low voltage programming in my design.
PCB layout, flyback diodes (across the relay coil), code design are important.
Good luck!

Mark

penelopepug
- 22nd December 2005, 04:33
I would pay close attention to the transients generated by the relay coils when switching. I like to use hexfets because of their high gate isolation from the drain and source. You have to add a reverse biased flyback diode like a 1N4001 accross the relay coil and provide further isolation from your port pin to the fet's gate with a resistor, perhaps 4.7K. If you have pic port wires in close proximity to the relay source/sink wires, you can get induced noise in the pic causing havoc as well.

Calco
- 22nd December 2005, 10:22
Hi,

Thanks for all the replies,

Yes I have flyback diodes on each relay, I also have diodes from the pic's port output to the resistor on each transistor.

My confusion is to why it works perfectly when seperately powered but not when its powered off its own transformer, Iam using the same regulator circuit etc.

It is driving me mad.

Yes I did have power up issues with the design initially also, I found adjusting the settings for the start up timer etc in the config sorted that out.

I had similar problems with the 18F452 with random resetting so I had knowledge of this trickiness.

I also had a batch of F819's that would only program once, cost me about 10 chips in the end.

Thanks anyway

Darryl

penelopepug
- 22nd December 2005, 13:28
It still sounds like your getting a power glitch that is affectig the pic. You could also try a larger capacitor parallel to 0.1uF accross the pic and turning off the brownout detect.