Page 1 of 1

CAN-BUS Forwarding

Posted: 02 Sep 2016, 00:07
by transpower

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,

Re: CAN-BUS Forwarding

Posted: 02 Sep 2016, 07:30
by rew
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.

Re: CAN-BUS Forwarding

Posted: 03 Sep 2016, 09:51
by pf26
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)


Re: CAN-BUS Forwarding

Posted: 30 Dec 2017, 16:26
by GvB
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

      comm_can_send_buffer(data[0], data + 1, len - 1, false);

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:

Re: CAN-BUS Forwarding

Posted: 31 Dec 2017, 10:45
by pf26
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.

Re: CAN-BUS Forwarding

Posted: 31 Dec 2017, 12:07
by GvB
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.