PDA

View Full Version : PIC12f683 GPIO.0 Trouble



Larryd
- 9th February 2014, 08:53
Trying to build small power reset circuit using a PIC12f683.
When GPIO.1 goes high, I set GPIO.0 high to MPS2222
Transistor to make the circuit. Trouble is GPIO.0
dosen't go low, or if it does it's only for a MS, then goes high again.
and PIC12F683 starts to get hot.

Code:
'************************************************* ***************
'* Name : RelayHold.BAS *
'* Description : Pull Relay and Hold 15 seconds *
'************************************************* ***************



PRELAY Var GPIO.0 'Pull Relay turn off power to old controller 15 seconds
RESETME Var GPIO.1 'GPIO.1 to Wait For 1 to Go High From Old Controller
STAT Var GPIO.4 'Alias GPIO.4 to Turn on LED while relay is on


ANSEL = 0 'Set all digital

CMCON0 = 7 'Analog comparators off
TRISIO =101110 'Set Pin I or O

low STAT
low PRELAY


mainloop:

If RESETME = 1 Then 'PIC Requesting Reset
gosub ReSet_Ctrllr
Endif
Goto mainloop ' Do it forever

End

ReSet_Ctrllr:

High PRELAY 'Turn on Relay connected to GPIO.0 to power cycle old controller
High STAT 'Turn On LED If Present
PAUSE 15000 'Hold Relay High for 15 seconds
low PRELAY 'Turn Off Relay connected to GPIO.0
low STAT 'Turn Off LED If Present
PAUSE 50000 '50000 ' Give Old Controller Chance to Recover Pause about a minute

return

See attached drawing for details.

Thanks in advanced,

Larryd

Charlie
- 9th February 2014, 15:15
Your problem description sounds like the transistor is in backwards. A word of caution about 2222A pin order - MPS2222A is EBC but 2N2222A is CBE.

aerostar
- 9th February 2014, 16:19
At a quick glance I think your circuit has some GOTCHAS in it.

You can supply a HI to the transistor, but you cannot send a LO to it, (diode blocking it) so the transistor base is floating.

Unsure as to your reason for feeding your ground through a diode.

You have no decoupling or smoothing caps in the 5V line

Also think that your 10K pull down should be on the other side of the diode as when the controller reset is LO the pic is not able to see it as it will not pass through the diode.

AvionicsMaster1
- 9th February 2014, 18:27
Well the biggest issue I see is GPIO.3 MCLR needs to be pulled high unless you disable it in your configs.

I agree with previous about diodes. Remove them especially on the power pins and add the decoupling caps. They are not really necessary in light of the slow speed of your program.

If PIC is getting hot it's sinking/sourcing too much current. Usually to the base of the transistor you'd use a 10K but if you look at datasheet of 2222A you can calculate the right size to get the transistor to saturation. Diodes to transistor isn't necessary and should be removed.

Resistor to GPIO.1 should be at pin to pull pin low when circuit is not setting it high. You can ditch the diode there also.

Since you're doing all that shifting I'd suggest you not use GPIO.0 and GPIO.1. They are the ICSP pins and with out a switch to isolate circuit use of those pins as shown will not allow you to do ICSP. Don't forget GPIO.3 is an input only when configured properly and your controller reset input is the best use of that pin.

I suspect it will work as drawn once you fix the MCLR pin and transistor orientation if incorrect.

Larryd
- 9th February 2014, 21:17
Thank you all for the Help !!
I'm new to micro controllers and have another question about the
decoupling capacitor. is this like a 0.1uf ceramic capacitor across pin
1 and 8?

Also does the diode on pin 1 of the 12F83 need to be removed?


I'm working on now, will let you know the outcome in just a few.

Thanks again !!

Larryd

AvionicsMaster1
- 9th February 2014, 22:29
Decoupling cap is across pins 1 and 8 and according to the "friendly" data sheet:To ensure these oscillator frequency tolerances, VDD and VSS must be capacitively decoupled as close to the
device as possible. 0.1 μF and 0.01 μF values in parallel are recommended.

Diode on pin 1, I think, needs to go. If you want to put it in series with the 10kish resistor pulling pin 4 high that would be fine. It is used to protect the power supply from the programming voltage applied to GPIO.3 during ICSP. If you're not going with ICSP you don't need the diode. Just the 10kish pulling GPIO.3 high.

Larryd
- 10th February 2014, 17:34
It works now but 12F683 still gets hot, I also noticed it flashes the
power power light on the old controller after 15 seconds.
but relay is still up seems like it takes 2 cycles to release relay.
Then 12F683 starts getting really hot.

I put the 10K resistor in not really sure on how to do the math on the
transistor.

any ideas?



Thanks
Larryd



'************************************************* ***************
'* Name : RelayHold.BAS *
'* Target PIC : PIC12F683 *
'* Oscillator : 4MHz internal *
'* Description : Pull Relay and Hold 15 seconds *
'************************************************* ***************


RstRELAY Var GPIO.2 ' Alias GPIO.2 Go High To Pull Relay
RESETME Var GPIO.4 ' Alias GPIO.4 to Wait For Pin-3 to Go High From Old Controller
STAT Var GPIO.5 ' Alias GPIO.5 Go High show LED Relay Active



ANSEL = 0 ' Set all digital
CMCON0 = 7 ' Analog comparators off
TRISIO =%00011000

low STAT
low RstRELAY


mainloop:

If RESETME = 1 Then ' PIC Requesting Reset
gosub ReSet_Ctrllr
Endif
Goto mainloop ' Do it forever

End

ReSet_Ctrllr:

High RstRELAY ' Turn on Relay connected to GPIO.0
High STAT ' Turn On LED If Present
PAUSE 15000 ' Hold Relay High for 15 seconds
low RstRELAY ' Turn Off Relay connected to GPIO.0
low STAT ' Turn Off LED If Present
PAUSE 20000 '50000 'Give Controller Chance to Recover Pause about a minute


return

Larryd
- 10th February 2014, 18:29
Charlie,
when I turn the transistor around it will not work at all

Thanks
Larryd

LinkMTech
- 11th February 2014, 15:43
Any chance the controller reset pin voltage to the PIC coming in at greater than 5V?

Larryd
- 12th February 2014, 00:51
Louie,
I just tested, it is 4.88 V.

Also don't know if this helps but once the 12F683 goes into the over heating mode,
I removed connections on pins 2 - 7 and it still got hotter till I disconnected power.

Thanks
Larryd

Charlie
- 12th February 2014, 11:46
Is your 5V supply really 5V? Does it stay at 5V when the relay is activated / not activated?

EarlyBird2
- 12th February 2014, 12:34
Louie,
I just tested, it is 4.88 V.

Also don't know if this helps but once the 12F683 goes into the over heating mode,
I removed connections on pins 2 - 7 and it still got hotter till I disconnected power.

Thanks
Larryd

Sounds like you have blown up the chip. Check what voltage is being fed into GPIO.4.