RollingGecko / VescUartControl

Arduino library to interface with the VESC bldc over UART.
Other
141 stars 75 forks source link

Update for new VESC4 Firmware incl w/ Beta VESC-Tool #11

Closed jeffnyc closed 7 years ago

jeffnyc commented 7 years ago

Now that the VESC6 is in Beta, the new VESC-Tool is out (Beta) and it includes new and improved firmware for the VESC4's. According to Vedder this new firmware requires some changes to UART. Can this library be modified to accommodate these changes? Or perhaps a new VescUartControl version is needed? Here is the summary (from Vedder) of what's required for the new firmware to work with VescUartControl:

"
The SetRpm and SetCurrent commands should work as before, but the GetValue command probably has to be updated. This is the way the values are sent in the latest firmware:

case COMM_GET_VALUES: ind = 0; send_buffer[ind++] = COMM_GET_VALUES; buffer_append_float16(send_buffer, mc_interface_temp_fet_filtered(), 1e1, &ind); buffer_append_float16(send_buffer, mc_interface_temp_motor_filtered(), 1e1, &ind); buffer_append_float32(send_buffer, mc_interface_read_reset_avg_motor_current(), 1e2, &ind); buffer_append_float32(send_buffer, mc_interface_read_reset_avg_input_current(), 1e2, &ind); buffer_append_float32(send_buffer, mc_interface_read_reset_avg_id(), 1e2, &ind); buffer_append_float32(send_buffer, mc_interface_read_reset_avg_iq(), 1e2, &ind); buffer_append_float16(send_buffer, mc_interface_get_duty_cycle_now(), 1e3, &ind); buffer_append_float32(send_buffer, mc_interface_get_rpm(), 1e0, &ind); buffer_append_float16(send_buffer, GET_INPUT_VOLTAGE(), 1e1, &ind); buffer_append_float32(send_buffer, mc_interface_get_amp_hours(false), 1e4, &ind); buffer_append_float32(send_buffer, mc_interface_get_amp_hours_charged(false), 1e4, &ind); buffer_append_float32(send_buffer, mc_interface_get_watt_hours(false), 1e4, &ind); buffer_append_float32(send_buffer, mc_interface_get_watt_hours_charged(false), 1e4, &ind); buffer_append_int32(send_buffer, mc_interface_get_tachometer_value(false), &ind); buffer_append_int32(send_buffer, mc_interface_get_tachometer_abs_value(false), &ind); send_buffer[ind++] = mc_interface_get_fault(); commands_send_packet(send_buffer, ind); break;

"

RollingGecko commented 7 years ago

@jeffnyc: Just checked Vedders repo. Current FW is 2.18. There are no real changes in the command.c visible for me. The last commit is nearly a year ago on this repo. Did I miss something?

jeffnyc commented 7 years ago

Sorry for the confusion - this is from the new firmware that is part of the Beta test program for the new Vesc 6.  As part of the Vesc 6 launch, Benjamin Vedder created the new VESCTool application.  And in addition to being the default interface for the new Vesc 6 boards, it also includes new firmware for the existing Vesc 4's that are already on the market (see screenshot attached).  And that is where the changes in UART protocol come into play.. It hasn't been released publicly yet as it's still in Beta, which I suspect is why it's not on Vedder's repo?

RollingGecko commented 7 years ago

Please send me the complete commands.c and .h to check it completely.

jeffnyc commented 7 years ago

Unfortunately, that's all Benjamin sent me in the email, which leads me to believe that's the only relevant change for your library?  I did tell him I was using VescUartControl and needed to know what changes might be required for my code (and if the delay could be shortened), and this is exactly what he wrote:

"The VescUartControl library is not written by me, so I'm not sure what the delay does. I usually don't use any delay and just wait for the result after sending the request. You could try increasing the baud rate and see if it helps. The SetRpm and SetCurrent commands should work as before, but the GetValue command probably has to be updated. This is the way the values are sent in the latest firmware:

case COMM_GET_VALUES:         ind = 0;         send_buffer[ind++] = COMM_GET_VALUES;         buffer_append_float16(send_buffer, mc_interface_temp_fet_filtered(), 1e1, &ind);         buffer_append_float16(send_buffer, mc_interface_temp_motor_filtered(), 1e1, &ind);         buffer_append_float32(send_buffer, mc_interface_read_reset_avg_motor_current(), 1e2, &ind);         buffer_append_float32(send_buffer, mc_interface_read_reset_avg_input_current(), 1e2, &ind);         buffer_append_float32(send_buffer, mc_interface_read_reset_avg_id(), 1e2, &ind);         buffer_append_float32(send_buffer, mc_interface_read_reset_avg_iq(), 1e2, &ind);         buffer_append_float16(send_buffer, mc_interface_get_duty_cycle_now(), 1e3, &ind);         buffer_append_float32(send_buffer, mc_interface_get_rpm(), 1e0, &ind);         buffer_append_float16(send_buffer, GET_INPUT_VOLTAGE(), 1e1, &ind);         buffer_append_float32(send_buffer, mc_interface_get_amp_hours(false), 1e4, &ind);         buffer_append_float32(send_buffer, mc_interface_get_amp_hours_charged(false), 1e4, &ind);         buffer_append_float32(send_buffer, mc_interface_get_watt_hours(false), 1e4, &ind);         buffer_append_float32(send_buffer, mc_interface_get_watt_hours_charged(false), 1e4, &ind);         buffer_append_int32(send_buffer, mc_interface_get_tachometer_value(false), &ind);         buffer_append_int32(send_buffer, mc_interface_get_tachometer_abs_value(false), &ind);         send_buffer[ind++] = mc_interface_get_fault();         commands_send_packet(send_buffer, ind);         break; I think you can update the library you are using easily to work with this. "

RollingGecko commented 7 years ago

OK. Let's go. Please test this branch:

https://github.com/RollingGecko/VescUartControl/tree/VESC6

Note: Now the complete package is read.

RollingGecko commented 7 years ago

Tested with a Mega2560 on VESC 4.11 and the newest firmware. This branch will be merged to master as soon, as Vedder released the FW.