Shop OBEX P1 Docs P2 Docs Learn Events
Pololu motor contoller with basic stamp 2 question... — Parallax Forums

Pololu motor contoller with basic stamp 2 question...

kingspudkingspud Posts: 128
edited 2009-04-02 22:07 in BASIC Stamp
Hello all,

I am trying to get the Pololu motor controller to work with two motors and the basic stamp 2 but it doesn't seem to work!
I have it all setup like the doc says but nothing.
I am trying different buad rates but am not sure what number is used for the set buad rate.· I know 84 means 9600 but what are the other buad rates?
I can use 9600 to 19200 but don't know the number for 19200.

also, did anyone else get this thing to work, and if so can you show me your code because the one I am using out of the doc doesn't work.

That or both of my controller are dead, which doesn't seem likely.

thanks

Joe

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“Intellectual growth should commence at birth and cease only at death”
Albert Einstein

Comments

  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-04-02 13:23
    Joe--

    I got mine to work well. I don't think I ever used two motors, however. Unfortunately, I can't do any testing for you because I no longer have it.

    My GUESS is that you nailed it when you mentioned not knowing how to set the baud rate.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Andy FoxAndy Fox Posts: 46
    edited 2009-04-02 22:07
    Hi, Joe.

    I've only used one motor with it, but here's the code I used. Hope it helps.

    '  Playing with the Polou Dual DC motor controller
    '
    '   {$STAMP BS2p}
    '   {$PBASIC 2.5}
    '
    
    ' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
    
    _MotorSDA       PIN     1
    _MotorRST       PIN     0
    
    ' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
    
    Baud           CON     84              ' 9600,N,8,1
    'Baud           CON     240             ' 9600,N,8,1 for BS2p
    ' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
    
    idx            VAR Byte
    idx2           VAR Byte
    
    ' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
    
    Main:
      HIGH  _MotorSDA
      LOW _MotorRST
      PAUSE 5
      HIGH _MotorRST
      PAUSE 100
      ' Configure Polou Dual Motor controller for single motor
      ' mode, motor number = 0.
      SEROUT _MotorSDA, Baud, [noparse][[/noparse]$80, $02, $40]
      LOW _MotorRST
      PAUSE 5
      HIGH _MotorRST
      PAUSE 100
    
    Loop1:
      ' Spin forward
      DEBUG "Ramping forward...",CR
      FOR idx = 32 TO 127
        SEROUT _MotorSDA, Baud, [noparse][[/noparse]$80, $00, $01, idx]
        PAUSE 20
      NEXT
      DEBUG "Full forward...",CR
      PAUSE 3000
      SEROUT _MotorSDA, Baud, [noparse][[/noparse]$80, $00, $01, $0]
      PAUSE 500
      DEBUG "Full backward...",CR
      SEROUT _MotorSDA, Baud, [noparse][[/noparse]$80, $00, $00, $7F]
      PAUSE 3000
      DEBUG "Ramping down...",CR
      ' Spin backward
      FOR idx = 127 TO 32
        SEROUT _MotorSDA, Baud, [noparse][[/noparse]$80, $00, $00, idx]
        PAUSE 20
      NEXT
      DEBUG "Stop.",CR
      SEROUT _MotorSDA, Baud, [noparse][[/noparse]$80, $00, $00, $0]
      PAUSE 2000
      GOTO loop1
    
    
Sign In or Register to comment.