4.e. Motor Control Commands

The jrk has several serial commands for turning the motor on and off and setting the target. These commands are mainly intended to be used in serial input mode, but they can be used in any input mode to turn the motor on or off from a computer.

Motor Off

Compact protocol: 0xFF
Pololu protocol: 0xAA, device number, 0x7F

This command will turn the motor off by setting the Awaiting Command error bit. The jrk will not restart the motor until it receives a Set Target command. The jrk can be configured to either brake or coast while the motor is off (Section 3.e).

Set Target High Resolution

Compact protocol, binary: 110LLLLL, 0HHHHHHH
Compact protocol, hex: 0xC0 + target low 5 bits, target high 7 bits
Pololu protocol, binary: 10101010, device number, 010LLLLL, 0HHHHHHH
Pololu protocol, hex: 0xAA, device number, 0x40 + target low 5 bits, target high 7 bits
(where target is the 12-bit number HHHHHHHLLLLL)

This command clears the Awaiting Command error bit and (if Input Mode is Serial) lets you set the 12-bit target to any of its allowed values (0–4095). The meaning of the target depends on what Feedback Mode the jrk is in (Section 3.c). The lower 5 bits of the command byte represent the lower 5 bits of the target, while the lower 7 bits of the data byte represent the upper 7 bits of the target.

For example, if you want to set the target to 3229 (110010011101 in binary), you could send the following byte sequence:

in binary: 11011101, 01100100
in hex: 0xDD, 0x64
in decimal: 221, 100

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.

Many motor control applications do not need 12 bits of target resolution. If you want a simpler and lower-resolution set of commands for setting the target, you can use the Set Target Low Resolution commands. Alternatively, you could use the Set Target High Resolution command with the lower 5 bits of the target always zero: sending a 0xC0 byte followed by a data byte (0–127) will result in setting the target to a value of 32 multiplied by the data byte.

Set Target Low Resolution Forward

Compact protocol: 0xE1, magnitude
Pololu protocol: 0xAA, device number, 0x61, magnitude

This command clears the Awaiting Command error bit and (if Input Mode is Serial) sets the target to a value of 2048 or greater which is determined by the magnitude (0–127).

If the Feedback Mode is Analog or Tachometer, then the formula is

Target = 2048 + 16×magnitude.

If the Feedback Mode is None (speed control mode), then the formula is

Target = 2048 + (600/127)×magnitude.

This means that a magnitude of 127 will set the duty cycle target to full-speed forward (+600), while a magnitude of zero will make the motor stop.

Set Target Low Resolution Reverse

Compact protocol: 0xE0, magnitude
Pololu protocol: 0xAA, device number, 0x60, magnitude

If magnitude is zero, then this command is equivalent to the Motor Off command above: the Awaiting Command error bit will be set, so the jrk will turn the motor off until another Set Target command is received.

Otherwise, this command clears the Awaiting Command error bit and (if Input Mode is Serial) sets the target to a value less than 2048 which is determined by the magnitude (0–127).

If the Feedback Mode is Analog or Tachometer, then the formula is

Target = 2048 − 16×magnitude.

If the Feedback Mode is None (speed control mode), then the formula is

Target = 2048 − (600/127)×magnitude.

This means that a magnitude of 127 will set the duty cycle target to full-speed reverse (-600).

Related Products

Jrk 21v3 USB Motor Controller with Feedback
Jrk 12v12 USB Motor Controller with Feedback
i00600 Torxis Servo 1600 oz.in. 1.5 sec/90 deg
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors