Arm Mbed OS support forum

How to interface CAN Bus with Smart Actuator

Hi I’m new to Mbed
Is there anyone have ever interface a smart actuator(RMD-X8) with CAN bus.
Right now I know protocol of the actuator but I don’t know how to start coding to drive this actuator and there is no tutorial too.
I’m using NUCLEO F446RE
Thank you.

Hi there,

if you are newbie, it is good to start with Mbed’s documentation - Mbed OS quick start.
I saw a video about that part and it looks like a nice toy but a little expensive for me.

For the start you need next to your board:

I tried to write only a simple program, which ask about a current PID setting of servo, it wait for response and then it end. Keep it mind it is only experimental code according to documents above, I not have this hardware.

#include "mbed.h"

#define DEVICE_CAN_ID 141 //identifier: 0x140+ID(1-32)

DigitalOut led1(LED1);
CAN can(PB_8,PB_9,1000000); //I am not sure with with frequency but  in the video 1000kbps is used
char data[] = {0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //read PID param. cmd

int main()
    if (can.write(CANMessage(DEVICE_CAN_ID, data))) { 
        CANMessage msg;
        while (1) {
            if ( {
                // Printing what was read
                printf("Message received:[ ID: %9x",;
                printf(" Length: %d", msg.len);
                printf(" Command: %2x",[0]);
                //printf(" %2x",[1]); // Null
                printf("Position loop Kp %2x",[2]);
                printf("Position loop Ki %2x",[3]);
                printf("Speed loop Kp %2x",[4]);
                printf("Speed loop Ki %2x",[5]);
                printf("Torque loop Kp %2x",[6]);
                printf("Torque loop Ki %2x",[7]);
                printf("CanBus Type: %d", msg.type);           // 0 = data, 1 = remote
                printf("Format: %d ]\r\n", msg.format);        // 0 = standard, 1 = extended
            led1 = !led1;
        printf("Write error\n");
    printf("Rrogram end!\n");

BR, Jan

1 Like

Thank you so much.