Hi everyone,
I am currently developing an omnidirectional model vehicle with 4 Vescs. Using a STM microcontroller we communicate with the VESCs over CAN bus. I have already managed to make all motors spin independently. The Hex Value in the CAN bus is in ERPM right?
I have now spent many hours writing hex values to the CAN bus. I have not been able to figure out how to reverse the motor direction so that we can drive forward and backward. Is there a bit to invert it or is there a point where the motor direction changes? What is the CAN message (SET RPM) for reverse direction.
Thanks for your help!
Hello,
You can go to code and see how it is coded (can_comm.c), but I think in default code you cannot do it. I needed the same thing for an application so I proceeded this way.
I rescaled this in the code (mc_interface.h, using duty mode because I use duty and not speed mode). Adding this line of code (mcpwm_set_duty(DIR_MULT * ((2.0 * dutyCycle) - 1.0));), I was able to set the 0% real duty cycle with a CANbus message of 50%, -100% with a message of 0% and +100% with a message of 100%.
Abdelilah
You can bring your changes on like below on (void mc_interface_set_pid_speed(float rpm)) as you are in speed mode.
Once you changes the code, you run a compilation using "make" on linux platform. The steps to do it are given on README file on VESC github.
Make sure that you choose the right hardware version that you use on "conf_general.h) !!
Abdelilah
You can also script this in QML or LISP, using the beta VESC-Tools scripting interface. The script is then loaded onto the unit.
Thank you very much for the answers, that actually gave me an idea.
it's too simple to be true. Everything is already implemented in the default code! The key is two's complement to represent the negative values in hex.
Example values with the SetRPM command:
+1000 ERPM => 0x00000E38
- 1000 ERPM => 0xFFFFFC18
This makes it very easy to send the corresponding CAN messages directly from the microcontroller. Now I'm able to spin the motors independently in any direction. NICE!
65273