You are here

Can't receive status message via CAN bus

5 posts / 0 new
Last post
IanG
Offline
Last seen: 4 years 3 months ago
Joined: 2020-03-05 04:23
Posts: 7
Can't receive status message via CAN bus

I am using V6.6 and FW4.2, everything works good. And I am trying to control via Can bus, I know how to set RPM, Current, Duty cycle and Position.

In the test last week, I suddenly can not receive the status broadcast after I burned new FW4.2 which I modified, the strange thing is I also can not receive it when I burned the original FW4.2.

In the past test, I always can receive Four Messages after I powered on the VESC, and there are: 000009XX  000010XX  00000EXX 00000FXX.

But now, I can receive nothing after I powered on. What the possible reason? THX

 

IanG
Offline
Last seen: 4 years 3 months ago
Joined: 2020-03-05 04:23
Posts: 7

Problem solved!

It must be run the set up FOC(run detection) again after burned the new FW, rather than detect the parameters directly.

IanG

logicthinking
Offline
Last seen: 4 years 1 month ago
Joined: 2020-10-12 17:48
Posts: 1

Hi IanG,
how did you manage to send messages via CAN? I have a setup with an arduino nano and an MCP2515 Module. I am sending an ID 0x0000033D for controlling the rpm of the node with the ID of 61. The message is in hex too: 3E800000 i have tried a lot of variations with the message but nothing works out. The setup in the vesc tool is: no app , send status and for the can mode I tried all options.
Looking forward to hear from you.

matrixgti
Offline
Last seen: 9 months 3 weeks ago
Joined: 2018-05-30 12:19
Posts: 7

how did you manage to send messages via CAN? 

 I Use mcp_can.h library to handle the bus on an atmega2560 + mcp2515

#include "mcp_can.h"

declare the Enum of the Can Commands

// CAN commands
typedef enum {
  CAN_PACKET_SET_DUTY = 0,
  CAN_PACKET_SET_CURRENT,
  CAN_PACKET_SET_CURRENT_BRAKE,
  CAN_PACKET_SET_RPM,
  CAN_PACKET_SET_POS,
  CAN_PACKET_FILL_RX_BUFFER,
  CAN_PACKET_FILL_RX_BUFFER_LONG,
  CAN_PACKET_PROCESS_RX_BUFFER,
  CAN_PACKET_PROCESS_SHORT_BUFFER,
  CAN_PACKET_STATUS,
  CAN_PACKET_SET_CURRENT_REL,
  CAN_PACKET_SET_CURRENT_BRAKE_REL,
  CAN_PACKET_SET_CURRENT_HANDBRAKE,
  CAN_PACKET_SET_CURRENT_HANDBRAKE_REL,
  CAN_PACKET_STATUS_2,
  CAN_PACKET_STATUS_3,
  CAN_PACKET_STATUS_4,
  CAN_PACKET_PING,
  CAN_PACKET_PONG,
  CAN_PACKET_DETECT_APPLY_ALL_FOC,
  CAN_PACKET_DETECT_APPLY_ALL_FOC_RES,
  CAN_PACKET_CONF_CURRENT_LIMITS,
  CAN_PACKET_CONF_STORE_CURRENT_LIMITS,
  CAN_PACKET_CONF_CURRENT_LIMITS_IN,
  CAN_PACKET_CONF_STORE_CURRENT_LIMITS_IN,
  CAN_PACKET_CONF_FOC_ERPMS,
  CAN_PACKET_CONF_STORE_FOC_ERPMS,
  CAN_PACKET_STATUS_5
} CAN_PACKET_ID;

 create your own function and pass the Index and the value , pay attention to the number of byte required by the command, for example RPM and Duty need 32 Byte , 

comm_can_set_rpm(1,vesc_speed);      // ID 1 , vesc_speed float RPM

 create the packet to send 

void comm_can_set_rpm(uint8_t controller_id, float rpm) {
        int32_t send_index = 0;
        uint8_t buffer[4];
        buffer_append_int32(buffer, (int32_t)rpm, &send_index);

        CAN.sendMsgBuf(controller_id | ((uint32_t)CAN_PACKET_SET_RPM << 8), 1, send_index, buffer);
}

Use buffer append to split your float into 4 Byte 

void buffer_append_uint32(uint8_t* buffer, uint32_t number, int32_t *index) {
        buffer[(*index)++] = number >> 24;
        buffer[(*index)++] = number >> 16;
        buffer[(*index)++] = number >> 8;
        buffer[(*index)++] = number;
}

 

olivierabristol
Offline
Last seen: 1 week 1 day ago
Joined: 2019-01-12 14:21
Posts: 3

Hy guys, y tried what matrixgti propose without sucess, could you please add more details on the configuration of the vesc you use, details of complete source code to send commands and receive heartbeat . I 'am also using a MCP2515 so that setup shall be exactly the same. I checked signals with the scope and get what you can expect from a can protocol but so far, can't receive nor send anything to the vesc.

Olivier