CAN-BUS Forwarding

Support for creating custom user applications on the VESC.
transpower
Posts: 1
Joined: 01 Sep 2016, 23:59
Location: Auckland

CAN-BUS Forwarding

Postby transpower » 02 Sep 2016, 00:07

Hello,

I am looking to control 4 VESC units from a single USB on my computer. I am struggling to understand how the CAN forwarding is to be implemented. I am able to control the first motors speed by sending a message that looks like [2,5,8,blah,blah,blah,blah,3]. I have enabled CAN forwarding using the bldc-tool and have given each a separate address and can control them though the single USB. I see COMM_FORWARD_CAN and CAN_PACKET_SET_RPM defined and assume that they are required to be placed somewhere within the message. I will continue to experiment with different message formats but if someone could provide and example message of setting a speed via CAN forwarding it would be amazing.

Thanks a bunch,
Mitchell

rew
Posts: 943
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: CAN-BUS Forwarding

Postby rew » 02 Sep 2016, 07:30

The CANBUS is a BUS. So normally all devices on the bus can hear what is transmitted by one of them.

I suspect that "CAN_FORWARD" is a command used on USB or SERIAL to send a message onto the canbus. But I haven't looked at that part of the code.

pf26
Posts: 304
Joined: 28 Mar 2016, 14:37
Location: FR Valence

Re: CAN-BUS Forwarding

Postby pf26 » 03 Sep 2016, 09:51

I think you just need to change your frame like this :

[2,5,8,blah,blah,blah,blah,3] -> [2,5+2,COMM_FORWARD_CAN, VESC_ADDRESS, 8,blah,blah,blah,blah,3].
+2, because the frame has 2 more bytes, hence the new length
Now the message should be forwarded to the VESC with VESC_ADDRESS.

Did you try with BLDC_tools ? (check CAN Fwd box and input the VESC destination in the Textbox nearby)
Using some COM port monitor, you will see how the serial frames are changed.
COMM_FORWARD_CAN = 33 (0x21)

Pierre

GvB
Posts: 8
Joined: 15 Sep 2017, 20:39
Location: Eindhoven

Re: CAN-BUS Forwarding

Postby GvB » 30 Dec 2017, 16:26

Sorry kicking up old dust.
but got a question.
how come COMM_FORWARD_CAN = 33? I would have thought it would be 31.
When I look into commands.c the

Code: Select all

   case COMM_FORWARD_CAN:
      comm_can_send_buffer(data[0], data + 1, len - 1, false);
      break;

is the 31st case starting from 0. But it apparently is the 33rd. It is working when I use 33.
I must be misunderstanding something. Nothing new there..... :lol:

pf26
Posts: 304
Joined: 28 Mar 2016, 14:37
Location: FR Valence

Re: CAN-BUS Forwarding

Postby pf26 » 31 Dec 2017, 10:45

In datatypes.h, you can see the enumaration of all communication commands, and COMM_FORWARD_CAN is the 33rd in the list, hence the constant COMM_FORWARD_CAN=33.

GvB
Posts: 8
Joined: 15 Sep 2017, 20:39
Location: Eindhoven

Re: CAN-BUS Forwarding

Postby GvB » 31 Dec 2017, 12:07

Ah. that's it. of course. did not know how that worked. and also was working with a different library. now switching to rollingGecko's...
Learning C++ as I am going along.


Return to “Custom Applications”

Who is online

Users browsing this forum: No registered users and 3 guests