Shop OBEX P1 Docs P2 Docs Learn Events
2 pwm outputs? — Parallax Forums

2 pwm outputs?

rwgast_logicdesignrwgast_logicdesign Posts: 1,464
edited 2012-11-15 20:14 in BASIC Stamp
so im just looki g to set up a quick test circuit to control my robot chasis. the plan was to add a bt uart for a bit or remote functionality t
and have that co trol two different pwn lines wired to an hbridge.

from what im reading the pwm command uses all the bs2s resources while its running? is this true the ps2 can not drive two pwm channels at once

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-15 11:17
    Correct. The Basic Stamp can only do one thing at a time like generate a PWM pulse. Sometimes you can interleave two different functions to make it look like the Stamp is doing things at the same time, but that's not really what's happening. A frequently used example is that of generating servo control pulses for two or three servos and operating some sensors like a PING))). This only works because the servos only need to see a control pulse about every 20ms. The control pulse takes maybe 3ms at most of the Stamp's time and the Stamp usually waits doing nothing for 17ms or so. You can do another one or two 3ms servo pulses plus a PING))) sense cycle in that 17ms. If you do this, notice that the servos may begin to stutter if the robot is in a big room at the limit of the range of the PING))). The PING))) is taking up to 18+ms to finish. That doesn't leave enough time for the servo pulses to be issued before the servos begin to time-out. If the room is small enough to limit the PING))) time to 10ms or so or if the servo pulses are always in a more limited range (like 2ms), all is well. It's like you have a time budget ... you only have 20ms to do all that you want.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2012-11-15 14:06
    Mike, Does this apply if using HB-25's or do they "takeover" the pulse commands from the Stamp?
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-11-15 14:16
    ok thats how i figured it worked. i was thinking i could pwm one motor then pwm the next motor on the second line, and the stamp would be able to budget its time, but pwm apparently takes 100% of the power.

    im tryin to get some code setup real quick just to test the chasis im worried about the traction of the wheel so i really can only test this by putting some weight on the bot and doing simple motor control.

    do u think i could do something like use arduino to generate the 2 pwm and turn it off and on with a bs2 im just lookin for a simple copy and paste soultion. i intend to use a propellers counters or a propeller controlling a dedicated pwm in the end, i just keep getting distracted from learning spin and pasm becuase im to busy building stuff wether it be electronics/battey packs or mechanical items such as chasis.

    basically i have a bt ssp module and a prewritten serial bt remot control app on my phone i figured maybe i could plug that into a bs2 and write a few lines for forward reverse left/right then the bs2 could just just start and stop two arduino pins that are generating pwms... i just wanna get the thing rolling so i can make sure it mechanically sound and test its limits i dont even need speed controll i can just reprogram the arduino as needed to change the pwm frequency for tests


    x
  • ercoerco Posts: 20,257
    edited 2012-11-15 15:43
    NWCCTV wrote: »
    Mike, Does this apply if using HB-25's or do they "takeover" the pulse commands from the Stamp?

    From http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/hb-25/List/0/SortField/4/ProductID/64/Default.aspx

    In the simplest sense the HB-25 allows a DC Motor to be controlled much like a Continuous Rotation Servo. While the signals are compatible, the HB-25 does not require refreshing as a servo does; a single pulse can maintain the output.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-15 16:04
    As erco mentioned, the HB-25 has the H-Bridge and all the other stuff inside so it can control a DC motor and make it look like a servo to the microcontroller with the added goody that it doesn't need continuous control pulses. It remembers the last pulse it got and acts on that until it gets something else. If you just need some kind of quick and dirty test controller, you could use two Stamps, one for each motor. You could use a pot and capacitor with RCTIME to set the % on time for each motor. Another option would be to get a Propeller QuickStart Board and use one of the PWM drivers from the Object Exchange along with your H-Bridges. There are all sorts of options for entering the control information. An Arduino can also work. It all depends on what you have on hand and what you're familiar with.
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-11-15 18:52
    i guess ill look for a prop driver, as i only have 1 bs2 which is what im the most familiar with at the moment, as i said only done some spin although i have tons of propellers around i just need to buckle down and get past the timing chapter in the PE kit, i guess i could probably use a a bs2 to generat the PWM coimmand and then send it to both sides of the bridge, but then im using so much cpu i cant process uart, or flip h bridge pins correct? like the pwm command eats all the bs2 recources?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-15 20:14
    Yes, when the PWM statement is executing, the Stamp is doing nothing else.
Sign In or Register to comment.