PDA

View Full Version : Dead PICs



CocaColaKid
- 8th August 2007, 19:19
I have a circuit done that is giving me lots of dead PICs for some reason. The PICs program fine but when installed in the circuit they lose there functionality and I can no longer program them nor can I even read them. Even the target ID is set to 0000 as well as all the memory locations. I have not put code protect on either. Once this happens the chips become totally useless. Any one have any ideas? The PICs I'm using are the 16F628A and the 16F88. I thought there might be a problem with the F628A for I tried the F88 and the exact same problem.

Ioannis
- 8th August 2007, 19:26
Few things that come to mind are:

Have you measured the +5 volts relative to the ground ON the chip directly?

Do you have any floating inputs or connected to other voltages relative to the ground of the PIC?

Is the MCLR pin properly setup and connected?

Ioannis

CocaColaKid
- 8th August 2007, 19:52
There are 4 floating inputs that I missed when the board was produced, porta.4, porta.5, porta.6 and porta.7. They should have been pulled up but I missed them as I was in a hurry to get the boards finished. Below is the code that I'm using in the device.


low porta.2 : low porta.1 : low porta.3 : low porta.0

@ __CONFIG _BOREN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _LVP_OFF & _WDT_ON & _INTOSC_OSC_NOCLKOUT & _MCLRE_OFF

'---------------------------- Port Assignments --------------------------------

' porta.0 Output 3 LED
' porta.1 Output 1 LED
' porta.2 Run LED
' porta.3 Output 2 LED
' porta.4 Unused
' porta.5 MCLR
' porta.6 Unused
' porta.7 Unused
' portb.0 Input 3
' portb.1 Input 2
' portb.2 Input 1
' portb.3 HPWM Output
' portb.4 Up Button
' portb.5 Down Button
' portb.6 Program Button
' portb.7 Debug Output

'---------------------------- EEPROM Locations --------------------------------

' 0 Output 1 Setting
' 1 Output 2 Setting
' 2 Output 3 Setting

'---------------------------- Debug Settings ----------------------------------

' DEFINE DEBUG_REG PORTB ' Debug port
' DEFINE DEBUG_BIT 7 ' Debug port bit
' DEFINE DEBUG_BAUD 2400 ' Debug baud rate
' DEFINE DEBUG_MODE 1 ' Debug mode 1 = inverted
' DEFINE DEBUG_PACING 300 ' Delay 'in micro sec' between characters sent

i con 254 ' Control byte
clr con 1 ' Clear the display
line1 con 128 ' Move cursor to home position on line 1
line2 con 192 ' Move cursor to home position on line 2

'------------------------------- Variables -------------------------------------

StillPressed var bit
x var byte
Output1 var word
Output2 var word
Output3 var word
StartupDelay var byte
TimeOut var byte

'------------------------ Miscellaneous Variables ------------------------------

Output3LED var porta.0
Output1LED var porta.1
RunLED var porta.2
Output2LED var porta.3
UpButton var portb.4
DownButton var portb.5
SetupButton var portb.6
Input1 var portb.0
Input2 var portb.2
Input3 var portb.1

'--------------------------- Port Initialization ------------------------------

TRISA = %00100000
TRISB = %11110111
CMCON = %00000111
CCP1CON = %00001111
OPTION_REG.7 = 0

'----------------------------- Main Program Loop -------------------------------

data 65,129,194

include "Elapsed.pbp"

gosub ResetTime ' Reset Time to 0d-00:00:00.00
gosub StartTimer ' Start the Elapsed Timer

clear

low porta.2 : low porta.1 : low porta.3 : low porta.0

StartupDelay = 34
TimeOut = 20

DelayedStartup:
if portb.7 = 0 then main
toggle RunLED
pause 250
if Seconds < StartupDelay then DelayedStartup
' debug i,clr

Main:
if SetupButton = 0 and StillPressed = 0 then
StillPressed = 1
gosub ResetTime
goto Setup
endif
StillPressed = 0
high RunLED
read 0,Output1 : read 1,Output2 : read 2,Output3
if Input3 = 0 then
' debug i,line1,"OUTPUT 3 = ",dec3 Output3," "
low Output1LED : low Output2LED : high Output3LED : hpwm 1,Output3,1000
goto main
endif
if Input2 = 0 then
' debug i,line1,"OUTPUT 2 = ",dec3 Output2," "
low Output1LED : high Output2LED : low Output3LED : hpwm 1,Output2,1000
goto main
endif
if Input1 = 0 then
' debug i,line1,"OUTPUT 1 = ",dec3 Output1," "
high Output1LED : low Output2LED : low Output3LED : hpwm 1,Output1,1000
goto main
endif
' debug i,line1,"OUTPUT = OFF "
low Output1LED : low Output2LED : low Output3LED : hpwm 1,0,1000
goto main

'-------------------------------------------------------------------------------

Setup:
low RunLED
low Output1LED
low Output2LED
low Output3LED
if SetupButton = 0 and StillPressed = 1 then Setup
StillPressed = 0
pause 50
read 0, Output1

Output1Setup:
high Output1LED
' debug i,line1,"OUTPUT 1 = ",dec3 Output1," "
hpwm 1,Output1,1000
if SetupButton = 0 and StillPressed = 1 then Output1Setup
StillPressed = 0
pause 50

StillPressed1:
if SetupButton = 0 then
gosub ResetTime
StillPressed = 1
low Output1LED
pause 250
if SetupButton = 0 then StillPressed1
write 0,Output1
read 1, Output2
goto Output2Setup
endif

if UpButton = 0 then
gosub ResetTime
x = x + 1
if Output1 + x > 254 then
Output1 = 255
goto Output1Setup
endif
Output1 = Output1 + x
pause 100
goto Output1Setup
endif

if downbutton = 0 then
gosub ResetTime
x = x + 1
if Output1 < x then
Output1 = 0
goto Output1Setup
endif
Output1 = Output1 - x
pause 100
goto Output1Setup
endif
StillPressed = 0
x = 0
if Seconds => TimeOut then
read 0, Output1
goto main
endif
goto Output1Setup

'-------------------------------------------------------------------------------

Output2Setup:
high Output2LED
' debug i,line1,"OUTPUT 2 = ",dec3 Output2," "
hpwm 1,Output2,1000
if SetupButton = 0 and StillPressed = 1 then Output2Setup
StillPressed = 0
pause 50

StillPressed2:
if SetupButton = 0 then
gosub ResetTime
StillPressed = 1
low Output2LED
pause 250
if SetupButton = 0 then StillPressed2
write 1,Output2
read 2, Output3
goto Output3Setup
endif

if UpButton = 0 then
gosub ResetTime
x = x + 1
if Output2 + x > 254 then
Output2 = 255
goto Output2Setup
endif
Output2 = Output2 + x
pause 100
goto Output2Setup
endif

if downbutton = 0 then
gosub ResetTime
x = x + 1
if Output2 < x then
Output2 = 0
goto Output2Setup
endif
Output2 = Output2 - x
pause 100
goto Output2Setup
endif
StillPressed = 0
x = 0
if Seconds => TimeOut then
read 1, Output2
goto main
endif
goto Output2Setup

'-------------------------------------------------------------------------------

Output3Setup:
high Output3LED
' debug i,line1,"OUTPUT 3 = ",dec3 Output3," "
hpwm 1,Output3,1000
if SetupButton = 0 and StillPressed = 1 then Output3Setup
StillPressed = 0
pause 50

StillPressed3:
if SetupButton = 0 then
gosub ResetTime
StillPressed = 1
low Output3LED
pause 250
if SetupButton = 0 then StillPressed3
write 2,Output3
goto main
endif

if UpButton = 0 then
gosub ResetTime
x = x + 1
if Output3 + x > 254 then
Output3 = 255
goto Output3Setup
endif
Output3 = Output3 + x
pause 100
goto Output3Setup
endif

if downbutton = 0 then
gosub ResetTime
x = x + 1
if Output3 < x then
Output3 = 0
goto Output3Setup
endif
Output3 = Output3 - x
pause 100
goto Output3Setup
endif
StillPressed = 0
x = 0
if Seconds => TimeOut then
read 2, Output3
goto main
endif
goto Output3Setup

BigWumpus
- 8th August 2007, 22:39
I see no 100nF C near the PIC.

What is about the 22uF-Cs near the optocouples ? What should they do ?

BobP
- 8th August 2007, 22:40
Hi,

Had a quick look at the schematic and can see nothing that I would expect to kill a PIC.

But I have some ideas for you to consider?
The 24vac supply for the power and the switches, are they independent or the same supply?
If independent are the earths connected? Can you isolate the switch earths from the rest of the circuit?

Having AC around with floating inputs definitely not recommended. Is there a good clearance between the 24vac and the PIC circuit? Can you tie the unused pins to ground with resistors?

Are the PICs killed within seconds of powering up? Are they killed on the bench or after connecting to its intended 'world'?

Hope this is of some help!

Bob

PS If the diagnostic input gets a static charge or voltage spike this would be relayed via the PICs internal port diodes to the 5v rail.

Ioannis
- 9th August 2007, 09:12
Also note that 78L05 has the input/output pins in reverse order than that you would expect looking at the device facing you and the pins downside, e.g. Out-Gnd-In.

Have you checked that you really have +5 at PIC's pins?

Ioannis

CocaColaKid
- 9th August 2007, 13:04
I see no 100nF C near the PIC.

What is about the 22uF-Cs near the optocouples ? What should they do ?

There are four 0.1uF capacitors in the circuit that are not shown on the schematic. One is located on the output from the 78L05, another is on the output from the 7812, another one is on the power pins right at the PIC and the last one is located right beside the OP-Amp.

The 22uF are there to keep the PIC inputs from cycling on and off caused by the AC voltage used for the inputs.

CocaColaKid
- 9th August 2007, 13:26
Hi,

Had a quick look at the schematic and can see nothing that I would expect to kill a PIC.

But I have some ideas for you to consider?
The 24vac supply for the power and the switches, are they independent or the same supply?
If independent are the earths connected? Can you isolate the switch earths from the rest of the circuit?

Having AC around with floating inputs definitely not recommended. Is there a good clearance between the 24vac and the PIC circuit? Can you tie the unused pins to ground with resistors?

Are the PICs killed within seconds of powering up? Are they killed on the bench or after connecting to its intended 'world'?

Hope this is of some help!

Bob

PS If the diagnostic input gets a static charge or voltage spike this would be relayed via the PICs internal port diodes to the 5v rail.

Everything uses the same power transformer and a common ground. The PICs are killed instantly when power is applied to the board on the bench. The diagnostic input is only used to bypass an internal startup delay timer. There is no connection to this pin other than a header socket so this should not cause any problems. Last week 4 PICs went south after passing a functionality test on the bench. The only thing that I can think is it has something to do with the floating inputs.

CocaColaKid
- 9th August 2007, 13:28
Also note that 78L05 has the input/output pins in reverse order than that you would expect looking at the device facing you and the pins downside, e.g. Out-Gnd-In.

Have you checked that you really have +5 at PIC's pins?

Ioannis

The 78L05 is oriented in the boar correctly and there is only 5V powering the PIC. The thing that's getting me the most is that this is a intermittent problem and I'm running out of things to look at beside the floating inputs. Can these 4 pins just be pulled high or do then have to go to ground?

BobP
- 9th August 2007, 14:29
Hi,

Interesting problem!!

I would suspect a voltage surge on the 5v rail when powering-up. Have you tried increasing the capacitance on the 12v rail to deaden surges hitting the 5v regulator. I have seen some 7805 (not 78L05) regulators 'whistle' on their output giving peaks of 8 volts if the capacitance is too small.

Is there any big inductive loads powered from the supply?

The unused inputs can be tied to ground or 5v with resistors (1k).


Last week 4 PICs went south after passing a functionality test on the bench
Was this a test using the PCB but with nothing connected? Do the PIC's die with just power connected or on load?

If every PIC dies on the bench in different (but identical) PCB's then I would look at the board layout carefully. If you can post a picture of track and component side I will look at it.

CocaColaKid
- 9th August 2007, 14:36
Looking at the pin function I noticed that porta.5 is shared with MCLR and Vpp. Just wondering if since it's floating that it somehow goes into a programming mode or something.

Luciano
- 9th August 2007, 15:19
Hi,

As a test, can you try to connect 24V DC instead of 24V AC and see if the problem is still there?

Best regards,

Luciano

Meriachee
- 14th August 2007, 21:59
Should the MCLR be tied with a 4k7 to 5v?

Raflex
- 15th August 2007, 06:26
Hello. You need to program RA5/MCLR as I/O port and add diodes between pic and optocouplers. Connect a 10uF cap to the out of 7805 regulator. Try it.

Squibcakes
- 15th August 2007, 10:32
Hi CC,

When your Chip dies, does it smoke, get hot or explode?

What does the 5V, 12V look like when there is no chip plugged in? What do they look like when the chip is in? (ie do either get dragged low from the dead chip?)

Have you checked your wiring, pcb for shorts. Double check that the VSS and VDD are connected to the right pins!

Take out all your electrolytics - it's possible that one of them is failing (shorting) when there is a voltage across them. Is one of them back to front?

I don't think that the floating inputs are going to kill your chip.. Its good practice to tie them to vss, or vdd when not used. I always just link them to ground and in my code set the tris registers to high (ie high impedance).

Oh if your not using the MCLR pin, just set the config fuse to off ie MCLR OFF.

Cheers
Squib

CocaColaKid
- 15th August 2007, 13:08
I think I may have traced the pass to my problem. I think what's been happening is that I have a header that I use to test the boards that is powered all the time. I think I'm applying 24V AC to the board with no ground and then grounding pin PORTB.7 then applying the ground to the chip. I have installed a resistor in the PORTB.7 line and have not seen the problem since then. I will keep checking though but so far so good.

CocaColaKid
- 15th August 2007, 13:12
Hi CC,

When your Chip dies, does it smoke, get hot or explode?

What does the 5V, 12V look like when there is no chip plugged in? What do they look like when the chip is in? (ie do either get dragged low from the dead chip?)

Have you checked your wiring, pcb for shorts. Double check that the VSS and VDD are connected to the right pins!

Take out all your electrolytics - it's possible that one of them is failing (shorting) when there is a voltage across them. Is one of them back to front?

I don't think that the floating inputs are going to kill your chip.. Its good practice to tie them to vss, or vdd when not used. I always just link them to ground and in my code set the tris registers to high (ie high impedance).

Oh if your not using the MCLR pin, just set the config fuse to off ie MCLR OFF.

Cheers
Squib

No explosion or anything exciting like that unfortunately, lol. The PIC does get hot though after it fails as do the regulators.

Typical if it powers up and everything works right the regulators volts I don't think even moves when the PIC is in the circuit or not. When the dead PIC is there the 5V drops to around 4.4V or something as I recall.

What I ended up doing since I noticed I forgot to tie the unused pins somewhere is I made them and output and but them high so they weren't floating.

The MCLR line is set to input mode as I didn't see the sense in putting in another resistor just for that pin.