Shop OBEX P1 Docs P2 Docs Learn Events
Creating PWM signal similar to RC receiver using a BS2px — Parallax Forums

Creating PWM signal similar to RC receiver using a BS2px

LexLex Posts: 13
edited 2009-02-19 06:38 in BASIC Stamp
Hi,

I''m using a dual H-bridge board to control 2 dc motors. I've test out the board using the RC tranceiver.

However, my intention is to use the px to control the motors. the PWM command dun seems to work.

Any suggestions?

Comments

  • dandreaedandreae Posts: 1,375
    edited 2009-02-17 14:49
    Can you attach a file of your code, so that we can review it?



    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Parallax Tech Support·
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-17 14:58
    Read the description of the PWM statement in the manual. It probably doesn't do what you expect. It's intended for use in generating analog voltages and produces short, pseudo-random pulses whose average width is proportional to the value supplied. The PULSOUT statement behaves much more like an RC receiver's output.
  • LexLex Posts: 13
    edited 2009-02-18 05:15
    the dual H-bride board uses the following standard:
    1 ms = turn left or reverse
    1.5 ms = neutral
    2 ms = turn right or forward

    Is there a difference between the PWM & PULSOUT command?

    here's the PULSOUT version:

    · FOR i = 1 TO 100

    ·· ·PULSOUT 7, 1250··············· '1250 = 1 ms; 1875 = 1.5 ms; 2500 = 2 ms
    ··· PAUSE 10
    ·
    · NEXT
    ···
    ···· RETURN

    the version is very jerky.

    here's the PWM version:

    start:
    ·
    · PWM 7, 255, 3······ '3 * .4 ms = 1.2 ms ~ 1.0 ms
    ·
    · GOTO start

    no response for this version. am i right to say that the Duty will control the speed of the output?

    thanx




    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-18 05:23
    You don't have a dual H-bridge board. What you have is a motor controller that appears to the Stamp like a servo motor. The PWM statement will not work with this board. The PULSOUT statement is the proper one to use. You might try increasing the PAUSE time to 20. That's what's normally used with servo motors. If you still get jerky operation, it probably has nothing to do with the program and may be due to the way you have things wired or how you're supplying power and you'll have to provide more information about that if you need further help (like schematics and program listings).

    Read the manual chapters on the PWM and PULSOUT statements if you want to understand the difference between them.
  • LexLex Posts: 13
    edited 2009-02-18 09:17
    Thanx Mike, you're right, PULSOUT is working. Here's my code:

    FOR i = 1 TO 20 'Set motion time

    PULSOUT DC_Throttle, 1875 '1250 = forward; 1875 = neutral; 2500 = reverse
    PULSOUT DC_Steer, 2500 '1250 = left; 1875 = neutral; 2500 = right

    NEXT

    RETURN

    However, this program does not permit speed control. Is there anyway to overcome this?
  • AmaralAmaral Posts: 176
    edited 2009-02-18 18:58
    Does your motor control permit speed control ?

    If it does, how should be the input signal ?

    BS can generate lots of signals, but you have to know what kind of signal you need !
  • LexLex Posts: 13
    edited 2009-02-19 06:38
    I'm using the Tamiya Twin Motor Gear Box. the speed is controlled via the voltage applied. The H-bridge board works fine with the RC transceiver set, both the speed and direction control.

    As for the type of signals, I believe it's the same as the RC signals, which is PWM right?
Sign In or Register to comment.