You are here

Able to read CAN messages from VESC but cannot write messages to CAN Bus.

4 posts / 0 new
Last post
willd3543
Offline
Last seen: 2 months 1 week ago
VESC Free
Joined: 2022-11-22 02:29
Posts: 2
Able to read CAN messages from VESC but cannot write messages to CAN Bus.

Using a microcontroller (ESP32S3) I am able to read CAN messages sent from the VESC (Status 1, 2, 3, 4, and 5). However, when writing CAN commands to the VESC controller my motors are unresponsive, I am wondering if there is a configuration in my VESC tool that is blocking write commands to the CAN bus or some other explanation of why the motors won’t spin? I have confirmed that the motors operate fine when sending control commands via keyboard control in the VESC Tool. Below is my CAN configuration in the VESC Tool. Both the VESC and microcontroller have a CAN baud rate of 250K and the VESC address ID is 10 (0x0A).

 

 

On the microcontroller side I have tried both my own script as well as the VESC_CAN_BUS_Arduino example by Craigg96: https://github.com/craigg96/vesc_can_bus_arduino 

 

In both situations I am able to read the CAN status messages being sent out from the VESC at 50Hz but the motors are unresponsive when I write commands to change RPM, duty cycle, or current. A code snippet example of an RPM command is as follows (see GitHub repo, linked above, for full script example):

void vesc_set_erpm(float erpm){
  uint32_t set_value = erpm;
  uint8_t buffer[4];
  buffer[0] = (set_value >> 24) & 0xFF;
  buffer[1] = (set_value >> 16) & 0xFF;
  buffer[2] = (set_value  >> 8  )  & 0xFF;
  buffer[3] = set_value & 0xFF;
  byte sndStat = CAN.sendMsgBuf(0x0000030A, 1, 4, buffer);  
}

 

This format follows the data and address structure for a VESC with CAN Address 10 (0x0A) as outlined in the official documentation: https://github.com/vedderb/bldc/blob/master/documentation/comm_can.md 

 

 

Additional documentation relating to the problem that I have consulted:

Similar problem (no relevant solution): https://vesc-project.com/node/2759

Information on VESC CAN structure: https://dongilc.gitbook.io/openrobot-inc/tutorials/control-with-can 

More information on the VESC CAN structure: https://electric-skateboard.builders/t/vesc-can-message-structure/98092/17 

 

Hardware setup up:

T-Display-S3 (ESP32S3 chip) wired to custom a PCB with 3V3 - 5V logic level shifter and MCP2125 CAN controller (system validated to work okay with other CAN devices). Microcontroller/PCB is connected to the CAN terminals on an EDU VESC Six; both ends of the CAN bus have 120 Ohm termination resistors.

 

Software:

VESC Tool with firmware 6.02 loaded

 

A related issue I am encountering is:

When selecting the “CAN Forward” button in the VESC tool (bottom icon on the right-side toolbar) I get the following warning: “No CAN device is selected. Go to the connection page and select one.” However, after pressing “Scan” under Connection/CAN Bus/Scan, I receive the warning “CAN bus is not enabled in this build of the VESC Tool”. As far as I can tell I have the most recent build of the VESC Tool (I have uninstalled and reinstalled the software as well). Likewise, under “VESC Dev Tools/CAN Analyzer” I am unable to see any CAN messages being sent or received. Is this behavior expected? Or is it related to (and a potential source of) my main issue in writing CAN messages?

benjamin
Offline
Last seen: 3 days 9 hours ago
VESC FreeVESC OriginalVESC Platinum
Joined: 2016-12-26 15:20
Posts: 490

Can you connect another VESC over CAN-bus and see if both show up in the lower left corner in VESC Tool when connected over USB on any of them?

willd3543
Offline
Last seen: 2 months 1 week ago
VESC Free
Joined: 2022-11-22 02:29
Posts: 2

I've tried connecting a second EDU VESC Six over the CAN-bus to the first EDU VESC Six, yet I cannot see the second device listed after refreshing "CAN Scan". I have confirmed this second VESC is functional and works when the USB is connected directly to it. I am fairly confident my CAN-bus wiring is correct as I am still able to receive CAN messages on my microcontroller. I have the 5V, CANH, CANL, GND directly connected to each other with two termination resistors at each end (I have also tried the wiring without the 5V pins connected, with no change).

For rigor, I also tested connecting a VESC Unity FocBox over the CAN-bus to the first EDU VESC Six and still I do not see it listed on the CAN Devices box in VESC Tool.

Finally, I also tested using the Beta VESC Tool (Original) and updated the VESC firmware to 6.05, all with the same results. I am not sure if this helps narrowing down the source of my troubles but I feel like I should be able to detect other VESCs on the CAN-Bus through the software - just not sure why I can't.

benjamin
Offline
Last seen: 3 days 9 hours ago
VESC FreeVESC OriginalVESC Platinum
Joined: 2016-12-26 15:20
Posts: 490

You should only connect CANH and CANL, not 5V and GND. There are also built-in termination resistors in the VESCs, so adding extra resistors is not needed. If the extra resistors have too low resistance that can even cause problems.