-1
\$\begingroup\$

I wonder, if I can control the speed a motor by applying PWM on VCC pin at H bridge, not at control pins. I try to do this with an Arduino microcontroller but the output will always be 5 volts!

\$\endgroup\$

closed as unclear what you're asking by Olin Lathrop, Joe Hass, Leon Heller, Matt Young, PeterJ Jan 11 '14 at 0:25

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    \$\begingroup\$ A schematic would be helpful. \$\endgroup\$ – Turbo J Jan 10 '14 at 20:39
  • \$\begingroup\$ What kind of H bridge? Transistors, mosfets, IC? A schematic would help. \$\endgroup\$ – alexan_e Jan 10 '14 at 20:41
  • \$\begingroup\$ @alexan_e mosfets are not transistors? :) \$\endgroup\$ – Diego C Nascimento Jan 10 '14 at 21:24
  • \$\begingroup\$ @DiegoCNascimento Maybe when they grow up :-))). I meant BJT vs mosfet \$\endgroup\$ – alexan_e Jan 10 '14 at 21:54
  • \$\begingroup\$ the h-bridge that i used is IC : "h-bridge l293" @alexan_e . \$\endgroup\$ – user3137879 Jan 11 '14 at 18:52
5
\$\begingroup\$

H-bridge usually has 3 pins for every motor. 2 pins are used for control, the third is normally labeled "E" which stands for Enable.

If you want to control the direction of rotation all you have to do is change the logical inputs to the 2 control pins. While on the other hand to control the speed of rotation you have to connect the Enable pin to one of the (PWM) pis on the arduino.

The Top left and bottom right switches are connected together for 1 control pin. While the top right and bottom left switches are connected together for the second control pin.

The Top left and bottom right switches are connected together for 1 control pin. While the top right and bottom left switches are connected together for the second control pin.

As to control the speed, look at the following table:

Note: that the enable pin has always be connected to a high volt (5v) to one of the digital pins

Now If you want to control the speed, all you have to do is connect your Enable pin to one of the (PWM) pins on the arduino.

In the arduino IDE write the following:

analogWrite(PINNUM,***)

Subs "PINNUM" by the pin number by which you've connected your Enable pin.

As for "***" write a number between 0-255

Note 255 is equivalent to applying 5v directly which will result in the max speed. Note: 0 is equivalent to applying 0v directly which will result as stated earlier in switching the motor off.

Any value in between will change the speed.

\$\endgroup\$
  • 1
    \$\begingroup\$ This is a very nice answer. Although OP did not ask about it, some discussion on where flyback diodes would be placed in an H bridge configuration would be the only "improvement" I would make to what you have supplied. I only mention it here so that readers will know to use a search engine to look it up. Like maybe in the first scematic on the first page of this: hades.mech.northwestern.edu/images/8/84/ProjectW2011.pdf \$\endgroup\$ – mikeY Jan 10 '14 at 22:12
  • \$\begingroup\$ thank you for you're explanation but my idea is : to connect "Motor power" pin on you're schematic by PWM , furthermore , i want to control the speed of motor by the value of power that delivered to motor . I know that is weird , but it's possible , is it ? \$\endgroup\$ – user3137879 Jan 11 '14 at 18:42
  • \$\begingroup\$ @user3137879 Actually, when you apply a PWM to the enable pin, you are actually changing the applied voltage. For example, if you applied 50% duty cycle -that is writing "analogWrite(127)", is like applying 0.5*Max voltage of motor. Say you're motor's voltage is 12V >> applying 50% duty cycle, is like applying 6v to your motor. This will cause half the speed of the max speed of your motor. Change the duty cycle accordingly, therefore you're changing the applied voltage or "Motor power pin". \$\endgroup\$ – Adel Bibi Jan 11 '14 at 22:03

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