modm API documentation
Sensor Actuator Bus Version 2 (SAB2)


class  modm::sab2::Interface< Device, N >
 SAB2 interface More...


enum  modm::sab2::Error { modm::sab2::ERROR_GENERAL_ERROR = 0x00, modm::sab2::ERROR_NO_ACTION = 0x01, modm::sab2::ERROR_WRONG_PAYLOAD_LENGTH = 0x02, modm::sab2::ERROR_NO_RESPONSE = 0x03 }
 Error code. More...


const uint8_t modm::sab2::maxPayloadLength = 32
 Maximum length for the payload.

Detailed Description

lbuild module: modm:communication:sab2

The SAB (**S**ensor **A**ctuator **B**us) is a simple master-slave bus system. It is primarily used to query simple sensors and control actuators inside our robots.

One master can communicate with up to 32 slaves. The slaves are only allowed to transmit after a direct request by the master. They may signal an event by an extra IO line, but this depends on the slave.






7 6 5 4 3 2 1 0
| Flags | ADDRESS |
Flags | Meaning
0 0 | request by the master
0 1 | reserved
1 0 | negative response from the slave (NACK)
1 1 | positive response from the slave (ACK)

The second bit is always false when the master is transmitting. In the other direction, when the slaves are responding, the second bit has to following meaning:

Electrical characteristics

Between different boards CAN transceivers are used. Compared to RS485 the CAN transceivers have the advantage to work without a separate direction input. You can just connected the transceiver directly to the UART of your microcontroller.

Within a single PCB, standard digital levels are used (either 0-3,3V or 0-5V) in a multi-drop configuration. Meaning it does not allow multiple drivers but multiple receivers. The idle state of a UART transmission line is high, so standard TTL-AND gates have to be used for bundling transmission lines from multiple slaves.

Both approaches can be combined to reduce the number of needed CAN transceivers on a single board. Between two boards you should always use transceivers and therefore differential signaling to improve noise immunity.

The signal lines to indicate events by the slave are strict optional, you may or may not use them (if the slave provides them).

Enumeration Type Documentation

Error code.

Error codes below 0x20 are reserved for the system. Every other code may be used by user.

Enum ValuesDocumentation

Universal error code.

Use this code if you're not sure what error to signal. If the user should react to the error code, create a specific one for the given problem.


No corresponding action found for this command.


Unexpected payload length.

The payload length of the received message differs from the expected length for the given command.


No response given by the user.

This error code is generated when no response method is called by the user during an action callback.