Shop OBEX P1 Docs P2 Docs Learn Events
PWM with H Bridge — Parallax Forums

PWM with H Bridge

azmax100azmax100 Posts: 173
edited 2007-03-30 16:23 in General Discussion
Hi all.

Just a question to make sure.

Is it posible to control·the speed of a motor with H bridge·by using·PWM or just use Hi/Low command?

Thanks for the answer.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-28 15:54
    An H-bridge just turns the motor on and off in either of the two directions. The PWM statement varies the average amount of time spent on and therefore the speed. You'll typically control the direction with a HIGH/LOW signal.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-02-28 16:26
    Yes, it's possible, if the H-bridge IC you're using has an enable input. ST Micro's L6203 is an example. It not only has an enable input for modulation by a PWM signal, but it has a sense pin for attaching a current sense resistor. With a low-value resistor attached between this pin and ground, the voltage on the pin can be used as feedback to the PWM controller.

    -Phil
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-03-01 01:35
    As a note the PWM command on the BASIC Stamp isn’t really designed to drive an H-Bridge and will not continuously pulse the pin. The PWM command was designed to generate an analog voltage using a filter. The PWMPAL, linked below can drive the H-Bridge in the manner you need. Take care.

    http://www.parallax.com/detail.asp?product_id=28020

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-03-01 03:51
    You might also consider Parallax's MoBoStamp-pe, which includes a BS2pe chip and two onboard coprocessors. With the pre-installed GPIO3 firmware, each coprocessor can sustain two PWM outputs at up to 37.5KHz, as well as perform A/D conversions to 10 bits of precision and event/frequency counting to 1MHz. The coprocessors respond to simple commands from the onboard BS2pe via its OWOUT statement.

    -Phil
  • azmax100azmax100 Posts: 173
    edited 2007-03-01 09:18
    Hi everybody.

    Thanks for the reply.

    Phipi said :"Yes, it's possible, if the H-bridge IC you're using has an enable input. ST Micro's L6203 is an example."

    How about if I use this(attached Photo) H Bridge. It use L298. can i send PWM to this H bridge to control the speed. I try to get the Hb25 but it seem too expensive here in my place.(USD 160 for 2).

    I'm stuck here for my robotic project.·I·don't want to use servo cause it's too slow.

    Thanks·in advance for your answer.
    640 x 480 - 30K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-03-01 09:46
    The L298 should work fine with a PWM speed control signal, since it has enable inputs. It also has sense pins, in case you need to monitor the motor current.

    -Phil
  • azmax100azmax100 Posts: 173
    edited 2007-03-01 10:05
    Thanks Phil.
  • legiondttmlegiondttm Posts: 4
    edited 2007-03-29 22:55
    I have built my own H-Bridge. If I just pulse one of the inputs to the H-Bridge, wouldn't that work just the same as pulsing an enable?

    Like this:

    Input 1
    Input 2
    --0
    1
    --0
    0
    --0
    1
    --0
    0

    Post Edited (legiondttm) : 3/29/2007 10:59:58 PM GMT
  • T ChapT Chap Posts: 4,223
    edited 2007-03-30 01:42
    If one input is for one direction, and the other is for the other direction, then yes you can pulse the pin and affect the speed. There are IC's you could use that would allow external PWM at whatever Frequency and Duty you wanted. A very easy solution would be to add an SX20/28 to your project, they are easy to program and are very cheap. You could let the SX be the PWM engine, just send it a serial input with the info, or use some parallel pins between the Stamp and SX that translate into duty. For low resolution, you could use 4 pins between the two, the SX uses those pins to scale 1 to 16 vaues for duty.

    Post Edited (TChapman) : 3/30/2007 3:55:01 AM GMT
  • legiondttmlegiondttm Posts: 4
    edited 2007-03-30 15:46
    I went to the lab today to test out the PWM. It works fine to pulse the inputs rather than a chip-enable. Though, I did make my H-Bridge using discrete darlington-pair transistors instead of using a chip, but I doubt that would make any difference.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2007-03-30 16:23
    Generally, the PWM would be used to reduce the speed in an H-bridge. And it might even control the amount of acceleration or deceleration. But, the PWM requires that the BasicStamp be occupied with producing pulses. If you can use the H-bridge without the PWM, the BasicStamp will have more free time to manage sensors.

    In sum, H-bridges [noparse][[/noparse]when properly designed and matched to the motor] will usually take full on; full off; or pulses.

    IT depends on what you want.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Sign In or Register to comment.