Hey guys , if this post is in wrong topic , then i am really sorry for it , i am new here. Now what's going on ....
I have Dual VESC setup (with 2 motors) ... i am communicating with master over UART. It looks like its working.
But slave doesn't respond ... or im not even trying with second VESC i think ... because i am not using any ID selector for VESC or anything with CAN.
I am using SolidGeek's libraries. (https://github.com/SolidGeek/VescUart)
Can someone please explain a give me example how to implement this CAN bus communication / selector maybe in example code in libraries ?
I have search all over the browser ,but i couldnt find any example code for this. (Only found this https://vesc-project.com/node/482 but it looks like no one build a complete working example.)
VESC 4.12
Thanks a lot. Im in struglle with it. I need it for my high school project.
Sounds like it is not forwarding to the slave vesc, I would check and make sure you have the forwarding configuration setup correctly in the app settings. Make sure the slave vesc has "send status over can" option checked. I believe there is a wizard for it in the net VESC tool.
Cheers!
Yes i have Status over can checked on Slave side. As i saw it doesn't need to be checked on master side.
But i need somehow enable COMM_FORWARD_CAN in Arduino. (it's in datatypes.h)
Master app settings:
Slave app settings:
Thanks a lot.
Do you have any ideas that help me ?
I found this topic , probably on old forum... but there are missing link/images from comments , so i can't really get into it.
http://vedder.se/forums/viewtopic.php?t=119
Looks like you need to put the COMM_CAN_FOWARD value followed by the VESC ID to forward to in the first two bytes of the UART command that you wish to forward. Original quote by Ben:
Cheers!
yes i tried yesterday , after that i recognize that both motors tried to rotate , when i force them both on command , but both were irensponsible to my moves
... maybe i decided to comunicate with both of them using Arduino Mega that have more serial ports ... so would be able to communicate with each separative after few code updates ... i will give you my feedback then
repair my code if its bad also , ... i learned C++ little after few theese remakes
also if u have time to look for how to communicate with 2 vesc in same time using UART (with CANBUS) or I2C , it will also help me
I'm really interested in the outcome. Did it work for you in the end?
actually i havent tried it yet ... but soon ... in few days / weeks i will do it for sure ... then i will give my feedback here , but i am still interested in that ... how to do it with Arduino Nano / Uno using i2c or 1 UART (+CANBUS) , Arduino Mega is too big for me ... i dont need too much inputs / outputs for it
Little bit late but ... UPDATE is here :)
For now im running on single VESC with UART , because i was working on wireless communication.
Soon i will give u little feedback when i will use dual vesc drive.
I've changed my mind , after few rides with 1 motor 6374 , i decided to run only at single VESC setup. From Arduino i have moved to a ESP32 , that i control with my phone.
In close future i will also try to run dual VESC with ESP32. If anyone have questions about my work. U can ask in this thread or write me an email (mage26gg@gmail.com).
I think this is exactly what I'm looking for. So if I understand correctly, I should be able to send a COMM_GET_VALUES command to one VESC to get its values, and if I precede the COMM_GET VALUES with a COMM_FORWARD_CAN and the index of the second VESC I should actually receive the values from the second VESC through the UART port of the first VESC - right?
It looks like this thinks I'm replying to post #11, but I'm actually replying to Josh - post #6. Sorry for any confusion.
That is correct. I'm working on some documentation about this, hopefully it will be available soon.
Excellent! Thanks very much. And if I may ask one more question...
One of my VESC's is running FW-2.18 and the other is running FW-3.40. Will that cause any trouble in passing messages through? Is there a preferred direction?
It is best to run the latest and same firmware on both. The protocol has changed a bit across versions, and 2.18 is very outdated in general. Most commands (except the configuration commands) will stay compatible in future firmwares, but that was not true for the earlier versions. I will also document that.
Thanks. The reason I have two different firmware versions is because I had one VESC repaired and it came back with the newer firmware (3.40). It seems like it may be having cut-out issues. That's why I'm logging it for the moment (to look for faults). Once I have that sorted out I'll probably get them on the same FW. At the moment I'm inclined to put them both on 2.18 since that one seems to be behaving best, but I know that's a bad solution to what's probably a setup problem.
In the meantime, I may try and log them both simultaneously using the CANBUS. If that doesn't work I can log independently. The logs for the 2.18 version already look pretty good.
Quick update. I am talking to both VESC's via UART (one at a time). They have different firmware versions, and I use different logging software for them. I did try talking to one via UART and getting data from the other over CANBUS. And it does seem that fw 2.18 and fw 3.40 are not compatible in that regard (as you suggested). So I'll do a little logging on the 3.40 VESC, and will then likely upgrade both to 3.40.
Would you say there's any particular fw version that's particularly stable, or is it simply the case that each has been an improvement over the previous version?
Thanks again!
Hi Spork! I managed to make it work, now I have access to all of the UART data from both Vescs using only one port. I only edited a slight bit fom GargiMan's code.
(On the VescUart.cpp file)
void SetCanId(int CanId){ //Added by me, use "SetCanId();" on arduino sketch
CANid = CanId; //to set the CAN bus id of the Vesc you desire to communicate.
}
bool VescUartGetValue(bldcMeasure& values, HardwareSerial* _vescserialPort) {
int32_t index = 0;
uint8_t command[3];
if(CANid == !0){ //When talking to a slave Vesc
command[index++] = { COMM_FORWARD_CAN }; //Forwarding CAN
command[index++] = CANid; //Sending CAN id
command[index++] = { COMM_GET_VALUES }; //Requesting Values
}
if(CANid == 0){ // When talking to the master Vesc
command[index++] = { COMM_GET_VALUES }; //Just requesting values
}
uint8_t payload[256];
_vescserialPort->flush(); // move to comm function directly?
PackSendPayload(command, 3, _vescserialPort);
int lenPayload = ReceiveUartMessage(payload, _vescserialPort);
if (lenPayload > 1) {
bool read = ProcessReadPacket(payload, values, lenPayload); //returns true if sucessful
return read;
}
else
{
return false;
}
}
bool VescUartGetValue(bldcMeasure& values) {
return VescUartGetValue(values, vesc_io);
}
(On the VescUart.h file)
void SetCanId(int CanId);
By the way, I'm using a dual Vesc 6 Setup, not sure if it works on 4.xx versions.
Dear Rc 44,
Thank you for posting these add-ons to VescUart.cpp and .h.
However, could you please explain, what line i would need to type in my .ino, to adress a specific motor (that is connected via CAN to the master VESC).
And. way more importantly: Is there a way, to automatically update the RPM of all VESCs (in my case 4) that are connected via CAN our themselves?
Or is in that case, the best to simply connect all RXs of the VESCS together, and disconnect CAN-Bus?
Thanks in advance,
Best Regards, Andi
Hi Rc 44 and others!
I tried to integrate the code in both VescUart.cpp and VescUart.h files.
Would it be possible to access to your whole code?
I am not sure where you got those from:
- HardwareSerial* _vescserialPort
- vesc_io
Did you also modify the void PackSendPayload(); to add some more elements? If yes, what did you modify there?
I would like to modify the void VescUart::setRPM to be able to control 8 VESCs from the Arduino. For now, it works individually, both the VESC Master via UART and the VESC Slave via COMM_FORWARD_CAN, but it doesn't work together.
Any help would be very appreciated!
Thanks a lot.
I found my answers here: https://github.com/astulnikov/ESk8Arduino/tree/405fe467cace6ee455dba3c70... !!!
Might help somebody later :)
You can communicate one Vesc over uart and other on CAN-Forward, One vesc acts like master and others will act like slaves
Here you can find all the tutorial and configuration setup:
https://github.com/GTU-Robotics-Club-2023/VESC-UART-CAN-Forward
Shubham