PWM motor drive makes PICAXE reset

Jack Hale

New Member
I've made a MOSFET H bridge circuit to drive model railway trains.
I'm using a 18M2+ to generate PWM pulses to drive the bridge transistors via 74 series logic chips. The form of the program is to perform some initial setup and then go into an infinite loop generating the PWM pulses.
The first circuit I built works OK, but then I built another, apparently identical, and it misbehaves. It runs for a short time (mostly less than a second) and then the program restarts.
I should add that it works fine when I use it to drive another small brushed DC motor, so maybe that points to something to do with the inevitable poor connection between model train wheels and track?
I've tried swapping PICAXE chips - no difference.
The only reason I know for the PICAXE to restart like this is loss of power, but I've looked at the 5V supply to pin 14 and it looks rock steady.
Has anybody any ideas for what can cause this behaviour?


New Member
I assume you have the serin/serout programming pins wired correctly - if not, that is the place to start. However, a reset can certainly happen if there is a spike on the supply - often caused by motors. Have you got a 0.1uF capacitor across the power supply pins of the Picaxe? It needs to be physically as close to the Picaxe as possible


Senior Member
When you interface any reactive load to a digital controller, there is a whole range of things that can go wrong. As Aries mentions, capacitors across all microcontroller's power pins is essential. Also, put a similar capacitor (at least 100v working voltage) across the motor terminals. Then if the motor and processor share the same power source, ensure that the processor and motor have separate wires all the way from the supply ("star fashion").

Jack Hale

New Member
Thanks Aries for your very fast response. That works. I had the capacitor, but evidently not close enough to the Picaxe terminals.
And thanks also Inglewoodpete. I've not got a capacitor across the motor terminals. I'll try adding one.


Senior Member
I wish placing capacitors would solve your problem ; that's a good practice. It did not work on our circuit driving a robot in PWM mode. The working solution was to supply separately the microcontroller side using a diode and a large capacitor (470/1000µF), so low voltage drops would not affect the MCU side (half-wave rectifier alike circuit).

A short story : we had several robots running for years using 20M, no PWM. The day we retrofit the board with 20M2, we had repetitive reset, probably due to the different brownout parameters of 20M2. Not having time to investigate further, we add the modification described above (diode + capacitor) with success.