Robo Claw with a Parallax Propeller?

Hello,

I just got a Robo Claw 2x5 and 2x10 yesterday and I am trying to figure out how to get my Propeller board to communicate with it. My intention is to use the Robo Claw in Packet mode as I have the QME-01 encoders attached to my two motors(ghm-16) and the Robo Claw. I can get all the other modes to work with the Robo Claw (simple serial/RC/analog), however the packet serial mode I am lost on and haven’t been able to figure out what I am missing, from the Basic Micro forums the packet mode is referred to as “the poor mans packet mode”

Has anyone had any luck with packet mode on the robo claw??

Thanks

Yes I have used packet mode on roboclaw on my Tri-track. More details up on the thread: viewtopic.php?f=20&t=6205

Note: I believe there may be several versions of the code up there that tried out the different modes. Note: I was using a BAP and not a propeller, but since it is simply serial communications it would not be hard to make it work on the propeller.

Let me know if you have any specific questions.

Kurt

Hi Kurte,

Thank you for the info, i’m guessing I will have to write an object for the Robo Claw to get it working peoperly with the propeller if I want to use packet mode with it, it’s been a while since I have programmed a prop, but i’ve got some time.

Thanks again

I should of been more specific, when looking at the Robo Claw manual on Serial Packet mode if using a bap you would use the command

Serout P15, i19200, [128, 0, 127, (255 & 0X7F)]

to do this on a propeller, unfortunately I don’t think it’s that easy, i’m using the fullduplexserial object from the obex

I am slightly rusty in spin right now, but should not be too difficult…

You could do somthing like:

[code]RCLAW : “FullDuplexSerial”

RCLAW.start(RXPIN,TXPIN, 0, 19200)
RCLAW.tx(128)
RCLAW.tx(0)
RCLAW.tx(127)
RCLAW.tx(255 & $ff)[/code]
Again I am a bit rusty, but something like this should work.

Kurt

I can understand the “rusty”, it’s been some time since I programmed my prop, what I just ended up doing was this:

serial.tx(128)
pause(2)
serial.tx(0)
pause(2)
serial.tx(127)
pause(2)
serial.tx(255 & %01111111)

Now on to a refresher course on arrays…

Yep, Luckily the arrays usage are pretty normal. I don’t think they have multi-dimensional arrays, but…

I used arrays as well in the conversion of the phoenix code to propeller…

Both with data arrays and normal arrays. Things like:


DAT    
  GetACos byte      255,254,252,251,250,249,247,246,245,243,242,241,240,238,237,236,234,233,232,231,229,228,227,225 
          byte      224,223,221,220,219,217,216,215,214,212,211,210,208,207,206,204,203,201,200,199,197,196,195,193 
          byte      192,190,189,188,186,185,183,182,181,179,178,176,175,173,172,170,169,167,166,164,163,161,160,158 
          byte      157,155,154,152,150,149,147,146,144,142,141,139,137,135,134,132,130,128,127,125,123,121,119,117 
          byte      115,113,111,109,107,105,103,101,98,96,94,92,89,87,84,81,79,76,73,73,73,72,72,72,71,71,71,70,70 
          byte      70,70,69,69,69,68,68,68,67,67,67,66,66,66,65,65,65,64,64,64,63,63,63,62,62,62,61,61,61,60,60,59
          byte      59,59,58,58,58,57,57,57,56,56,55,55,55,54,54,53,53,53,52,52,51,51,51,50,50,49,49,48,48,47,47,47
          byte      46,46,45,45,44,44,43,43,42,42,41,41,40,40,39,39,38,37,37,36,36,35,34,34,33,33,32,31,31,30,29,28
          byte      28,27,26,25,24,23,23,23,23,22,22,22,22,21,21,21,21,20,20,20,19,19,19,19,18,18,18,17,17,17,17,16
          byte      16,16,15,15,15,14,14,13,13,13,12,12,11,11,10,10,9,9,8,7,6,6,5,3,0 

or 
VAR   '' Global Variables and Cog Stack Space
  
'====================================================================
'[ANGLES]
  long     CoxaAngle1[6]    'Actual Angle of the horizontal hip, decimals = 1
  long     FemurAngle1[6]    'Actual Angle of the vertical hip, decimals = 1
  long     TibiaAngle1[6]    'Actual Angle of the knee, decimals = 1
'-


Usage is pretty simple...
CoxaAngle1[LegIKLegNr] := ((Atan4*180) / 3141) + cCoxaAngle1[LegIKLegNr]

For me the most difficult thing to remember when I unrusty myself our things like: what symbols did they use for the different operators (:= for assignment, >= has different meaning than =>…) Also things like when dealing with BYTE or WORD sized variables, they are always treated as unsigned, unless you use the operator to sign extend them…

Kurt

I’ve forgotten how “fun” it can be programming the prop. I am trying to get the commands working that I need to use the encoders on my wheels. Starting to wonder if it would be easier to just have a couple of prop pins and a cog monitor them, right now I am working on receiving data when I send the command to read the main battery voltage, what i’m trying to figure out is what exactly is the robo claw sending back?

In the robo claw manual it says:

24 - Read Main Battery Voltage Level
Read the main battery voltage level connected to B+ and B- terminals. The voltage is returned in 10ths
of a volt. Command syntax:
Sent: [Address, CMD]
Received: [Value.Byte1, Value.Byte0, CRC]
The command will return 3 bytes. Byte 1 and 2 make up a word variable which is received MSB fi rst
and is 10th of a volt. A returned value of 300 would equal 30V. Byte 3 is the CRC. It is calculated the
same way as sending a command and can be used to validate the data. The following example will
read the main battery voltage with Robo Claw address set to 128.
hserout [128, 24] ;read main battery voltage
hserin [Value.Byte1, Value.Byte0, CRC]

So is it actually sending “[Value.Byte1, Value.Byte0, CRC]” or is just sending the bytes themselves back?

The code I am using on the prop is this:

[code]PUB GetBattery | i
PST.START (2400) ’ Starts PST
PAUSE(1_000)
SERIAL.START(RX_Pin, TX_Pin, 0, 2400) ’ Starts FullDuplexSerial in another cog
PAUSE(1_000)
serial.RXflush
serial.tx(128) 'sends roboclaw address
serial.tx(24) 'sends roboclaw command
‘’ serial.RXstrTime(20,@x)
‘’ serial.RxStr (@x)
repeat i from 0 to 2
x* := Serial.rx 'receive 3 characters

  x[3] := 0          'set last character to zero to mark end of string
  PST.Str(String("First = "))
  PST.Dec (x[2])
  PST.Str(string(13,"Second = "))
  PST.Dec(x[1])
  PST.Str(string (13,"Third = "))
  PST.Dec (x[0])
  PST.NewLine
  PST.Str (@x)
  PST.NewLine
PST.Str(String(13,"End",13))

repeat[/code]

in my terminal window I get back

First = 23
Second = 127
Third = 0

End

Now the second byte(127) is actually the battery voltage 12.7, sometimes the second byte comes back as 129 or 12.9v, which is correct. Any ideas?*