PICAXE and Pololu Jrk Motor Controller...

Adamey

Senior Member
Anyone used the Pololu Jrk 21v3 or 12v2 USB motor controllers with a PICAXE? They have a serial input but I can't seem to find any code examples of how to use & connect with a PICAXE.

I'm only interested in sending serial target position commands to the Pololu Jrk and nothing more.
 

papaof2

Senior Member
Looking at the manual http://www.pololu.com/docs/pdf/0J38/jrk_motor_controller.pdf the TX and RX appear are 5 volt TTL ports.

I did not read the entire manual, but you may have to set the Jrk to serial input mode via the USB connection before you can talk to the device on the TX and RX pins. Unless you pre-set the baud rate, you must send 0xAA (decimal 170) to set autobaud before sending a command.

If this Jrk is the only Polulu device onthis serial line, I suggest that you use the Compact Protocol to simplify commands.

serout YOURPIN, T2400_4, 0xFF 'motor off

The other commands are more complex, as you're splitting a 12 bit value (0-4095) over two bytes (5 bits in command byte, 7 bits in data byte)

Example:
Set Target High Resolution
Compact protocol, binary: 110LLLLL, 0HHHHHHH
Compact protocol, hex: 0xC0 + target low 5 bits, target high 7 bits

A function that converts a 12 bit value into two bytes (5 low bits in one byte, 7 high bits in the other byte) would probably be the easiest to use solution, as other commands also use 12 bit values.

John
 

Adamey

Senior Member
Been awhile, but finally starting working on this again. This is a method I came up with to get my 12 bits into two bytes.

Keeping in mind I need my output to equal: 110LLLLL 0HHHHHHH

Code:
w0 = 4095                ' sample target position maximum or 0000HHHH HHHLLLLL

let b3 = b0              ' make b3 = HHHLLLLL
let bit31 = 1
let bit30 = 1            ' make B3 = 110LLLLL
let bit29 = 0

let b0 = b0 >> 5         ' shift HHHLLLLL to 00000HHH
let B1 = B1 << 3         ' shift 0000HHHH to 0HHHH000
B2 = B1 | B0             ' turn 0HHHH000 and 00000HHH into 0HHHHHHH

serout 1, T2400_4, (w1)  ' send position command in format 110LLLLL 0HHHHHHH
I'd like comments on my code and if this is OK or if someone can think of a simpler method.
 
Last edited:
Top