Shop OBEX P1 Docs P2 Docs Learn Events
Using a Prop to control the Robo Claw motor controller — Parallax Forums

Using a Prop to control the Robo Claw motor controller

charleyshfcharleyshf Posts: 165
edited 2011-02-20 12:40 in Propeller 1
Hello,

I am hoping that someone may have used this motor controller with the prop. I haven't seen anything posted on the forums, but the problem I am having is this:

The motor controller is set to packet mode (I need this mode to read wheel encoders which are interfaced to the motor controller).

The manual for the motor controller states:
CRC Checksum Calculation:

All packet serial commands use a 7 bit CRC checksum to prevent corrupt commands from being
executed. Since the Robo Claw expects a 7bit value the 8th bit is masked. The basic CRC checksum is
calculated as follows:
Address + Command + Data = Checksum
To mask the 8th bit you use can a simple math expression called AND as shown below:
Serout P15, i19200, [128, 0, 127, (255 & 0X7F)]

I am using the Extended_FDserial object from the obex along with my program which is attached:

What I cannot figure out is how to get this to work with the roboclaw, you will see by my code I have tried a few different things, and have not had any luck.

I would appreciate any help, thanks

Comments

  • charleyshfcharleyshf Posts: 165
    edited 2011-02-19 14:06
  • kuronekokuroneko Posts: 3,623
    edited 2011-02-19 17:31
    You're getting close. Sending a string doesn't fly (that's about 26 characters you're sending). Using the tx method is OK but ATM you or'ing all values together and send them as a single byte. So what you need is a sequence of 4 tx calls like this:
    serial.tx(128)
      serial.tx(0)
      serial.tx(127)
      serial.tx(255 & %01111111)
    
    When that works you can think about using e.g. a loop to pick up the bytes from an array. HTH
  • charleyshfcharleyshf Posts: 165
    edited 2011-02-19 18:08
    Thank you for responding! I've been going through manuals and forums all day today, The code does work, however it works about only 50% of the time. I think I might need more than 1k resistors on my tx and rx lines or maybe even going with a lower baudrate since the motor controller is a 5v device.. Once I get that resolved i'm going to get going on arrays, thanks again.



    kuroneko wrote: »
    You're getting close. Sending a string doesn't fly (that's about 26 characters you're sending). Using the tx method is OK but ATM you or'ing all values together and send them as a single byte. So what you need is a sequence of 4 tx calls like this:
    serial.tx(128)
      serial.tx(0)
      serial.tx(127)
      serial.tx(255 & %01111111)
    
    When that works you can think about using e.g. a loop to pick up the bytes from an array. HTH
  • kuronekokuroneko Posts: 3,623
    edited 2011-02-19 18:19
    charleyshf wrote: »
    The code does work, however it works about only 50% of the time.
    I don't know much about the BASIC Stamp, could it be that its timing is slightly different (between character time)? I may be talking nonsense here but just to clear that up could you add a pause between the tx calls (e.g. waitcnt(MS_001 * 2 + cnt) for 2ms or maybe more)?
  • charleyshfcharleyshf Posts: 165
    edited 2011-02-19 19:16
    That was it, thank you again! Adding the 2ms delay has made it really stable, now on to arrays...

    kuroneko wrote: »
    I don't know much about the BASIC Stamp, could it be that its timing is slightly different (between character time)? I may be talking nonsense here but just to clear that up could you add a pause between the tx calls (e.g. waitcnt(MS_001 * 2 + cnt) for 2ms or maybe more)?
  • charleyshfcharleyshf Posts: 165
    edited 2011-02-20 12:40
    I was still having some strange problems with the robo claw controller, so I changed the resistors on the Rx/Tx from 1k to 2.2k and now it works 100% of the time...
Sign In or Register to comment.