18X forgets program - intermittently

crossthreaded

New Member
Well, it's happened twice.

I have a strip-board and wire prototype board which is, frankly, built from my scrap box. It has a socketed 18X, connectors for servos, an analogue sensor and the serial programming cable, 2 LEDs (one is just power) and three buttons (one is reset). The 18X is powered from an emitter follower circuit with a zener reference and runs about 3.3V. The 18X power is coupled with a parallel capacitor to remove any big lumps but there isn't a separate decoupler.

The only "bad" thing I think I'm doing, other than not having a proper on-off switch and just plugging in the 4 cell nicad to add power, is that the servos have direct connections to PIC pins rather than through resistors, which I thought might be better for them since the PIC has a reduced voltage compared to the servos, which run straight off the battery.

On two occasions (from a sample of ~40) I have had the circuit running with a program, removed power, restored power (within 10 minutes) and had the PIC act asthough there was no stored program. Subsequent connection to the serial lead and downloading (the same) program in this state proceeds normally and restores function.

Is there some strange combination of power transition and reset switch that could cause this to happen? How complex is the serial line handshake which signals the PIC to clear program memory?
 

BeanieBots

Moderator
I doubt that setup is causing a memory clear. I have had it happen (memory curruption) but only when playing with seriously high emi.
Double check that your serin is not left floating when the cable is removed. Also double check that no inputs referenced in your code are left floating.
 

hippy

Ex-Staff (retired)
The 18X (16F88) should be operated on a supply of between 4V and 5V5. They can run lower than that but it is outside specification. It would definitely be recommended to perform downaloding with a voltage of 4V or more.
 

moxhamj

New Member
4 nicads and a 3.3V supply. I'm wondering if there is another way to do that. 4 nicads unregulated can go from 4.4V to 6V. And 3.3V is under spec as hippy says.

Personally I prefer regulated 5V, but I appreciate that might not be possible due to weight etc.

Manuka likes 3 AA batteries.

Many radio controlled cars go for a 9V battery to run the electronics (eg 5V low quiescent reg), and then run the motors/servos etc on a seperate power supply eg 4 nicads.

If you are reading analog voltages then there are lots of advantages to running off a regulated supply.

For a picaxe driving a servo, the servo current might be hundreds of times the picaxe current. So the optimum battery size is for the picaxe battery to be hundreds of times smaller than the servo batteries. So tiny rechargeable button cells or N cells etc could run the picaxe and only add a tiny amount of extra weight.

What is your application?
 

crossthreaded

New Member
The application is a small, light and cheap hexapod - although I've used the controller circuit in other similar applications. The voltage was chosen because I had the zener in my bit-box and the datasheet (i.e. picaxe manual 1) says that 3 to 5.5 volts is OK, but that programming at 3V might cause problems.

I isolated the PIC supply from the servos because I was using a 2-axis accelerometer in a prevous robot and I needed accurate PSU regulation for that to work precisely enough. I did wonder if the problem was due to the nicads being low, but measurement suggests that the voltage regulator was still operating with a big margin.

I spent some time last night jiggling the board and the battery connector, to see if I could deliberately reproduce the problem, but it worked perfectly.

I'll be developing on this platform for some time, as I add sensors to the robot, so it should get plenty of opportunity to go wrong again if it's going to. I'll report if any correlations come out of the analysis of the problem.

Thanks for the suggestions so far.
 

crossthreaded

New Member
Two more occurrances of an apparently forgetful 18x, but I' beginning to suspect that the power supply may be the critical factor. I've measured the supply from my voltage regulator as 3.4v, but I forgot to retest it when the fault happened. I'm beginning to correlate the failures, mentally, with extended runs of the robot, which may be depleting the aging nicads a little too far.

I also noticed that my bit-box only delivered a 27k resistor when I was building the download circuit. I'll correct that before I complain again.

Whatever the problem is it leaves the 18x receptive to another download without needing a reset, so the chip is running something, just not my program.
 

Andrew Cowan

Senior Member
If you don't want to put servos on an isolated supply, then I recommend some bigish capacitors across the power lines. I had a project with a servo, and the backlight would always dim whenever a servo first moved. A 1000uF capacitor across the power solved that.

You can also help partially isolate the supply buy having an input (eg 9V with caps), then use two 7805s - one for the PIC and one for the servo.

Hope this helps,

Andrew
 

crossthreaded

New Member
Thanks Andrew. I have a power indicator LED and I generally take its flickering as a sign that the nicads are getting a bit low. They're only half AA size, so not much capacity (that, and they are getting old). I might try and source a low voltage, high value cap, just to improve the power regulation. Currently I use a gait for the hexapod that only moves one servo at a time, which helps too.

I spent part of the afternoon calibrating the photodetectors and the robot pirouettes really nicely.
 

Technical

Technical Support
Staff member
Is there some strange combination of power transition and reset switch that could cause this to happen? How complex is the serial line handshake which signals the PIC to clear program memory?
On the second question the handshaking is fairly complex, it is not likely that a 'corrupt' program is being downloading by mistake.

The first is far more likely with your out of spec batteries. If power on any i/o pin is higher than the PIC supply pin, strange leakage can occur, where the PIC starts to draw power via the input pin. This is because of in built diodes on the i/o pins.

In this situation you will get strange interaction between the reset pin etc. and it is likely the chip will enter a reset state.
 
Top