-
Notifications
You must be signed in to change notification settings - Fork 5
TCP IP OPCODE
- Introduction
-
Motor OPCODES
2.1. Motor Configuration
2.1.1. Microstepping
2.1.2. Servo Bound Upper
2.1.3. Servo Bound Lower
2.2. Motor Control
2.2.1. Move
2.2.2. Goto
2.2.3. Stop -
Device OPCODES
3.1. WiFi
3.1.1. Connect
3.1.2. Disconnect
3.2. OTA
3.2.1. OTA Password Change -
TCP IP Structure
4.1. JSON over TCP
4.1.1. Motor OPCODE
4.1.2. WiFi OPCODE
4.2. UDP
4.2.1. Motor OPCODE
4.2.2. WiFi OPCODE
Control commands may be issued to a controller via JSON over TCP or binary over UDP. In this document we will review the available OPCODE commands and command structure over each transport layer.
Compatibility:
- Servo: ❌
- Stepper: ✔️
Description: Sets stepper driver micro step mode
code: 'U'
data:
1. motor id: ID of the motor to control
2. queue: Set to 1: add command to queue 0: clear queue and run command
3. step num: N/A
4. step rate: if greater than 0, microstepping enabled. Otherwise, disabled
Compatibility:
- Servo: ✔️
- Stepper: ❌
Description: Set maximum servo angle
code: 'H'
data:
1. motor id: ID of the motor to control
2. queue: Can not be queued
3. step num: N/A
4. step rate: Maximum servo location in degrees; limit is 200 degrees
Compatibility:
- Servo: ✔️
- Stepper: ❌
Description: Set minimum servo angle
code: 'L'
data:
1. motor id: ID of the motor to control
2. queue: Can not be queued
3. step num: N/A
4. step rate: Minimum servo location in degrees; limit is 0 degrees
Compatibility:
- Servo: ✔️
- Stepper: ✔️
Description: Traverses a number of units from the current location
code: 'M'
data:
1. motor id: ID of the motor to control
2. queue: Set to 1: add command to queue 0: clear queue and run command
3. step num: For Steppers, the number of steps to move; for servos, the number of
degrees to move
4. step rate: For Steppers, the number of steps to move per second; for servos, the
number of degrees to move per second
Compatibility:
- Servo: ✔️
- Stepper: ✔️
Description: Move to a specific location
code: 'G'
data:
1. motor id: ID of the motor to control
2. queue: Set to 1: add command to queue 0: clear queue and run command
3. step num: For steppers, the number of steps from the home location to travel to; for
servos, the specific angular degree to travel to
4. step rate: For Steppers, the number of steps to move per second; for servos, the
number of degrees to move per second
Compatibility:
- Servo: ✔️
- Stepper: ✔️
Description: Pauses movement for specific amount of time
code: 'S'
data:
1. motor id: ID of the motor to control
2. queue: Set to 1: add command to queue 0: clear queue and run command
3. step num: For steppers, the number of cycles to wait; for servos, the number of
cycles to wait
4. step rate: For steppers, the period of wait cycles in milliseconds; for servos, the
number of wait cycles per second
Compatibility:
- Servo: ✔️
- Stepper: ✔️
Description: Connect to WiFi SSID
code: 'C'
data:
1. SSID: SSID of target network
2. Password: Password of target network
Compatibility:
- Servo: ✔️
- Stepper: ✔️
Description: Disconnect from WiFi
code: 'D'
data:
1. SSID: N/A
2. Password: N/A
Compatibility:
- Servo: ✔️
- Stepper: ✔️
Description: Changes the OTA password
code: 'O'
data:
1. SSID: Old OTA password
2. Password: New OTA password
JSON packets should be sent with a HTTP POST.
Motor OPCODE Structure:
{
"commands": [
{
"code": "?",
"data": [
"motor_id",
"queue",
"step_num",
"step_rate"
]
}
]
}
Motor OPCODE Example:
- Move, motor zero, no queue, 400 steps at 100 rate.
{
"commands": [
{
"code": "M",
"data": [
0,
0,
400,
100
]
}
]
}
Wifi OPCODE Structure:
{
"commands": [
{
"code": "?",
"data": [
"SSID",
"Password"
]
}
]
}
Wifi OPCODE Example:
- Connect to "HomeWiFi" with password "1234"
{
"commands": [
{
"code": "C",
"data": [
"HomeWiFi",
"1234"
]
}
]
}
Motor OPCODE C Structure:
struct stepper_command_packet
{
unsigned short port;
char opcode;
uint8_t queue;
int32_t stepNum;
uint16_t stepRate;
uint8_t motorID;
};
Motor OPCODE example:
- Move, motor zero, no queue, 400 steps at 100 rate. Hexadecimal UDP data:
00004D0000000190006400
WiFi OPCODE C Structure:
struct wifi_command_packet {
char opcode;
char ssid[32];
char password[63];
};
WiFi OPCODE example:
- Connect to "HomeWiFi" with password "1234"
Hexadecimal UDP data:
43486F6D6557694669000000000000000000000000000000000000000000000000313233340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000