Electronic – PIC pins change state when DC motor connected

dcmotoroutputpic

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.

Update

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.

Best Answer

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.