Mab Robotics MD80 x CANdle User manual

TABLE OF CONTENTS
Ecosystem overview 3
MD80 3
CANdle and CANdle HAT 3
Safety information 4
Operating conditions (MD80 and CANdle) 5
Hardware setup 5
Quick startup guide 5
MD80 5
General parameters 5
Connectors pinout 6
Control modes 7
Controller tuning 10
Safety limits 11
FDCAN Watchdog 12
Measurements 13
Calibration 13
CANdle and CANdle HAT 14
Principle of operation 15
USB bus 16
SPI bus 16
UART bus 16
Using CANdle and CANdle HAT 16
Latency 18
Soware Pack 20
CANdle C++ library 20
MDtool 22
CANdle ROS/ROS2 nodes 24
MD80 update tool - MAB CAN Flasher 30
CANdle update tool - MAB USB Flasher 31
Common Issues and FAQ 32
How to check if my motor is operating properly 32
Motor not soldered properly 32
Failed calibration 32
Lack of FDCAN termination 32
Different FDCAN speeds between actuators 32
Too low torque bandwidth setting 33
www.mabrobotics.pl

1. Ecosystem overview
MD80 x CANdle is a system of brushless actuator controllers (MD80) and translator devices (CANdle)
used for interfacing with them. MD80-based actuators can be used in advanced robotic projects like
quadrupedal robots, robotic manipulators, exoskeletons, gimbals, and many more.
1.1. MD80
MD80 is a highly integrated brushless motor controller. It can be interfaced with a great variety of
motors to turn them into advanced servo actuators. MD80 can work with both direct drive (no gearbox) and
geared motors.
MD80 brushless controller
1.2. CANdle and CANdle HAT
CANdle (CAN + dongle) is a translator device between the host controller and the MD80 drivers. It is
possible to interface CANdle with a regular PC over USB bus or CANdle HAT with SBCs (such as Raspberry PI)
over USB, SPI or UART bus.
CANdle Device CANdle HAT device
www.mabrobotics.pl

1.3. Safety information
The instructions set out below must be read carefully before the initial commissioning or installation to
raise awareness of potential risks and hazards, and to prevent injury to personnel and/or property damage.
To ensure safety when operating this servo drive, it is mandatory to follow the procedures included in this
manual. The information provided is intended to protect users and their working area when using the device,
as well as other hardware that may be connected to it.
Electric servo drives are dangerous: The following statements should be considered to avoid serious injury
to individuals and/or damage to the equipment:
●Do not touch the power terminals of the device (supply and phases) as they can carry dangerously
high voltages.
●Never connect or disconnect the device while the power supply is ON to prevent danger to
personnel, the formation of electric arcs, or unwanted electrical contacts.
●Disconnect the drive from all power sources before proceeding with any wiring change.
●The surface of the device may exceed 100 ºC during operation and may cause severe burns to direct
touch.
●Aer turning OFF and disconnecting all power sources from the equipment, wait at least 10 minutes
before touching any parts of the device, as it can remain electrically charged or hot.
●Do not remove the casing of the device.
The following statements should be considered to avoid serious injury to those individuals performing the
procedures and/or damage to the equipment:
●Always comply with the connection conditions and technical specifications. Especially regarding
wire cross-section and grounding.
●Some components become electrically charged during and aer the operation.
●The power supply connected to this controller should comply with the parameters specified in this
manual.
●When connecting this drive to an approved power source, do so through a line that is separate from
any possible dangerous voltages, using the necessary insulation in accordance with safety
standards.
●High-performance motion control equipment can move rapidly with very high forces. An
unexpected motion may occur especially during product commissioning. Keep clear of any
operational machinery and never touch them while they are working.
●Do not make any connections to any internal circuitry. Only connections to designated connectors
are allowed.
●All service and maintenance must be performed by qualified personnel.
●Before turning on the drive, check that all safety precautions have been followed, as well as the
installation procedures.
www.mabrobotics.pl

1.4. Operating conditions (MD80 and CANdle)
Ambient Temperature (Operating)
0°C - 40°C
Ambient Temperature (non-operating)
0°C - 60°C
Maximum Humidity (Operating)
up to 95%, non-condensing at 40 ºC
Maximum Humidity (Non-Operating)
up to 95%, non-condensing at 60 ºC
Altitude (Operating)
-400 m to 2000 m
1.5. Hardware setup
A typical hardware connection/wiring scheme is presented in the picture below:
CANdle MD80-actuator string (USB bus)
CANdle HAT MD80-actuator string (SPI/UART bus using Raspberry Pi 4)
www.mabrobotics.pl

1.6. Before first use
Here are some things to look out for while playing with the MD80 x CANdle ecosystem for the first time:
1. Always stay cautious when dealing with actuators. Even though they don't seem like it, they may
severely hurt you when unintentional movement occurs. Itʼs recommended to fix the actuator to the
workbench.
2. Get accustomed to the safety limits section of this document. While developing your application be
sure to keep the limits low, and only if you are sure you know what you're doing - increase the limits.
3. We recommend using power supply sources that have the ability to work in two quadrants -
meaning they can supply and dissipate some of the energy produced by the motor in case it works
as a generator. Old trafo-based power supplies usually block current coming into the power supply,
causing overvoltage events on the MD80s. The best choice is to use LiPo batteries or at least SMPS
power supplies.
1.7. Quick startup guide
Please see the quick startup guide on our YouTube channel: Md80 x CANdle - Getting Started Tutorial
2. MD80
2.1. General parameters
MD80 is a brushless servo drive. It may come with a variety of motors and reductors, that can be precisely
matched to the usersʼ specifications. All MD80 variants are using an advanced motor control algorithm (FOC),
a high-resolution encoder, a high-speed FDCAN communication bus, and a common communication
interface. The servo drives have an integrated high-frequency position PID controller (at 1 kHz), velocity PID
controller (at 5 kHz), and impedance controller (at 40 kHz), as well as a direct torque controller. MD80 also
features a daisy-chaining mechanism, for easy connection of many drives in a single control network.
Parameter
Value
Input Voltage
18 - 28 VDC
Nominal Input Voltage
24 VDC
Max Input Current
20 A
Max Continuous Phase Current
20 A
Max Peak Phase Current (t = 4 s)
40 A
FDCAN Baudrate (adjustable)
1/2/5/8 Mbps
Position PID Controller Execution Frequency
1 kHz
Velocity PID Controller Execution Frequency
5 kHz
Impedance Controller ExecutionFrequency
40 kHz
Torque Control Execution Frequency
40 kHz
Torque Bandwidth (adjustable)
50 Hz - 2.5 kHz
www.mabrobotics.pl

2.2. Connectors pinout
The connectors used in the system on the CANFD side are MOLEX Micro-Fit series 3.0. Both connectors are
connected in parallel for easy daisy-chaining. The connector pinout is presented below:
The colors of the corresponding wires in the Molex socket, as supplied by MAB (looking from the side of the
wires):
2.3. Control modes
TL;DR: MD80 x CANdle - motion modes
To control the motor sha with the userʼs command MD80 is equipped with multiple control
loops. All controllers are based on a regular PID controller design with an anti-windup block. The saturator
(anti-windup) is an additional module that acts as a limiter to the ʻIʼ part of the controller, as in many
systems, the error integration may grow to very large numbers, completely overwhelming ʻPʼ and ʻDʼ parts of
the controller.
www.mabrobotics.pl

Velocity PID
Velocity PID controller calculates velocity error based on target velocity (set by user) and estimated
velocity read from the encoder. Its output is a torque command for the internal current/torque controller.
The parameters of the controller are:
●Velocity Target (in [rad/s])
●kP (proportional gain)
●kI (integral gain)
●kD (derivative gain)
●I windup (maximal output of an integral part in[Nm])
●Max output (in [Nm])
Position PID
Position PID mode is the most common controller mode used in industrial servo applications. In MD80, it is
implemented as a cascaded PID controller. This means that the controller is working in two stages, firstly
the position error is calculated, it is then passed to the Position PID, which outputs target velocity. This value
is then passed as an input to the Velocity PID controller, which outputs commanded torque. This mode uses
both Position PID and Velocity PID and thus needs the following parameters:
www.mabrobotics.pl

For Position PID
●Position Target (in [rad])
●kP (proportional gain)
●kI (integral gain)
●kD (derivative gain)
●I windup (maximal output of an integral part in [rad/s])
●Max output (in [rad/s])
For Velocity PID:
●Velocity Target (in [rad/s])
●kP (proportional gain)
●kI (integral gain)
●kD (derivative gain)
●I windup (maximal output of an integral part in[Nm])
●Max output (in [Nm])
To properly tune the controller, it is recommended to first tune the velocity controller (in Velocity PID mode),
and then the Position PID. The controller can be described with a diagram:
Impedance PD
Impedance Control mode is a popular choice for mobile or legged robots, as well as for any compliant
mechanism. The main idea behind it is to mimic the behavior of a torsional spring with variable stiffness and
damping. The parameters of the controller are:
●Position Target
●Velocity Target
●kP (position gain)
●kD (velocity gain)
●Torque Feed Forward (Torque FF)
The torque output is proportional to the position error and velocity error and additionally supplemented
with a torque command from the user. Here are some of the most common applications for this control
mode:
●Spring-damper mechanism - when Velocity Target is set to 0, Impedance Controllers kP gain acts
as the virtual spring stiffness and kD as its damping coefficient.
Example use case: a variable suspension for a wheeled robot, where suspension stiffness can be
regulated by kP, damping by kD, and height (clearance) by changing the Target Position;
●High-frequency torque controller, where its Targets and Gains can act as stabilizing agents to the
torque command.
Example use case: In legged robots, force control can be achieved by advanced control algorithms,
which usually operate at rates below 100 Hz. It is usually enough to stabilize the robot but too slow
to avoid vibrations. Knowing desired robot's joint positions, velocities, and torques, drives can be
set to produce the proper torque and hold the position/velocity with small gains. This would
www.mabrobotics.pl

compensate for any high-frequency oscillations (vibrations) that may occur, as the Impedance
controller works at 40kHz (much faster than <100 Hz).
●Raw torque controller - when kP and kD are set to zero, the torque_ff command is equal to the
output controller torque.
The impedance controller is quite simple and works according to the schematic below:
2.4. Controller tuning
TL;DR: The best way to get started with tuning is to copy the default gains and tweak them. You can
treat this section as our recommendation for tuning the controllers, but online articles can be useful as
well (link)
The first step to correctly set up the gains is to start with our default gains. There are three sets of default
gains that are set on each motor power up and thus they allow for restoring the actuator to a default state in
case some gains were set incorrectly by the user. These gains are also a great starting point for user
modifications when the actuator has to be used in a specific application requiring high positioning accuracy
or very dynamic movements.
Note: Default gains are set to work with CANdle examples. This way they can be assumed to be
universal but it does not have to always be the case.
Note: When something does go wrong during the tuning process just power-cycle the actuator - the
default gains will be restored.
Warning: Always keep your safety limits low when experimenting with gains. Gains not suitable for
your system may cause oscillations and unstable operation of the MD80-based actuators.
Velocity PID
The velocity PID controller can be used to command different velocity profiles to the motor. This mode uses
a regular PID controller architecture and has four user-defined parameters: kP, kI, kD, and windup. Since
velocity readout is somewhat noisy, it is recommended to keep the kP value as low as possible and play with
kI gain. It is necessary to find the sweet spot that makes the actuator response resistant to disturbances, but
also not too noisy (too high kP gain may introduce oscillations). Usually, the kI gain is set to a higher value,
however, do not treat it as a rule of thumb. Setting the kI gain to a too high value can cause an overshoot
when the target velocity is changed rapidly. The kD gain may be used to partially overcome this issue. The
windup parameter is used to limit the integral action which could potentially rise to high values when
velocity error is present for longer periods.
www.mabrobotics.pl

Position PID
Position PID is the mode used when high positioning accuracy is required. Usually, no compliance is
assumed in this mode, so the actuator will try to hold the read position as close to the commanded value as
possible. One must be aware that position mode is actually made out of two PID controllers - the inner loop
which is the velocity PID discussed earlier and the position PID working on top of the velocity loop. This is
why it is essential to first take care of the velocity controller, considering the highest velocity that may occur
in the system between the corresponding position commands in time. When both high and very low
velocities are needed in a system it might be necessary to change the velocity PID gains on the fly, depending
on the commanded velocity in each trajectory segment. When the velocity PID is ready the next step is to
adjust the position PID gains so that a required actuator response is achieved. Since position readout is
much less noisy compared to velocity it is recommended to first pick a kP value that will allow the motor to
get to a setpoint position. In the next step kI and kD can be varied, together with the kI limiting factor
(windup). One should remember the position PID output limit which is called MaxVelocity. This is a
parameter that will limit the maximum commanded velocity and thus may limit actuator performance. It
should be set to a value that is close to the actual trajectory segment maximum achievable velocity. Making
it too high when very low velocities are required may result in oscillations.
Impedance PD
The impedance mode is relatively straightforward to get started with since there are only two main
parameters that affect the response of the actuator. The easiest way is to think of a motor as a combination
of a torsional spring with a damper, where kP is the spring constant, and kD is the damping coefficient. The
higher the kP gain the more accurate positioning is achieved, but also, when itʼs set too high oscillations may
be introduced. This is why a damping coefficient should be introduced. It makes the response more
“smooth”, usually less aggressive, and minimizes overshoot. It can be thought of as placing the motor in a
viscous fluid where the viscosity of the fluid is the damping coefficient. This mode, however, can introduce
steady-state error due to the lack of integral term. If high positioning accuracy is needed be sure to read
about position PID mode.
Current PI
Current/torque PI is the lowest level controller. Its gains are not directly user-configurable, however, they can
be modified using the bandwidth parameter. Please see the calibration section for more insight on the topic.
2.5. Safety limits
There are safety limits imposed on the maximum phase current as well as maximum torque and velocity to
ensure a safe operation of the drive. Safety limits are there to protect the controller and the motor from
overheating and the surrounding environment from too-powerful actuator movements.
Warning: setting the max current limit to above the maximum continuous current may damage the
MD80 controller if the maximum torque is commanded for a prolonged period.
www.mabrobotics.pl

Letʼs start with the max current limit.
This setting limits the maximum current (and thus torque) the motor can output. It is the last
user-configurable limit in the control scheme. The maximum current is set using the mdtool config
current command, and by default, it is usually set to 10A. This setting can be saved in the non-volatile
memory so that it is always loaded on the actuator power-up. To estimate the maximum current setting for a
particular motor, you should use the following formula:
where
- calculated current in Amps
desired maximum torque
gear ratio
motorʼs torque constant
for example letʼs calculate the max current limit for AK80-9 motor, for a 2Nm max torque:
t
Note: usually this limit should be set to the highest peak torque that is allowed in the system so that it
doesn't limit the actuator performance.
Now, to put this value into the MD80 please refer to mdtool config current command. Donʼt forget to
save it with the mdtool config save command.
The other limits are the max torque and max velocity parameters, which are set from the user script level.
www.mabrobotics.pl

These parameters allow restricting the output of high-level controllers - the position PID, velocity PID, and
impedance PD controllers. These limits are applied before the max current limit, so even when set high they
will not lead to a hazardous situation until the max current is fixed at a safe level. The max velocity limit is
respected only in position PID mode, whereas the max torque limit is respected in all motion modes. Check
out the controller tuning section for more information.
Note: if the torque bandwidth is set to a low value it is possible to read torque values that are above
limits when external torque is applied (for example during impacts). This is only true in transition
states - when the load is constant the limits will work as expected. This is because with low torque
bandwidth the internal torque PI controllers may be too slow to compensate for rapidly changing
torque setpoint when hitting the torque/current limit. If you care about accurate torque readout be sure to play
with the torque bandwidth parameter and possibly increase it from the default level.
2.6. FDCAN Watchdog
MD80 features an FDCAN Watchdog Timer. This timer will shut down the drive stage when no FDCAN
frame has been received in a specified time. This is to protect the drive and its surroundings in an event
of loss of communications, for example by physical damage to the wiring. By default, the watchdog is
set to 250ms. This time can be set to any value in the range of 1 to 2000ms using mdtool config can
command. When the watchdog is set to 0, it will disable the timer, however, this can lead to dangerous
situations, and it is not a recommended way of operating MD80.
Warning: we do not recommend disabling the CAN watchdog timer.
2.7. Measurements
MD80 is equipped with sensors that allow for measuring the motor position, velocity, and torque. Whether
the motor has an integrated gearbox or not, the position, velocity, and torque are in the output sha
reference frame. This means that changing the position from 0.0 to 2𝞹 radians, will result in approximately
one rotation of the motor for direct-drive (gearless) servos and approximately one rotation of the gearbox
output sha for geared motors.
Position
To measure the position of the rotor an MD80 uses an internal magnetic encoder. The resolution of the
encoder is 14 bits (16384 counts per rotation). The drive aggregates all the measurements to provide
multi-rotation positional feedback. The reference position (0.0 rad) is set by the user and stored in the
non-volatile memory. Please see mdtool config zero command for more information on how to set the
desired zero position.
Note: When using geared actuators with gear ratios above 1:1 it is not possible to determine the
position aer startup unambiguously, since the motor completes multiple rotations per single
rotation of the output sha. For example, for a 2:1 gearbox, there are two sections within a single
output sha rotation where the motor sha is in the same position. Unless the motor is placed in the wrong
“section” during startup the absolute encoder functionality will work.
Velocity
www.mabrobotics.pl

The velocity is estimated by measuring position change in time, at a frequency of 40kHz. The measurements
are then filtered using a low-pass filter with a cut-off frequency of 5 kHz since the position differentiation
method introduces noise.
Torque
Actuator torque is estimated by measuring motor phase currents. This method can be used on low gear ratio
actuators (preferably below 9:1), that are easily back drivable, to get an estimate of the torque applied by the
motor. In applications with higher gear ratios, the torque readout might be not as accurate due to excessive
friction in the gearbox.
2.8. Calibration
Calibration is performed when the MD80 controller is first mounted to the motor. It has two stages during
which it measures specific parameters of the setup.
Note: the calibration has to be performed on a motor that is free to rotate with no load attached to its
output sha. If the calibration fails, you will see errors when executing the mdtool setup
diagnostic command. If the failure is essential to the motorʼs operation the MD80 will remain
disabled till the next calibration attempt.
Encoder eccentricity
Encoder eccentricity is the first measurement that takes place. During this part, the motor performs a single
rotation in both directions to assess the amount of error due to non-axial encoder placement.
Torque bandwidth
Even though the torque command on MD80 controllers seems to be applied instantaneously, in reality, itʼs
not the case. As in every system, thereʼs a response to the command which depends on the system itself and
the controller gains. A parameter called bandwidth was introduced to describe how fast the output of a
system reacts to the changing input. Calibrating the motor for a certain torque bandwidth requires
measuring motor parameters. This happens in the last stage of calibration and it manifests itself as an
audible sound.
The torque bandwidth is set to 50 Hz by default. It can be set to anywhere from 50 Hz to 2.5 kHz,
however it is important to note that higher torque bandwidth causes a higher audible noise level. Please see
the mdtool setup calibration command for more details on calibrating the actuators.
When the system that youʼre designing is a highly dynamic one, you want the torque bandwidth to
be higher than the default setting of 50 Hz. Start by calibrating the drives for 1 kHz torque bandwidth, and if
you see this is still not enough you can increase it further.
3. CANdle and CANdle HAT
CANdle is a translator device used to communicate between MD80 controllers and the host device. Currently,
there are two CANdle versions - CANdle and CANdle HAT.
www.mabrobotics.pl

The first one is a simple version that uses only the USB bus to communicate with the host, whereas the latter
can communicate using USB, SPI, and UART bus, and is easy to integrate with SBCs such as Raspberry PI. The
communication with MD80 controllers is performed using FDCAN bus.
To achieve the fastest communication speeds you should aim for the SPI bus. For more details on the latency
topic please check out the latency section.
Note: currently CANdle supports only Linux operating systems.
3.1. Principle of operation
CANdle can work in two different modes: CONFIG and UPDATE. When in CONFIG mode, it works as a
traditional translator device between two selected buses - USB/SPI/UART and FDCAN. This mode is used to
set up the drives and prepare them for a low latency operation in the UPDATE mode. When the configuration
is done the user calls candle.begin() which starts a low latency continuous connection with the MD80
controllers. In the UPDATE mode, you are not allowed to call the config functions. To make them easier to
recognize, each config function starts with a config keyword. The user exits the UPDATE mode using
candle.end() method.
When in UPDATE mode there are three different speed modes, that select how fast the host should
communicate with the CANdle device:
●NORMAL mode - up to 12 actuators on the bus, the slowest mode
●FAST1 mode - up to 6 actuators on the bus, the faster mode
●FAST2 mode - up to 3 actuators on the bus, the fastest mode
Each mode has a different CANdle <> host communication speed, thus the limit on the possible number of
drives. Please see the latency section for maximum communication speeds in each mode.
www.mabrobotics.pl

Generally, a program using CANdle should follow the workflow below:
Creating a Candle object creates a class that will hold all the data and provides an API for the user. During the
creation of the class, the soware will attach itself to the ttyACMx port used by the CANdle, or SPI/UART bus if
CANdle HAT is considered. It will also perform a reset operation on the device and set up basic parameters.
This ensures that the device is in the known state at the start of the program. When an object is created, the
CANdle is in the CONFIG state.
Now the configuration of the drives can be done. As a rule of thumb, all class methods starting with the word
ʻconfigʼ can be used here. They do not require adding md80 to the update list, just require an ID of the drive
to talk to. This is a good place to set current limits, change FDCAN parameters, or save data to flash.
Note: This is also a good place to call Candle::ping(), this will trigger the CANdle device to send an FDCAN frame
to all valid FDCAN IDs. The method will return a vector of all IDs that have responded. This can be used to check
if all the drives have power and if all communication is set up correctly. Please note that scanning of the entire
ID range will take about 2.5 seconds.
The next step is adding md80s to the update list. To do so, use Candle::addMd80() method, with an FDCAN
ID (drive ID) as an argument. This will trigger CANdle to quickly check if the drive is available on the bus at
the ID, and if it is, the CANdle device will add the drive to its internal list and send an acknowledgment to the
CANdle lib. If the drive is successfully added the addMd80() method will add this particular md80 to its
internal vector for future use and return true.
When all drives have been added, the drives should be ready to move. This can be done with methods
starting with the “control(...)” keyword. Firstly the control mode should be set, then zero position set (if
desired), and finally the drives can be enabled by using Candle::controlMd80Enable() method.
Note: sending an ENABLE frame will start the CAN Watchdog Timer. If no commands follow, the drive will shut
itself down.
When all drives are enabled, Candle::begin() can be called. This will set the CANdle (both device and library)
to UPDATE state. The device will immediately start sending command frames to the md80s. From now on the
library will no longer accept config* methods. Right now it is up to the user to decide what to do. Aer the
first 10 milliseconds, the whole md80 vector will be updated with the most recent data from MD80s and the
control code can be executed to start moving the drives.
Individual drives can be accessed via Candle::md80s vector. The vector holds instances of ʻMd80ʼ class, with
methods giving access to every md80 control mode. Latest data from md80ʼs responses can be accessed with
Md80::getPosition(), Md80::getVelocity(), Md80::getTorque(), Md80::getErrorVector().
Note: As the communication is done in the background, it is up to the user to take care of the soware timing
here. If you for example set a position command, but donʼt put any delay aer it, the program will get to an
end, disabling the communication and the servo drives, without you seeing any movement!
www.mabrobotics.pl

When the control code finishes, the Candle::end() method should be called. This will ensure a ʻclean exitʼ
meaning a properly closed communication on both USB and FDCAN side. Candle::begin() can be called later
to resume communication if needed.
3.2. USB bus
The USB bus is the most common one, used in both CANdle and CANdle HAT. This is the slowest
communication bus when it comes to performance, due to the non-realtime nature of the host, however, it's
the easiest one to set up and test. Since the USB communication interface is not well-suited for realtime
applications due to random host delays, the MD80 baudrate is not the limiting factor - you can set it to
1/2/5/8 Mbps and there will be no difference in the update rate.
Note: We highly recommend using the USB bus setup for the first run.
3.3. SPI bus
The SPI bus is only available on CANdle HAT devices. Itʼs the fastest possible bus that can be used to
communicate with the MD80 controllers using CANdle HAT. Together with the RT-PATCHED kernel of the
system, you will get the best performance.
Note: CANdle HAT in SPI mode works with all FDCAN speeds, however, we advise setting it to 8M for the
best performance.
Note: Since it needs some additional configuration on Single Board Computers such as Raspberry PI,
we recommend starting playing with it aer getting accustomed to the ecosystem using the USB bus.
3.4. UART bus
The UART bus is only available on CANdle HAT devices. Its speed on Raspberry PI microcomputers with
CANdle HAT is comparable to that of USB, so it should be only used as an emergency bus when the SPI and
USB ports are not available.
Note: CANdle HAT in UART mode works with all FDCAN speeds, however, we advise setting it to 8M for
the best performance.
3.5. Using CANdle and CANdle HAT
PC (USB bus)
The library does not require any additional soware to be functional, It can work as-is. However, to make full
use of it we recommend using setserial package (for increasing maximal access frequency to the serial port
used for communication with CANdle). To install it please call:
sudo apt install setserial
www.mabrobotics.pl

To enable access to CANdle from userspace, the user should be added to dialout group by calling:
sudo usermod -a -G dialout <user> # where <user> is current username
If this is not possible, devices access level can be granted by:
sudo chmod 777 /dev/ttyACMx # where x is CANdle port number, usually 0
If this is also not possible, programs that use CANdle (including examples), can be launched with sudo.
SBC (USB/SPI/UART)
Running CANdle or CANdle HAT using a USB bus on SBC is identical to running it on a Linux PC (section
above). However, when using SPI or UART a few other requirements have to be met. We will guide you
through the setup process on Raspberry PI 4.
Note: when using SBCs other than Raspberry the process may vary and should be performed
according to the board manual or with the help of the manufacturer.
SPI
To enable the SPI bus you should call:
sudo nano /boot/config.txt
uncomment the following line, save the file
dtparam=spi=on
and reboot:
sudo reboot
to make sure SPI is enabled call:
ls /dev | grep spi
you should see an output similar to this:
spidev0.0
spidev0.1
UART
To enable the UART bus you should call:
sudo nano /boot/config.txt
and add the following lines on the end of the file
enable_uart=1
dtoverlay=disable-bt
www.mabrobotics.pl

aer that open the cmdline.txt
sudo nano /boot/cmdline.txt
and remove the part:
console=serial0,115200
and reboot:
sudo reboot
3.6. Latency
The latency was measured in a real scenario to get the most accurate results. A special flag was embedded
into the MD80 command which the MD80 should return in the next response it sends. This way the whole
route from the host, through CANdle, MD80 and back was profiled in terms of the delay. The setup was tested
on a PC using only USB bus (PC Ideapad Gaming 3 AMD Ryzen 7 4800H) and Raspberry PI 3b+ with RT PATCH
(4.19.71-rt24-v7+) on USB, SPI, and UART bus.
www.mabrobotics.pl

Each mode was tested with the maximum number of actuators i.e NORMAL mode with 12 actuators, FAST1
mode with 6 actuators, and FAST2 with 3 actuators. As can be seen, the SPI bus gives the best results,
reaching over 1 kHz of communication speed in FAST2 mode and 3 actuators. The UART and USB buses
generally give similar results. The division between priority normal and priority high was accomplished using
a script that changes the scheduler priority of the running test program:
CONTROL_PID=$(sudo pidof -s <NAME_OF_YOUR_EXECUTABLE>)
CONTROL_PRIORITY=99
sudo chrt -f -p ${CONTROL_PRIORITY} ${CONTROL_PID}
This script changes the priority only when the program is already running (otherwise it will not work). It can
be used when your program cannot be run directly with sudo - for example it is useful when dealing with
ROS nodes.
You can also embed the following snippet in your C++ code if you can run it with sudo directly:
struct sched_param sp;
memset(&sp, 0, sizeof(sp));
sp.sched_priority = 99;
sched_setscheduler(0, SCHED_FIFO, &sp);
During testing on Raspberry PI SBCs we have found out that isolating a CPU core (isolcpus) specifically for
the CANdle process did not result in a performance increase - rather made it less performant.
4. Soware Pack
The MD80 x CANdle soware pack consists of a few modules. All of them are based on the main CANdle C++
library which takes care of the low-level communication and provides API for high-level soware.
4.1. CANdle C++ library
CANdle C++ library is the base module of soware that all other modules are based on. It takes care of
low-level communication between the host and the MD80 controllers. Using the CANdle C++ library directly
is the best option to reach the full performance of the drives when it comes to communication frequency
between the host and MD80 controllers.
www.mabrobotics.pl
Table of contents
Popular Robotics manuals by other brands

SuperDroid Robots
SuperDroid Robots IG42-DB2 Assembly operation maintenance

ABB
ABB IRBP A Applications manual

EFORT
EFORT ER180-4-3200 Quick operation manual

Nonscio
Nonscio ScioBot 1.0 user manual

Sparkfun Electronics
Sparkfun Electronics RedBot Getting started

Mover-Technology
Mover-Technology CT 1500 manual

JS Automation
JS Automation MPC3042A/3042AL user manual

HEBI Robotics
HEBI Robotics Hexapod R Series Assembly instructions

Parallax
Parallax Boe-Bot Assembly

Thermo Scientific
Thermo Scientific Heraeus Cryofuge 5500i instruction manual

Hyundai Heavy Industries
Hyundai Heavy Industries HCA Series instruction manual

ABB
ABB IRB 920 product manual