Skip to content

NeaveEng/luggage-can-protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Luggage CAN Protocol

This library defines the protocol used to communicate between various CAN nodes in The Luggage's distributed motor control system. The command and payload are encoded in an extended ID by using the 29bits as three bytes and ignoring the rest.

The heartbeat is used to confirm nodes are online, the payload should be an integer increasing over time so that the coordinating node can monitor all nodes and confirm they're operational. millis() can be used for this for example, though if synchronisation is required this can be offset by broadcasting a value for all nodes to set their heartbeat value to.

The format is [Node ID, Payload Type, Command] where each element is a byte in a three byte array. Where a value is shown after the array it should be considered the payload.

For example [17, 1, 0]:127 as an ID would translate to "set the speed of node 17 to the value in the payload (127). [17, 0, 0] would request the wheel speed from node 17. Node 17 could also broadcast it's speed at a regular interval for others to monitor.

Node ID 255 is used as a broadcast ID, for example if you wanted to sync all nodes you could send [255, 0, 1]:0 and it would set all the nodes heartbeat values to the payload.

To adjust the interval at which telemetry is transmitted the SetInterval command can be used. For example, [4,1,2]:1000 would ask node 4 to broadcast it's speed once per second. Using the broadcast ID would set all nodes to the same interval, eg [255,1,2]:1000.

Payload Types

These define what the value of the payload contains, zeroth indexed.

Heartbeat,              // All nodes send a heartbeat
Speed,                  // Get/Set wheel speed
Brake,                  // Get/Set brake state
Inverted,               // Get/Set motor inversion
P,                      // Get/Set P value
I,                      // Get/Set I value
D,                      // Get/Set D value
Temperature,            // Get controller temp (if available)
ID,                     // Set CAN ID for the controller
System                  // EEPROM/reboot commands

Commmands

These define the operation that will be performed against the payload, zeroth indexed.

Get,            // Get the value from RAM
Set,            // Set the value to RAM
SetInterval,    // Used to set the report interval in ms  
SaveEeprom,     // Save state to eeprom 
GetEeprom,      // Get value from eeprom
Reset           // Reset the node

About

Definition of the CAN protocol used to control The Luggage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages