Shop OBEX P1 Docs P2 Docs Learn Events
Driving a roboclaw motor controller with the basic stamp — Parallax Forums

Driving a roboclaw motor controller with the basic stamp

PAPCHPAPCH Posts: 3
edited 2012-03-29 09:39 in General Discussion
Hello, I would like to drive a roboclaw motor controller with my basic stamp. Would someone please tell me the equivalent of this BasicAtom pro line ( Serout P15, i19200, [128, 5, 127, (260 & 0X7F)] ) for a Basic Stamp 2? Thank you in advance for your help.

Comments

  • ratronicratronic Posts: 1,451
    edited 2012-03-25 15:33
    PAPCH to use the serout command in PBASIC, click on Help, then click on PBASIC Language Reference, then scroll down the command list to "serout" and click on it for information on how to use the command in PBASIC from the BASIC Stamp Editor menu.

    Edit: when I say click on help I mean the book icon with question mark in it on the right end of all of the icons at the top of the editor
  • ercoerco Posts: 20,259
    edited 2012-03-25 19:06
    @PAPCH:

    Please decode the BA command ( Serout P15, i19200, [128, 5, 127, (260 & 0X7F)] )
  • lanternfishlanternfish Posts: 366
    edited 2012-03-27 23:26
    ( Serout P15, i19200, [128, 5, 127, (260 & 0X7F)] ) is the same for both chips.

    Serout on Port 15 @ 19200 baud

    Data output is [128, 5,127, (260 AND 0x7F)]

    If you go to the AtomPro website you can download the AtomPro manual. On pg 211 there is a guide to converting Basic Stamp programs to AtomPro MBasic. So you should be able to easily reverse the proces.
  • PAPCHPAPCH Posts: 3
    edited 2012-03-28 04:39
    I checked the basic stamp manual and I didn't see any baud rate of 19200 for the Serout command. Please help me to convert the line (Serout P15, i19200, [128, 5, 127, (260 & 0X7F)]) into pbasic. I desperately need it for my project.

    Thanks in advance.
  • ratronicratronic Posts: 1,451
    edited 2012-03-28 09:02
    Now that lanternfish interpereted the Mbasic code I am posting how to calclate the baudrate # (how I came up with 32 for 19200) for the BS2's as it doesn't show for that high of a baud rate in the help manuel. This is from the BasicStamp syntax reference manuel. Also I'm not sure whether a BS2 can do math in the serout statement maybe one of the Stamp experts can jump in and correct me if I am wrong. But here is one way you could do it.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    'constants
    Baud  CON 32  '19200 baud for BS2
    TxPin CON 15  'BS2 transmit pin
    
    'variables
    a VAR Byte
    b VAR Byte
    c VAR Byte
    d VAR Byte
    
    'program
    
    DO
    
    a = 128
    b = 5
    c = 127
    d = (a + b + c) & $7f
    
    SEROUT TxPin, Baud, [a, b, c, d]
    
    LOOP
    
    1024 x 325 - 41K
  • PAPCHPAPCH Posts: 3
    edited 2012-03-29 09:32
    Thanks a lot im going to see if it works. :-)
  • PublisonPublison Posts: 12,366
    edited 2012-03-29 09:39
    In reality, the BS2 can not communicate very well over 9600 baud. Can you set your RoboClaw to accept this baud rate?

    Jim
Sign In or Register to comment.