Hello,
I'm working on a project, and I would like to control 2 VESC with external CAN.
I'd like to be able to :
- Control each VESC speed independently
- Control each VESC direction of rotation independently
- Control each VESC braking current independently
I'm aware that I can give each VESC a different ID, but I would like to know what kind of CAN frame should I send to it.
I studied the source code and I guess I should send something like : |Controller ID|Command|Parameter|
where Controller ID is the ID i setted on BLDC tool, Command is (Duty cycle, braking current, etc.)
So I would like to know the bytes (corresponding to each command) that I have to send.
I would also like to know if I can get each VESC current informations on the CAN bus.
Thanks in advance for your replies.
Dimitri
Control 2 VESCs with external CAN
Re: Control 2 VESCs with external CAN
you need to program your CAN engine (500kbds, receive filters..) to be able to send or receive the CAN messages from VESC.
You can get inspiration on frames by the file from VESC code named "comm_can.c".
To sen a position request using a PIC18 with can bus, it goes like:
You can get inspiration on frames by the file from VESC code named "comm_can.c".
To sen a position request using a PIC18 with can bus, it goes like:
Code: Select all
TXB0SIDH = 0;
TXB0SIDL = 0x18; // Extd message filter : 0x00
TXB0EIDL = ID; // VESC destination ID
TXB0EIDH = CAN_PACKET_SET_POS; // Command to send to VESC - for example CAN_PACKET_SET_POS=4
TXB0DLC = 8; // 8 bytes to transmit
TXB0D0 = position >> 24;
TXB0D1 = position >> 16;
...
TXB0CONbits.TXREQ=1; // Mark this buffer as ready to start transmit.
Re: Control 2 VESCs with external CAN
Thanks for your reply.
My problem is that I can't find the decimal values of the different commands to send.
Where did you get "CAN_PACKET_SET_POS = 4". I'm not seeing this in the "comm_can.c"
My problem is that I can't find the decimal values of the different commands to send.
Where did you get "CAN_PACKET_SET_POS = 4". I'm not seeing this in the "comm_can.c"
Re: Control 2 VESCs with external CAN
My bad,
I just saw that the different commands ID have been declared in the file "datatypes.h"
Thanks again for your help
I also wanted to know if I can get VESC information like Current over the CAN bus ?
I just saw that the different commands ID have been declared in the file "datatypes.h"
Thanks again for your help
I also wanted to know if I can get VESC information like Current over the CAN bus ?
Re: Control 2 VESCs with external CAN
Thanks a lot, this is exactly what I needed
Re: Control 2 VESCs with external CAN
Did you figure out how to pull info from the VESC units over CAN? Also, are you using the TI SN65HVD232 Transceiver as your external can IC?
Thanks!
Thanks!
My Site: https://www.radicalcreation.com
Re: Control 2 VESCs with external CAN
A tutorial would probably be helpful, but here is the CAN interface I'm using for a self driving RC car:
https://github.com/vedderb/rise_sdvp/bl ... comm_can.c
and here is the bldc interface code
https://github.com/vedderb/rise_sdvp/bl ... nterface.c
https://github.com/vedderb/rise_sdvp/bl ... nterface.h
here is an older version of the interface that should work for FW 2.16
https://github.com/vedderb/bldc_uart_co ... nterface.c
https://github.com/vedderb/bldc_uart_co ... nterface.h
There are also a few much simpler CAN commands with limited functionality, but by implementing the things above you will be able to access everything on the VESC over CAN, including changing the configuration.
https://github.com/vedderb/rise_sdvp/bl ... comm_can.c
and here is the bldc interface code
https://github.com/vedderb/rise_sdvp/bl ... nterface.c
https://github.com/vedderb/rise_sdvp/bl ... nterface.h
here is an older version of the interface that should work for FW 2.16
https://github.com/vedderb/bldc_uart_co ... nterface.c
https://github.com/vedderb/bldc_uart_co ... nterface.h
There are also a few much simpler CAN commands with limited functionality, but by implementing the things above you will be able to access everything on the VESC over CAN, including changing the configuration.
Re: Control 2 VESCs with external CAN
Thank you for the reply, Ben! I will read through the code and play with it. I can make a lite tutorial with examples once I get it working.
Cheers!
Cheers!
My Site: https://www.radicalcreation.com
-
- Posts: 16
- Joined: 29 May 2017, 20:47
- Location: Bordeaux
Re: Control 2 VESCs with external CAN
hello all!
I'm really interested by this topics.
for info we do that : www.kitewinder.fr
My which is to control a Vesc trough a can bus delivered by an arduino with can shield bus.
I try to figure out infos but with no great success at that point.
My first step would be just to send data from vesc ( voltage, current for example) and try to get them on the arduino can bus port. but even the conf that shall be given in bldc tool, I'm not sure about it...
Is there some update available, tutorials, anything. Any help would be greatly appreciated !
I'm really interested by this topics.
for info we do that : www.kitewinder.fr
My which is to control a Vesc trough a can bus delivered by an arduino with can shield bus.
I try to figure out infos but with no great success at that point.
My first step would be just to send data from vesc ( voltage, current for example) and try to get them on the arduino can bus port. but even the conf that shall be given in bldc tool, I'm not sure about it...
Is there some update available, tutorials, anything. Any help would be greatly appreciated !
Re: Control 2 VESCs with external CAN
benjamin wrote:A tutorial would probably be helpful, but here is the CAN interface I'm using for a self driving RC car:
https://github.com/vedderb/rise_sdvp/bl ... comm_can.c
and here is the bldc interface code
https://github.com/vedderb/rise_sdvp/bl ... nterface.c
https://github.com/vedderb/rise_sdvp/bl ... nterface.h
here is an older version of the interface that should work for FW 2.16
https://github.com/vedderb/bldc_uart_co ... nterface.c
https://github.com/vedderb/bldc_uart_co ... nterface.h
There are also a few much simpler CAN commands with limited functionality, but by implementing the things above you will be able to access everything on the VESC over CAN, including changing the configuration.
Hi Ben,
I would like first to thank you for the VESC controller which is a really great solution!
And I would like to ask about the CAN bus protocol. Are there any news? It would be great to control several VESC controllers over the CAN. I know how to configure and use a CAN bus in the microprocessor but decoding a CAN bus messages' format from the code is so time consuming. Do u have maybe a table (draft, whatever) that would contain the messages format (a name of the message, its description and meaning of its data bytes)?
I would like also to ask how is the communication from the VESC solved? Does it send its status periodically over the CAN or do I need to pull it?
Thank you very much.
Regards
Ondrej
Return to “Custom Applications”
Who is online
Users browsing this forum: No registered users and 1 guest