I have built a low-current motor controller for my Atmega8 controller based on the L293D chip (I also built a high-current controller based on the L298N chip). It works fine except that it needs three pins per channel to control bi-directional motors using PWM (total of 6 pins for 2 motors). The logic of the L293/L298 is such that:
FORWARD:
input1 =H
input2 =L
enable=H (PWM)
REVERSE:
input1=L
input2=H
enable-H (PWM)
BRAKE:
input1=input2
FREE-ROLLING-STOP:
enable-L
I don't need active brake and wanted to reduce the number of pins required to control the motor so I ordered a SN74HC14N inverter chip to add an inverter circuit before the motor controller. I plan to input the the output of one of the ATmega digital pins so that it is inverted (input=H(5V)=0, inputL(0)=~5V). By feeding the output of the digital pin to input1 of the motor controller, and feeding the output of the converter to iinput2 (digital pin output inverted), I should be able to control the direction of the motor with 1 pin from the ATmega. I think this is how the motor control is implemented on the Aduino motor shield V3 which uses the same L293 controller chip and only requires 1 input for motor direction per channel (DIRA or DIRB) along with the PWM signal.
Any thoughts on how well this will work or any gotchas I need to be aware of?
The circuit I built for the L293D is straight out of the Spec sheet for bi-directional motor control. Same with the L298N circuit, adding 1AMP fast recovery diodes as recommend.
Here are the links for the spec sheets of the ICs I am using:
Inverter chip:
http://www.ti.com/lit/ds/symlink/sn74hc14.pdfL293D:
http://www.st.com/web/en/resource/technical/document/datasheet/CD00000059.pdfL298N:
http://www.st.com/web/en/resource/technical/document/datasheet/CD00000240.pdfAs a side note, I have used the output of a single PWM pin as input to the enable pin of both channels on the motor controller. This gives me synchronized speed control of both motors and only uses 1 PWM pin on the ATmega. I know this works as I have successfully tested it. Is there any reason why I shouldn't do this other than the limitations on available rotational speeds on the different motors?
Using these methods, I hope to gain bi-directional PWM control of 2 motors using only 3 pins on the ATmega. I have done this successfully using the Arduino Motor Shield and my ATmega controller. This will give me syncronized forward, reverse, and rotation in both directions, which is all I need for this portion of the project.