Pages: [1]   Go Down
Author Topic: Arduino to Jrk motor controller with SoftSerial  (Read 959 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  I am new to programming and I am trying to send  high resolution speed values to a motor jrk motor controller from an arduino.
 I need to send the target value is in hex from 0-4095 over serial using the SoftSerial library. I am not sure how to do this in the Arduino programming language. I would appreciate any help on this topic.

Below is an example tha I pulled from the Pololu JRK user guide.

Pololu protocol, hex: 0xAA, device number, 0x40 + target low 5 bits, target high 7 bits

Here is some example C code that will generate the correct serial bytes, given an integer “target” that holds the
desired target (0–4095) and an array called serialBytes:
serialBytes[0] = 0xC0 + (target & 0x1F); // Command byte holds the lower 5 bits of target.
serialBytes[1] = (target >> 5) & 0x7F; // Data byte holds the upper 7 bits of target.

Seattle, WA USA
Offline Offline
Brattain Member
Karma: 640
Posts: 50335
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Once you have the two bytes (in serialBytes), use NewSoftSerial::print(serialBytes[n], BYTE); twice to send the two bytes (with n=0 then n=1).

Pages: [1]   Go Up
Jump to: