Shop OBEX P1 Docs P2 Docs Learn Events
pololu motor problems, getting no action. BS2, pololu micro dual serial contro — Parallax Forums

pololu motor problems, getting no action. BS2, pololu micro dual serial contro

neotericneoteric Posts: 144
edited 2006-02-12 17:31 in Robotics
I am using a bs2, and a Pololu Micro Dual Serial Controller
This is really a little ahead of me, but this is the first time I have hooked up something and it just gets nothing.· Nada.
I have tested the motors, and just been through all the threads here under "Pololu" search.
http://www.parallax.com/detail.asp?product_id=30052

I believe I have it wired correctly, as in two motor documentation with Pololu. Seperate· 9v driving the motors &·9V on logic board, common ground.
This is my first time hooking up the controller, but I have checked and double checked.· No heat, no nothing.· No motors.
The motors do turn if wired directly.

The·code, taken from the nuts and volts article....
' {$STAMP BS2}
' {$PBASIC 2.5}
MLFwd VAR  Word  'l forward'
MRFwd VAR Word   'r forward'
Sout VAR Word    'serial line
Reset VAR Word   'reset line
MLFwd = %11
MRFwd = %00
Sout = 1         'pin 4 on Pololu motor controller
Reset = 2        'pin 5 on Pololu motor controller
 
Main:
HIGH  SOut
DEBUG "reset"
GOSUB Reset_SMC
DEBUG "accel"
GOSUB  Accelerate
DEBUG "begin again...."
GOTO  Main
 
Accelerate:
SEROUT SOut, $84, [noparse][[/noparse]$80, 0, MLFwd, 127]
SEROUT SOut, $84, [noparse][[/noparse]$80, 0, MRFwd, 127]
PAUSE 50
RETURN
 
Reset_SMC:
LOW Reset
PAUSE 100
HIGH Reset
RETURN




I appreciate anyone who can help me.· Thanks!!!

Post Edited (neoteric) : 2/12/2006 12:34:14 PM GMT

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-02-12 04:41
    neoteric -

    The PBASIC statement which follow, and the comments on them don't match:

    Sout = 1 'pin 4 on P controller
    Reset = 2 'pin 5 on P controller

    The comments imply you're using Pin Ports 4, and 5 but Pin Ports 1 and 2 are being assigned. Which is correct? I'm also not clear on why they're being assigned as WORD variables? Something gives me the impression that the code listed did not come directly from a Nuts and Volts article, that it's been substantially modified.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • neotericneoteric Posts: 144
    edited 2006-02-12 12:33
    Bruce,

    Thanks for helping.· Sorry, the comments should have been clearer...

    a case where the comments added confusion as oppossed to clarity.· "P controller" meant Pololu controller.· As for the Word var, is·it OK to use that in this case?· For proto-code?

    As for the nuts and volts article, I cut out everything that I believe I ddint need.· I had to add some, as the entire program is not included in the article.· I tried using everthing in the article, first, with the addition of variables.·· When I get back to the board, I will change the Vars, as per your suggestion.· (I HAVE EDITED THE ORIGINAL CODE IN THE FIRST MESSAGE FOR CLARITY)
  • Rick BrooksRick Brooks Posts: 67
    edited 2006-02-12 13:43
    Neoteric,

    The word length variables are causing you a problem. They should really all be constants. Try:

    MLFwd con 3 'l forward
    MRFwd con 0 'r forward
    Sout con 1 'serial line pin 4 on Pololu motor controller
    Reset con 2 'reset line pin 5 on Pololu motor controller

    Then call the reset subroutine before the "Main:" loop, not within the loop.

    Finally, take the "$" off of your Baudmode. 84 should be a decimal. When you type $84 you are making it a hex number which is actually 132 decimal.

    I think that these changes should make it work. Try it again and post your results.

    Rick Brooks
    Brooksbots.com
  • Steve JoblinSteve Joblin Posts: 784
    edited 2006-02-12 15:41
    If your still having problems,try this program... you will need to hook up the reset line from the Pololu to Pin 15 and the serial control input fromthe Pololu to Pin 14.
    There is a working example BASIC Stamp II Program that is in the Pololu documentation.
    '{$STAMP BS2}
    SPEED···var··byte
    RESET_DSMC··con··15
    output 14

    DEBUG CLS
    DEBUG "Reset Controller", CR

    Low RESET_DSMC
    pause 10
    High RESET_DSMC

    DEBUG "Ramp Up Motors Forward", CR
    for SPEED = 0 to 127
    ·· serout 14,32,[noparse][[/noparse]$80,0,1,SPEED]
    ·· pause 50
    ·· serout 14,32,[noparse][[/noparse]$80,0,3,SPEED]
    next

    pause 1000

    DEBUG "Ramp Down Motors Forward", CR
    for SPEED = 127 to 0
    ·serout 14,32,[noparse][[/noparse]$80,0,1,SPEED]
    · pause 50
    · serout 14,32,[noparse][[/noparse]$80,0,3,SPEED]
    next

    pause 4000

    DEBUG "Ramp Up Motors Reverse", CR
    for SPEED = 0 to 127
    · serout 14,32,[noparse][[/noparse]$80,0,0,SPEED]
    · pause 50
    · serout 14,32,[noparse][[/noparse]$80,0,2,SPEED]
    next

    pause 1000

    DEBUG "Ramp Down Motors Reverse", CR
    for SPEED = 127 to 0
    ·serout 14,32,[noparse][[/noparse]$80,0,0,SPEED]
    · pause 50
    · serout 14,32,[noparse][[/noparse]$80,0,2,SPEED]
    next

    end
  • neotericneoteric Posts: 144
    edited 2006-02-12 16:06
    Bruce, Steve, Rick. It is working! Would you believe I had a wire in the wrong place? (EMBARRASED BEGINNER HERE)
    Thats what I get for working on it so late. I actually wired it from scratch 3 times last night, and missed that connection all 3 times!

    Wired correctly, the first program I posted does run, although it does reset everytime. Moved the reset out of the main loop as suggested by Rick.
    Bruce, just learning about variables. Sure enough, I have not written a program yet that struggles for memory. But as of today, I am paying attention to variable usage. For some strange reason, I just didnt understand that variable types actually take up space differently, but I got that concept now... Thanks.

    Steve, I will review your program, and try it. BTW, I simply cannot find that documentation! Not on thier site, definitely not with the controller. AM I CRAZY? I am one of those persons who does the research before asking.... In fact, lots of research. Probably too much, as my retention is not so good some times....

    One other question: It does not seem to matter whether I use $84 or 84. Which now has me very confused. Because what you said about that, Steve, does make sense. Although the NV article has it as $84. Is this because the original article was written for a BS1? Just trying to learn here...

    Once again, I cannot thank you folks enough for helping me. I have done tons of experimentation, and purchased 4 different learning packages from Parallax and been through each. I will probably have more questions, as this robot I intend to make a little more complex. (I want to add an arm....)

    Thanks! I only hope I can get good enough to help others!
  • Rick BrooksRick Brooks Posts: 67
    edited 2006-02-12 17:31
    Neoteric,

    There is a difference between a baudrate of 84 and $84, but you probably won't notice.

    The Pololu takes any baudrate from 1200 to 19,200.

    When you use a baudrate of 84, the data is sent at 9600 bits per second. When you use a baudrate of $84, in decimal that is 132 which results in about 6579 bits per second.

    Just don't try to change baudrate in the middle of a program. The Pololu "locks" onto the first rate that it sees after a reset and will use that rate until another reset.

    Rick Brooks
Sign In or Register to comment.