I'm new to PIC programming, and having trouble getting getting it control a DC motor. It's a PIC18F25K22, and a TI L293D driver. Power is suppliued by a 5V linear regulator connected to a desktop power supply. I've setup the PWM correctly, and it drives when I directly connected to the ground and power rails, however I get strange behavior when I connect PIC pins to the control pins of the L293D. A circuit diagram is shown below.

enter image description here When unconnected, pin RC1 is low, and pin RC3 is high (0.0V and 5.0V respectively). When connected, RC1 rises to about 0.25V and RC3 falls significantly to 0.42V, as my multimeter says. The L293D has internal diodes, and I've put capacitors on either side of the motor to ground. The pins on the L293D draw a max of half the current a PIC pin can supply. I'm new to both PICs and motors, so it could be either.


I connected the inputs and enables of the other half of the L293D to ground, and used ground and power to control and enable to half I am using. This produced expected results. Leaving the 1,2EN pin connected to 5V, I connected the PIC pins again. This time, the motor turns, but sluggishly. I recorded the following voltages

1Y = 1.03V 2Y = 0.34V 1A = 0.84V (PIC pin, set high) 2A = 0.0V (PIC pin, set low)

This is being built on a breadboard currently.

  • \$\begingroup\$ Can you post how this is wired (PCB or breadboard?, what it looks like?). Motors can create all sorts of inductive coupling shenanigans. \$\endgroup\$
    – Mark
    Feb 23, 2013 at 6:16
  • \$\begingroup\$ www.ti.com/lit/ds/symlink/l293d.pdf \$\endgroup\$
    – Spoon
    Feb 23, 2013 at 9:54
  • \$\begingroup\$ The L293D has 2 supplies... both need to be connected. Vcc1 is the logic supply and needs to be clean, Vcc2 is the motor supply and can be much higher and not as clean. Connecting both together is not recormended as the motor can cause noise in the logic supply and then predictability goes out the window \$\endgroup\$
    – Spoon
    Feb 23, 2013 at 10:10
  • \$\begingroup\$ @Mark It is currently on a breadboard. \$\endgroup\$ Feb 23, 2013 at 21:48
  • \$\begingroup\$ @Spoon Thanks for the link. I do have both connected, and to the same supply. Unfortunately, I can't use a separate supply. \$\endgroup\$ Feb 23, 2013 at 21:50

1 Answer 1


My guess (there's not really enough information for more than a guess) is that the 5V supply rail is collapsing when the motor turns on (motor may be stalled, too powerful for your supply, etc.). To troubleshoot this further, break the problem down:

First, disconnect the PIC and the motor and just focus on the driver chip. Make sure ALL the inputs are defined (pulled high or low) - even the inputs you aren't using. Make sure any outputs you aren't using are floating. Now, with 5V on the Vcc of the driver, take the EN pin high, toggle an A input, and verify that the appropriate Y output goes high and low following the A input. Do that for both A inputs. If it doesn't work, record the voltages on ALL the pins (supply, input, output, even GND in case you miswired something) of the driver and report them here.

After that's working, connect the motor, toggle the A inputs again and verify that the Y outputs change as before and that the motor turns as expected. If it doesn't, record the voltages on ALL the pins of the driver (particularly the Vcc pins) and report them here.

Next, connect the PIC, and repeat the above procedure with the PIC driving the pins.

If you go through it methodically, you will find the problem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.