6 Specification
6.1 UCOM CAN-Bus Functions
6.1.1 Warning
This specification is incomplete and might not be always correct. If you find and error, please notify me.
6.1.2 Important concepts
- DSP / UCoM:
Name of the control chip / control board used to control the motor driver.
- Sequence Number:
Position of the UCoM board in the CAN-Bus. (boards are chained together)
- Flash ID:
ID of the UCoM board that is choosen while flashing the bootloader.
- Program ID:
Checksum of the firmware that is transmitted over CAN.
- Exloader:
Name of the bootloader that executes the firmware.
6.1.3 Implementation Notes
The relevant files for CAN support in MCA/ARMAR are:
mca2.4/libraries/hardware/UseSocketCAN.h
mca2.4/projects/armar3/action/hardware/
6.1.4 Message ID encoding
The type of function is encoded in the message id of the CAN frame in the following way:
+--------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
|Bit | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
+--------+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+
|Meaning | Function Number | Sequence Number |
+--------+---------------------------------------+----------------------------------+
msg_id = ((id & 0x001f) | ((fctn & 0x003f) << 6));
When the sender of the CAN-Frame is the PC, the Sequence Number denotes the recipient. When the sender of the CAN-Frame is a DSP, the Sequence Number denotes the UCoM board.
6.1.5 Function IDs
Name | Number | Sender |
---|---|---|
PC_RESET | 0 | PC |
PC_XRESET | 1 | PC |
DSP_ERROR | 2 | DSP |
DSP_INITACK | 3 | DSP |
DSP_PROGFINISHED | 4 | DSP |
DSP_INFO | 5 | DSP |
DSP_READY | 6 | DSP |
PC_SETSTATUS | 7 | PC |
PC_INFO | 8 | PC |
PC_REPORT | 9 | PC |
PC_INIT | 10 | PC |
PC_PROG | 11 | PC |
PC_START | 12 | PC |
MCA_PC_CI | 13 | PC |
MCA_DSP_SO | 14 | DSP |
MCA_PC_PAR | 15 | PC |
DSP_REPORT0 | 16 | DSP |
DSP_REPORT1 | 17 | DSP |
DSP_REPORT2 | 18 | DSP |
DSP_REPORT3 | 19 | DSP |
MCA_DSP_READY | 20 | DSP |
MCA_PC_START | 21 | PC |
MCA_DUMP_IO_DESCRIPTION | 22 | PC / DSP |
MCA_DUMP_CI | 23 | PC |
MCA_ADMIN_DATA | 24 | PC / DSP |
MCA_DEBUG_MSG | 25 | DSP |
MCA_ALIVE | 26 | PC / DSP |
MCA_DSP_CI | 27 | DSP |
6.1.6 Function descriptions
6.1.6.1 PC_RESET
- Meaning:
- Reset UCoM boards.
- Data:
- No data.
- Expected response:
- UCoMs respond with DSP_REPORT0 - DSP_REPORT3
6.1.6.2 PC_XRESET
- Meaning:
- Special reset, used when updating the firmware.
- Data:
- No data.
- Expected response:
- No response.
6.1.6.3 DSP_ERROR
- Meaning:
- Send error code to PC.
- Data:
- 1 byte DSP error codes.
- Response:
- None.
6.1.6.4 DSP_INITACK
- Meaning:
- Acknowledge initialisation request with sequence id.
- Data:
- 1 byte DSP sequence id.
- Response:
- None.
6.1.6.5 DSP_PROGFINISHED
- Meaning:
- Programming firmware finished.
- Data:
- None.
- Response:
- None.
6.1.6.6 DSP_READY
- Meaning:
- DSP signals it is ready to receive more program data. (used while programming for flow control)
- Data:
- None.
- Response:
- None.
6.1.6.7 PC_SETSTATUS
- Meaning:
- Set status of target DSP.
- Data:
- 2 Bytes:
new_state = (old_state & ~bit-mask) | 2nd_byte
+-------------+------+------+------+------+------+------+------+------+
| Byte - Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+=============+======+======+======+======+======+======+======+======+
| 0 | bit-mask for second byte |
+-------------+------+------+------+------+------+------+------+------+
| 1 |MSTART|ASTART|MCARUN|EXLRUN| INIT | PROG |OPINIT|IPINIT|
+-------------+------+------+------+------+------+------+------+------+
6.1.6.8 PC_INFO
- Meaning:
- Request information about the ucom board.
- Data:
- None.
- Response:
- DSP_INFO with data containing information about the DSP.
6.1.6.9 DSP_INFO
- Meaning:
- DSP sends information about state/options to PC.
- Data:
- Multiple packages.
DSP Info (1 package, 8 Bytes)
+-------------+------+------+------+------+------+------+------+------+ | Byte - Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +=============+======+======+======+======+======+======+======+======+ | 0 | 1. Byte Flash Number | +-------------+------+------+------+------+------+------+------+------+ | 1 | 2. Byte Flash Number | +-------------+------+------+------+------+------+------+------+------+ | 2 | Sequence Number | +-------------+------+------+------+------+------+------+------+------+ | 3 |MSTART|ASTART|MCARUN|EXLRUN| INIT | PROG |OPINIT|IPINIT| +-------------+------+------+------+------+------+------+------+------+ | 4 | 1. Byte Program ID | +-------------+------+------+------+------+------+------+------+------+ | 5 | 2. Byte Program ID | +-------------+------+------+------+------+------+------+------+------+ | 6 | 1. Byte Program Flash Date | +-------------+------+------+------+------+------+------+------+------+ | 7 | 2. Byte Program Flash Date | +-------------+------+------+------+------+------+------+------+------+
- MSTART:
- MCA is started
- ASTART:
- Autostart is enabled
- MCARUN:
- MCA is running
- EXLRUN:
- Bootloader is running
- INIT:
- UCoM is initialized
- PROG:
- Programming is enabled
- OPINT:
- State of init-pin (outgoing)
- IPINT:
- State of init-pin (incoming)
DSP description (multiple packages) String transmission packages containing the description
- Response:
- None.
6.1.6.10 PC_REPORT
- Meaning:
- List all DSPs that are listening over CAN-Bus. (only used for debugging) It is similar to the PC_RESET command, only it will not actually reset the DSP.
- Data:
- None.
- Response:
- DSPs should answer with DSP_REPORT0 - DSP_REPORT3.
6.1.6.11 PC_INIT
- Meaning:
- Initialize the target DSP.
- Data:
- None.
- Response:
- DSP should answer with DSP_INITACK.
6.1.6.12 PC_PROG
- Meaning:
- Start a cycle to transmit program data. (there are 2 cycles needed)
- Data:
- 8 Packages each 8byte payload of program data.
- Response:
- None.
6.1.6.13 PC_START
6.1.6.14 MCA_PC_CI
6.1.6.15 MCA_DSP_SO
6.1.6.16 MCA_PC_PAR
6.1.6.17 DSP_REPORT0 - DSP_REPORT3
- Meaning:
- Answer to reset command.
- Data:
- 1 byte UCoM id
- Response:
- None.
6.1.6.18 MCA_DSP_READY
6.1.6.19 MCA_PC_START
6.1.6.20 MCA_DUMP_IO_DESCRIPTION
When send by PC:
- Meaning:
- Dump description of CI/SO/PARA
- Data:
- None.
- Response:
- Target DSP sends MCA_DUMP_IO_DESCRIPTION messages.
When send by DSP:
- Meaning:
- Flag for packages that contain edge/parameter descriptions.
- Data:
- Multiple Packages with the same flag, number of descriptions for each type is contained in first package.
CI/SO/PAR dimensions (1 package)
+------+-----------------------+ | Byte | Meaning | +======+=======================+ | 0 | 1. Byte CI dimension | +------+-----------------------+ | 1 | 2. Byte CI dimension | +------+-----------------------+ | 2 | 1. Byte SO dimension | +------+-----------------------+ | 3 | 2. Byte SO dimension | +------+-----------------------+ | 4 | 1. Byte PAR dimension | +------+-----------------------+ | 5 | 2. Byte PAR dimension | +------+-----------------------+
DSP description (multiple packages)
String transmission packages containing the description of the DSP.
CI descriptions (multiple packages)
For each CI one string transmitted by string transmission packages.
SO descriptions (multiple packages)
For each SO one string transmitted by string transmission packages.
PARAM descriptions (multiple packages)
For each PARAM one string transmitted by string transmission packages.
- Response:
- None
6.1.6.21 MCA_DUMP_CI
- Meaning:
- Dump initial values that should be send as CI to the DSP.
- Data:
- None
- Response:
- DSP should answer with MCA_DSP_CI packages.
6.1.6.22 MCA_DSP_CI
- Meaning:
- Transmit initial values for PC to send over CAN as CI.
- Data:
CI-dimension / 3 packages containing each 3 initial values.
- Response:
None.
6.1.6.23 MCA_ADMIN_DATA
When send by the PC: Meaning: ~ Set state of MCA module on DSP.
When send by the DSP: Meaning: ~ Current state of the DSP.
(Data format is the same for sending an receiving)
- Data:
- For all targetet DSPs each being
0
or1
.
+------+-----------------------+
| Byte | Meaning |
+======+=======================+
| 0 | 1. run state |
+------+-----------------------+
| 1 | 2. active state |
+------+-----------------------+
| 2 | 2. debug state |
+------+-----------------------+
| 3 | 2. global debug state |
+------+-----------------------+
- Response:
- None.
6.1.6.24 MCA_DEBUG_MSG
- Meaning:
- DSP sends debug message to PC.
- Data:
- String transmission.
- Response:
- None
6.1.6.25 MCA_ALIVE
When send from PC: Meaning: ~ PC is still alive. (should be send all 500ms to all DSPs) Data: ~ None Response: ~ None
When send from DSP: Meaning: ~ DSP is still alive. (should be received all 1000ms) Data: ~ None. Respone: ~ None.
6.2 String transmission packages
Strings are transmitted in the following way:
First Package, data frame format:
+------+-----------------------+
| Byte | Meaning |
+======+=======================+
| 0 | 1. Byte num msgs |
+------+-----------------------+
| 1 | 2. Byte num msgs |
+------+-----------------------+
Rest of packages, data frame format:
+------+-----------------------+
| Byte | Meaning |
+======+=======================+
| 0 | string data byte |
+------+-----------------------+
| ... | ... |
+------+-----------------------+
| DLC | string data byte |
+------+-----------------------+
6.3 SO/CI/PAR transmission packages
For the n-th package:
+------+-----------------------+
| Byte | Meaning |
+======+=======================+
| 0 | 1. Byte buffer offset |
+------+-----------------------+
| 1 | 2. Byte buffer offset |
+------+-----------------------+
| 2 | 1. Byte buf[n] |
+------+-----------------------+
| 3 | 2. Byte buf[n] |
+------+-----------------------+
| 4 | 1. Byte buf[n+1] |
+------+-----------------------+
| 5 | 2. Byte buf[n+1] |
+------+-----------------------+
| 6 | 1. Byte buf[n+2] |
+------+-----------------------+
| 7 | 2. Byte buf[n+2] |
+------+-----------------------+
6.4 DSP Error codes
Name | Number | Cause |
---|---|---|
DSP_ERROR_CHECKSUM | 1 | Checksum error. |
DSP_ERROR_MEM_PROTECTED | 2 | Memory area disabled or protected. |
DSP_ERROR_FLASH | 3 | Error while flashing. |
DSP_ERROR_OVERRUN | 4 | Buffer overrun |
DSP_ERROR_DATA | 5 | Invalid dataheader |
DSP_ERROR_CAN_TRANSMIT | 6 | CAN transmission error. |
DSP_ERROR_CAN_RECEIVE | 7 | CAN receive error. |
DSP_ERROR_CAN_OVERRUN | 8 | CAN buffer overrun. |
DSP_ERROR_REINIT | 9 | Previous init request was not acknowledged. |
DSP_ERROR_EXLOAD_CYCLE | 10 | ExLoading failed. |
DSP_ERROR_AUTOSTART_FORBIDDEN | 11 | Autostart forbidden. No application or exloader in program flash. |