14m losing its program periodically

Peter-C

Member
I have a 14m on a professional pcb which uses three inputs for temperature via DS18B20. 3 outputs operate LCDs and two run MOSFETS to switch pump loads of < 1 amp each. Diodes to prevent possible Backfeed from the pumps are in place after the FETs.
I have made many of these circuits without problems but I have one user who is finding that the PIC program is corrupting every few weeks. A cold restart does not help, the program no longer runs or runs incorrectly and the only cure is to reprogram the chip.
The SERIN is tied down correctly with 22k and 10k and the power supply is through a 7805 regulator.
I'm running out of ideas and can only think to add a chunky capacitor (100uF?) to the power in and tie the two unused inputs low with 10k resistors. Can anyone suggest what might be causing the program to corrupt in this way and any possible remedies?
 

BeanieBots

Moderator
I've had exactly the same issue.
It's caused by high current spikes. They in turn cause large voltage spikes and or electro-magnetic radiation. It will be your pumps causing it. In my case was a flourescent lamp. In my case, the corruption was obvious. ?hard coded menu items suddenly displayed different or corrupt characters the next time it was reset!

There is no single cure but there are two main areas to concentrate on.
Firstly, wherever possible, prevent generation of the noise in the first place.
If the FETs just turn on the pumps (NOT PWM control), then add a small RC to the FET gate to reduce transients. The time constant should be in the range of 100's of uS maximum, 10uS minimum.
(just an R will probably do. Check the datasheet for gate capacitance value).

The second line of attack is to prevent the noise getting back to the PICAXE.
There are obvious measures such as good decoupling at both the PICAXE and the regulator but also consider radiated noise. Screening and cable layout will have significant effect.

In my case, it was when the lamp (activated by a relay) turned off that my PICAXE sometimes reset and sometimes became corrupt. The DS18B20 leads ran quite close to the lamp mains leads. Seperating the leads cured the problem but was not an option in the final installation.

I required two mods to fix the problem.
First was to add a capacitor and resistor in series across the relay contacts.
That significantly reduced the switch-off voltage spikes at turn off.
The second was to add ferrite beads to the DS18B20 leads close to the point of entry into the metal box housing the PICAXE.

Good luck, noise related problems can be quite tricky to cure.
 

moxhamj

New Member
BB - that is a wealth of experience in that one post!

Re "The second was to add ferrite beads to the DS18B20 leads close to the point of entry into the metal box housing the PICAXE."

Yes, that was the solution that worked for me too. And to move the object being switched at least a metre away from the picaxe in its metal box.

Interestingly, the picaxe resets quite frequently when switching pumps nearby and when switching a relay which in turn switches flouro lights. But it seems to be quite ok in the engine bay of a car.

I've also resorted to intermediate circuits. Eg a pump does not like being switched on and off frequently, so one solution is for the picaxe to switch a 555 and the 555 then stays on for a fixed time before it can be turned off again.
 

Peter-C

Member
Thanks BB, (and Dr_Acula) for such a prompt and full response. Its reassuring to find others who have suffered and won! The Ferrite rings are simple so I'll start with that.

I want to try your suggestion of the RC across the gate of the FET as I feel sure the pumps must be the source of the problem. I have not experienced it in similar circuits using different pumps.
I am in learning mode and beyond my level of understanding here and I plan to run the resistor and cap. across the power leads of the pump, but I don't know how to calculate the values for the components. Is there an easy formula for this, or even a stab in the dark suggestion?

I am using a plastic project box, would metal shield the circuit better?

Your advice is much appreciated.
 

eclectic

Moderator
@Peter-C
I can't offer any advice, but,
what is "one user"'
doing differently to all the others,

that "breaks" his Picaxe?

e
 

Andrew Cowan

Senior Member
I want to try your suggestion of the RC across the gate of the FET as I feel sure the pumps must be the source of the problem.

I plan to run the resistor and cap. across the power leads of the pump...
Putting them accross the gate will stop interference coming back into the PICAXE.

As long as you are not PWMing the FETs, try using a 10K resistor and a 0.47uF capacitor.

Just a stab in the dark!

A
 

BeanieBots

Moderator
What values for R & C?
A good question but not too easy to answer without getting very deep in maths.

By adding an RC to the FET gate, it increases the time taken to come on and switch off. You need to be careful here. If the RC value is too high, the FET will spend a lot of time in linear mode which could cook it.

As mentioned earlier, the time constant should be in the range 10uS to 200uS.
An RC time constant is quite simply the resistance multiplied by the capacitance.
If we take Andrew's suggestion of 10k and 0.47uF, that would give us 0.0047S or 4700uS which IMHO would be far too high and could compromise the health of your FET. Depends a lot on how much current you are switching and the thermal mass of the FET junction.

I's suggest 10k and 10nF for FET transient suppression.
Also, the gate has it's own capacitance which needs to be taken into account. The datasheet will tell you what that is. Subtract it from the capacitance you add if it's significant in comparison.

What type of motor do the pumps use?
Maybe add suppression to them (right up close) if they are brushed type.

Impossible to suggest series values for switch supression without knowing the load. Don't forget, the components also need to be rated for whatever the supply is and the worst case surge current which could be TWICE the supply voltage (capV + SupplyV) at whatever current determined by R when the contacts close. (in your case a FET, so watch for FET surge current, again, that can be found in the datasheet).
"Typical" values would be several ohms and around 1uF.


@Dr_Acula.
I doubt the pump on/off duration is the real culprit rather that adding a time delay reduces the "odds" on hitting a peek surge if it's a mains pump.
Without using a zero-crossing type switch, it's 'luck' and 'odds' when the cycle gets a 'hit'.

During my flouro problems, I cycled at 0.5Hz to 'repeat' the problem.
Dropping down to once every 30 seconds 'masked' the problem but it was still there 'waiting' to happen and did so once or twice an hour until the beads were added as well. If you only cycle once or twice a day, it could be a few months before you get 'hit' again but the potential is still there if frequent cycles still show an issue.
 

Andrew Cowan

Senior Member
How often is it switching on and off? At under 1A, if switched on and off once an hour, the thermal energy built up from 0.0047S of linear mode should easily be disipated.

A
 

BeanieBots

Moderator
0.0047S is probably perfectly fine.
As stated, it all depends..... in particular, how close to the 'limit' is the FET being run? (as apposed to absolute current).
Run PWM with that value and it's almost certain doom, (unless very low current).
 

Peter-C

Member
As part of the earlier attempts to nail this problem I have resorted to using bigger TO220 FETs rated at 30A,(STP36NF06L) for a load probably around half an Amp, so presumably I won't have to worry about frying them with too high a cap?

Thanks for all the explanation and suggestions, it is evidently a highly complex area I have stumbled into. I'll see what effect the 0.47uF and 10K R has.

I suspect the best answer is to get him to change his pumps to the ones I provide!
 

BeanieBots

Moderator
As a general rule, the bigger the FET, the bigger the internal gate capacitance, so the LESS external capacitance required.

A 30A FET running at ~0.5A driven with a 0.005S slew rate should be perfectly safe.

Yes, noise issues is a highly complex area.
 

nbw

Senior Member
I second the R-C. I have some grunty metal halide lights and (in particular) T-5 fluoros over the fish tank that when they go off (latter) and go on (former) generate nasty spikes. The 16x2 LCD used to show odd characters all of a sudden. Sometimes the 40x would shrug and give up. Not nice.

Shielding and R-C helped in my case (no pun intended), and I kept the optoisolators / mains wiring at a good distance from the sensitive electronics board. I also put an EMI filter and a MOV of course on the incoming power supply to filter out most nasties coming in that way. We had over 190 lightning strikes here yesterday. Every little bit of protection helps :)
 
Top