Arduino Micro & H-bridge (L293D)

Hi,

In my project, i try to control two dc motors using PWM. The motor will create the flapping motion of wings by rotating clockwise and anticlockwise alternately.

First i generate two pairs of PWM using arduino micro. Then i pass each pair of pwm into pin 2 and 7, and another pair into pin 10 and 15 of L293D. The dc motor can operate in the voltage range of 3-5V. So i connect the enable pins (pin1 and 9), Vcc1 and Vcc2 to the 5V pin of Arduino Micro. I think all connections are correct.

For the pwm, the frequency is 5000Hz. According to my code, each pair of pwm will make up a sinusoidal-like cycle. Let say one of the pwm is P1 and the other one is P2. So at first P2 has zero duty cycle and P1 will start from zero duty cycle and increase to a greater value after some time and eventually increase to maximum (100%). Then P1 will decrease step by step until zero. After that P1 will stay at zero and P2 will repeat the same process as P1. Basically if i pass P1 and P2 into the input pin of L293D, the output from L293D will produce signal to the motor which is like a staircase going up and down.

What i get:
Both wings are able to flap at the correct frequency when i set the maximum duty cycle to 100%. But when i reduce the maximum duty cycle to 50%, the wing could not produce stable flapping amplitude, but correct frequency. When i try to offset the motion, by setting P1 to completely zero, and setting P2 to have stepping up and stepping down duty cycle (all above 0%), the wing could not move as predicted. It should be flapping above the equilibrium position since the voltage to the motor is like just from one direction but different amplitude. But what i get is the wing still flapping across the equilibrium position.

When i check using oscilloscope, the signal produced by the H-bridge output contains very high noise level. I am not sure if this is normal, because i think i should get a signal similar to the the signal output from the Arduino Micro which is pretty neat and the PWM waveform could be observed easily.

Any suggestion? or improvement i could make to produce a better output from H-bridge.

Thank you.

WeeSiang

The old L293D can be used with 12V motors.
It will not work with 3V motors and with 5V motors it will work a little.

Normally the input pins are used for the direction, and the enable is used for the PWM signal. See the datasheet for the direction.

Do you use the 5V output pin of the Arduino Micro to power the motor ? The Micro can not supply enough current for that.

Thanks Erdin,

Yes i think you are right with the direction and pwm pins. i will try to change the code and test tomorrow.

Thanks again.

Also check the datasheet of L293d, VCC2 is supposed to be greater than Vcc1