# PICAXE crashes when running L293D Motor Drive

#### Jakeeh9

Joined Nov 28, 2019
12
I am trying to run motors using a PICAXE and an L293D motor driver.

I have no choice to use a PICAXE, as this is for a exam project.

I assumed that since the motor driver relies on logic to control the motors, then I would be able to connect the PICAXE outputs straight to the motor driver inputs. This cause me lots of problems, and I assumed it was because the motors were causing the voltage to drop. When I tested this with an oscilloscope, I found that was a problem. I used a capacitor across the voltage rails to smooth the voltage, and it kind of worked, however the PICAXE was still crashing. I tried connecting the motor driver to a different power supply, so that it wouldn't cause any interference with the PICAXE supply.

This still didn't solve the issue, so I assumed that the logic inputs of the motor driver were taking too much current from the PICAXE outputs. I didn't understand why this would be the case, as the inputs of the motor driver aren't what are controlling the motors. I tried putting a voltage follower inbetween the output of the PICAXE and the input of the motor driver, and this kind of worked a few times, but... then it didn't work

I've run out of options to try, and I still don't understand why it's not working. The way I see it is that the inputs of the motor driver are just logic inputs, so shouldn't need much current at all, and shouldn't be causing the PICAXE to crash.

Just to make this post even longer, I have tried testing the logic using an oscilloscope when the motors weren't connected to the motor driver, and the logic worked perfectly. There was nothing wrong with how it was working, until I added the motors back in.

Sorry that the post was long, but hopefully there's enough information and someone will be able to help me fix this problem.

#### BobTPH

Joined Jun 5, 2013
3,025
How is it built? Breadboard, stripbboard, PCB?

And are the power and ground paths to the motor and PIC kept seperate using a star topology?

Photos of the construction and a schematic might help.

Bob

#### Jakeeh9

Joined Nov 28, 2019
12
It is built on breadboard, and I have attached a picture of it.

I'm not sure what you mean by star topology (sorry). I've heard the term before but have no idea what it means in these circumstances.

In the picture, I had to draw on the motors as I seem to have misplaced them... Oops.
The problematic area is outlined in green. Hope this information would be helpful.

#### AlbertHall

Joined Jun 4, 2014
11,165
You should connect capacitors across the supply pins of the picaxe with the shortest wires possible, that means over the top of the chip in this case. Try 100nF and 47uF together.
Note that abreadboard is not a good way to build such a circuit.

#### ronsimpson

Joined Oct 7, 2019
1,166
Every inch of wire has resistance and inductance. You have ground wire motor current flowing on the top and bottom of the board and they are only loosely connected together. Motor current in the red wires to. Stripboard have large amounts of resistance. I an certain motor causes strange voltage drops all over your project. The voltage on the PICAXE drops down to where it resets.

I would connect the power and grounds on the top to the bottom several times as shown. Then add more capacitors. Your motors are probably pulling too much power and the wires to the power supply are too long.

#### Jakeeh9

Joined Nov 28, 2019
12
You should connect capacitors across the supply pins of the picaxe with the shortest wires possible, that means over the top of the chip in this case. Try 100nF and 47uF together.
Note that abreadboard is not a good way to build such a circuit.
I know that breadboard isn't the best for building things, however it's an A-Level project, so there are certain things that we have to do, such as use breadboard. Another thing is we have to use a PICAXE microcontroller, even though things like arduinos are generally better.

I'll try the capacitors and hopefully that would work

#### Sensacell

Joined Jun 19, 2012
2,761
The breadboard is a big problem, as many have stated.

As soon as you have heavy currents flowing - things start to go haywire due to the high resistance and inductance of the breadboard.

One way to work around this problem would be to fabricate a "backbone" for both power and ground lines.
Take a thick (16AWG) bare copper wire, solder smaller spurs of #22 wire every few CMs along the length. (like barbed wire)

Plug these into the power and ground busses along the top and bottom.

Don't forget bypass capacitors on EVERY CHIP - as close as possible to the power pins.
Ceramic capacitors!

#### Hemi

Joined Mar 17, 2012
18
Have you left the Serial IN pin on the PICAXE (leg #3) floating as shown in your pics? That will cause the PICAXE to reset randomly. That pin needs to be tied to ground using at least a 100K resistor. Or leave the programming circuit in place (the 10K and 22K resistors).

#### BobTPH

Joined Jun 5, 2013
3,025
Wire the power and ground pins to the L293D directly back to the power supply, do not connect them through the busses on the breadboard. Also, the capacitor for the PICAXE is an absolute requirement. Also place a tank capacitor or 100uF or so where power comes in to the breadboard.

The first time I tried running even a small motor controlled by a PIC, it crashed every time the motor turned off. This was on a reasonably designed PC board, far better than the breadboard construction. I fixed it be running a separate ground wire for the motor.

Bob

#### Hemi

Joined Mar 17, 2012
18
A couple more suggestions.
I know for a fact that the PICAXE is perfectly capable of driving the L293D pins directly - you can get rid of the op-amps, they're just adding unnecessary complexity. I can't determine the pulldown resistor values on the L293D's inputs (colorblind), but >=10K are sufficient. Put a 0.1uF and 10uF cap as close to + and - pins on the PICAXE as possible.

Code:
#terminal 4800
pause 2000
sertxd (13,10,"Started!",13,10)
This will show you in in the PE terminal if/when the PICAXE is resetting.

Also, the L293D uses the 4 ground pins on the chip for heatsinking. Make sure the motor you're driving isn't drawing a lot of current as the jumper wires on the breadboard won't keep that chip running cool for very long.

#### Jakeeh9

Joined Nov 28, 2019
12
Have you left the Serial IN pin on the PICAXE (leg #3) floating as shown in your pics? That will cause the PICAXE to reset randomly. That pin needs to be tied to ground using at least a 100K resistor. Or leave the programming circuit in place (the 10K and 22K resistors).
I didn't not know this! I have not get any resistors there, so I will add that.