Shop OBEX P1 Docs P2 Docs Learn Events
Contolling DC motors — Parallax Forums

Contolling DC motors

MduboisMdubois Posts: 3
edited 2005-07-27 16:06 in Robotics
I'm trying to do autonomous sumo robots at my school and want to be able to use other motors besides the servo's.· I have a sozbot controller's and was wondering if I could use those?· And how I would do that?

Thanks
Mike

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-07-25 19:08
    Do you have the Speed Control Board, MX speed control or M speed control?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • MduboisMdubois Posts: 3
    edited 2005-07-25 19:21
    I have a SOZDSCR2 speed control board. At http://www.sozbots.com/
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-07-25 21:23
    I have bad news for you, the SOZDSCR2D was designed to drive DC motors using an RC receiver. The output of the RC receiver is PWM, and there are two channels (meaning two PWM signals). As such using the PBASIC PWM command was only designed to generate a single PWM channel, so you can't really use the built in command to drive both channels of your SOZDSCR2D. But you can design your own dual channel PWM control (if you arn't doing anything else while doing the PWM). Im leaving work now, but if you want more info, I can fill in more detail for you.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10

    Post Edited (Paul Baker) : 7/25/2005 10:19:52 PM GMT
  • MduboisMdubois Posts: 3
    edited 2005-07-26 18:23
    How do I design my own dual channel PWM control?

    Thanks
    Mike
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-07-27 16:06
    Ok this isn't as difficult of a task as I first anticipated, Servo PWM signals·are·1.3 mS to 1.7 mS pulse every 20 mS. ·Look at pages 67, 76 and 78 of the Robotics V2.2 text for an overview. For the BS2 the pulses are values 650 through 850 with 650 being center (off).

    CH1Value VAR Word
    CH2Value VAR Word
    Do
       PULSOUT CHANNEL1, CH1Value
       PULSOUT CHANNEL2, CH2Value
       IF (CHSelect = 1) THEN
          CH1Value = 650 + INL
       ELSE
          CH2Value = 650 + INL
       ENDIF
       PAUSE 20
    LOOP
          
    

    ··This code sends the servo control signal for two channels, CH1Value and CH2Value are·the pulse width of each Channel in 2 uS resolution, the code after the two PULSOUTs reads the value of CHSelect which is an input pin (one of IN8-IN15) which indicates what channel the value on the low byte of your input pins refers to, the value on the low byte is read and added to·650 and stored in the corresponding channel value. The·input value can be from 0 to 200, values higher·than·200 may produce unexpected results.

    · The PAUSE statement for 20 mS may be too long since your doing another pulse and some computations, so you may need to reduce this value. http://www.emesystems.com/BS2speed.htm·shows relative execution times of BS2 commands and can provide some guidance what a more appropriate value to PAUSE is.

    · If you need to perform more calculatations you'll need to adjust the PUASE command even more, and you'll also need to make sure the code does not take more than 20 mS, and finally if your code branches you should make sure it takes aproximately the same amount of time to execute the code regardless which branch is·taken (by inserting PAUSES in the shorter branches).

    Not all code was provided, CHSelect, CHANNEL1, CHANNEL2 need to be defined, and CHANNEL1 and CHANNEL2 pins need to be set as output.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10

    Post Edited (Paul Baker) : 7/27/2005 4:21:44 PM GMT
Sign In or Register to comment.