Skip to content

Motor Unit Packets

MilkyTea123 edited this page Aug 7, 2024 · 30 revisions

These packets are made for the Motor Units

Packet Name Direction Priority Packet ID B1 B2 B3 B4 B5 B6 B7
Mode Set Recieve Normal 0x00 Mode Set Byte
0x01
0x02
Motor PWM & Direction Receive Normal 0x03 PWM & Direction int16_t MSB LSB
Motor PID Position Target Receive Normal 0x04 Target to 1000th degree int32_t MSB -> -> LSB
P Coefficient Set Receive Normal 0x05 P_Coefficient*10 int32_t MSB -> -> LSB
I Coefficient Set Receive Normal 0x06 I_Coefficient*10 int32_t MSB -> -> LSB
D Coefficient Set Receive Normal 0x07 D_Coefficient*10 int32_t MSB -> -> LSB
Initialize with Mode (not implemented yet) Receieve Normal 0x08
Limit Switch Alert Send High 0x09 Sender Group Code Sender Serial Number Limit Switch Status
Encoder Pulse Per Joint Revolution Set Receieve Normal 0x0A Encoder Pulse per joint Rev uint32_t MSB -> -> LSB
Maximum Joint Revolutions Set Receive Normal 0x0B Maximum Joint Rotation in quarter rotation
Initialize Encoder Receive Normal 0x0C Initilization Packet
Max PWM for PID Receive Normal 0x0D PWM max uint16_t MSB LSB
PCA PWM Receive Normal 0x0E PCA pin uint8_t On Time uint16_t MSB LSB Off Time uint16_t MSB LSB
Pot Set Low Receive Normal 0x0F ADC value uint16_t MSB ADC value uint16_t LSB Joint position (millideg) int32_t MSB -> -> Joint position (millideg) int32_t LSB
Pot Set High Receive Normal 0x10 ADC value uint16_t MSB ADC value uint16_t LSB Joint position (millideg) int32_t MSB -> -> Joint position (millideg) int32_t LSB
PCA Servo Receive Normal 0x11 Servo Num uint8_t Angle (millideg) int32_t MSB -> -> Angle (millideg) int32_t LSB
Set Limit Switch Encoder Bound Receieve Normal 0x12 Limit Switch Number uint8_t Encoder Count int32_t MSB -> -> Encoder Count int32_t LSB
Set Peripherals Receieve Normal 0x13 Peripheral ID uint8_t Peripheral Set uint16_t MSB Peripheral Set uint16_t LSB

Packet Details

Additional information of the packet

Mode Set

Mode Set Byte Description
0x00 PWM Control
0x01 PID Control

PID Coefficients

The Coefficients sent are in units of 10000. So sending a 1 will be interpreted as 10000.

Limit Switch Alert

Limit Switch Status: Each bit represents a limit switch state. If a bit is set to 1 it means it is closed, 0 means it is open.

Initialize Encoder

Initialization Packet

bit 7 6 5 4 3 2 1 0
Description: X X X X X 1 means motor board uses a potentiometer, 0 means the motor board uses a encoder 1 means reverse angle dirction 1 means set Encoder to Angle 0, 0 means ignore

MAX PWM PID

Notice that the uint16_t can create a much larger value than the int16_t can in the set PWM function. However, sending a value larger than or equal to the max value of int16_t (32,767) should be treated as 100% power. This is to keep it consistent with the set motor PWM direction.

Set Limit Switch Encoder Bound

Limit Switch Number: Used to select which limit switch the given count should be correlated with. Use 0 and 1, probably cw vs ccw
Encoder Count: The count that the quad dec should be set to when the limit switch in question is hit

Pot Set

Sets the mapping between potentiometer value (ADC reading) and millidegrees.

Peripherals

Peripheral ID Peripheral Name Min. Value Max. Value
0x00 Null N/A N/A
0x01 Laser 0 65536
0x02 Linear Actuator 0 (off) 1 (on)