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.

PIC freezes when running from batteries

Status
Not open for further replies.

Macka

New Member
Hi guys,

This is the first DIY PIC project I've worked on; all of the other projects I have worked on had either a dev board or a predrawn circuit ( and components) supplied.

I'm using a 16F88 (internal OSC set to 8MHz) and a PICKit2. Currently I'm attempting to use 4LEDs to make a POV display, they are connected to PortB.0, PortB.1, PortB.2, PortB.3. I have a 1MΩ resistor connected from VPP to +5V. There are no other components connected.

When I use the PICKit as the PSU it works fine, the lights flash and the loop continues until power is removed, however, if I replace the PICKit with 4AA batteries the PIC freezes on the first (or perhaps last) instruction of the loop.

I have tried placing a 47nF capacitor across the supply with no luck.

Any suggestions?
 
That's about all I have available and it seems to do the job, without it VPP goes low and the PIC won't run.

My choices are: 1MΩ, 1.5MΩ, 370Ω
I unfortunately do not have a stock of components, I have only ever bought what I've needed when I needed it. I think I need to find a good, cheap kit of assorted resistors and capacitors.

Surely the 1MΩ resistor isn't the cause, I'll try replacing it with the 370Ω.... No change
 
why dont you change the config word to disable MCLR that way you dont need a resistor on MCLR
 
No reason in particular, I might do that.

I simplified my code and changed the OSC to 4MHz:
Code:
program FlashingLED

main:
TRISB=%11111110
OSCCON=%1101100       'OSC 31.25

while (1)
    'TESTING
    PortB.0 = 1
    delay_ms(500)
    PortB.0 = 0
    delay_ms(500)
WEnd
End.

I connect the battery and the LED flashes a few times and stays on. I then have to disconnect the battery and wait a few seconds before reconnecting, the longer I wait, the more flashes before it freezes.

I disconnected the programming wires completely this time to see if there was any effect, there wasn't.
 
No reason in particular, I might do that.

I simplified my code and changed the OSC to 4MHz:
Code:
program FlashingLED

main:
TRISB=%11111110
OSCCON=%1101100       'OSC 31.25

while (1)
    'TESTING
    PortB.0 = 1
    delay_ms(500)
    PortB.0 = 0
    delay_ms(500)
WEnd
End.

I connect the battery and the LED flashes a few times and stays on. I then have to disconnect the battery and wait a few seconds before reconnecting, the longer I wait, the more flashes before it freezes.

I disconnected the programming wires completely this time to see if there was any effect, there wasn't.

sounds like a flat battery or some how your circuit is drawing too much current and is exhausting the battery
 
MCLR disabled, didn't change anything, but hey it's made my bread board neater.

I added a resistor to the LED - I originally had one, then took it out for doing some PWM experiments and now that it's back in it appears to be working correctly, which is great!

Thank you for your help.
 
4AA? Like alkaline batts?
6v is too high for a PIC when they're fresh. You need an LDO 5v reg.
 
most of the time I've been using the PICKit as the PSU, I think I have been using this PIC for about 10 hours before I even attempted yo use batteries.

I originally tried with 3 fresh batteries, but at that time it wasn't working, so I tried with a 4th.

The chip isn't getting hot, so it should be allright, shouldn't it?
 
Not necessarily..
 
Not necessarily..
really? could you explain why?

They don't go in to that sort of thing at uni, or at least not in the first 2 yrs, perhaps not in my course at all, possibly in the Electrical and Microengineering.

blueroomelectronics said:
VPP to VDD resistor from 4.7K to 47K
Also you will need a 0.1uF cap as near as possible to the PICs VDD & VSS pins. It is necessary.

Is the VPP pull-up resistor necessary? I have disabled MCLR in the fuses.

What about the cap? is that necessary to stop damage or provide stability?
Can I omit it whist I'm bread boarding and include it in the PCB? (assuming I get around to making one)

EDIT: PS. I'll be away until Sunday, so I won't respond until at least then.
 
Last edited:
I went through this same problem and it was the lack of decoupling caps on VDD/VSS pins. I had a seven-seg hooked up and instead of counting up sequentially, there was some jumps to random numbers. I changed the code to flash the decimal point at the beginning of the program outside of the loop, which let me know when the PIC reset. It was pretty obvious after that point that swings of the power rail were causing the PIC to brown out.

BTW I use the pickit 2 for power to the target breadboard and it works fine.
 
Last edited:
Problem with internal MCLR and internal OSC is it can become tricky to reprogram. You still have to tie MCLR to something else it's a floating input pin.
 
Macka, there are different types of failure. There are thousands or tens of thousand of transistors that can fail on a micro controller, or more. ONE failure in the wrong spot can cause the chip to cease to function, not all of them will cause the chip to get hot =\
 
Last edited:
Macka, there are different types of failure. There are thousands or tens of thousand of transistors that can fail on a micro controller, or more. ONE failure in the wrong spot can cause the chip to cease to function, not all of them will cause the chip to get hot =\

Ok, fair enough.

Problem with internal MCLR and internal OSC is it can become tricky to reprogram. You still have to tie MCLR to something else it's a floating input pin.

How come it becomes tricky to reprogram?
Does it matter if it is floating if the pin is not utilised?
 
I unfortunately do not have a stock of components, I have only ever bought what I've needed when I needed it. I think I need to find a good, cheap kit of assorted resistors and capacitors.
This place has pretty good prices:
Value Packs
 
This place has pretty good prices:
Value Packs

:O hose prices! :O I'm stunned, they're... brilliant!
I can't walk in to any electronics store in Australia and find prices like that!

and the shipping is sooo cheap :O
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top