vedderb / bldc

The VESC motor control firmware
2.18k stars 1.35k forks source link

Get ESC faults via CAN #740

Open drewskoots opened 3 months ago

drewskoots commented 3 months ago

Is there a way to get faults from an ESC via the CAN network? It seems that VESC tool is able to do so, but in the VESC CAN documentation, it isn't documented anywhere.

DovPearX commented 2 months ago

You can send a command via CAN to download data and the entire structure along with error codes will be there. Exactly the same way as in the vesc uart libraries.

manmountain commented 2 months ago

What can command to use for requesting fault codes? I cant find anything like that from datypes.h CAN_PACKET_ID enum

DovPearX commented 2 months ago

When using CAN, fill the receive buffer with the COMM_GET_VALUES command. Of course, you also need to make sure that the device you are sending from can receive the data in the commands.c file.

void comm_can_get_values(uint8_t controller_id) {

    int32_t send_index = 0;

    uint8_t buffer[4];

    buffer[send_index++] = COMM_GET_VALUES;

    comm_can_send_buffer(controller_id, buffer, send_index, 3);

}

It returns the mc_values structure which contains fault code. 133-164 and 1308-1332 line in datatypes.h