Hi all,
I'm setting up a CAN controller for a VESC 6.0 using an Atmega2560 , I'm able to control RPM, Duty, and Current ring and get back all the info from Message 5 but is not clear form me ho to dynamically set the maximum motor current. Not intended as primary control, just the maximum current as in the FOC parameter.
Here is the portion of the code from comm_can.c
/**
* Update current limits on VESC on CAN-bus.
*
* @param controller_id
* ID of the VESC.
*
* @param store
* Store parameters in emulated EEPROM (FLASH).
*
* @param min
* Minimum current (negative value).
*
* @param max
* Maximum current.
*/
void comm_can_conf_current_limits(uint8_t controller_id,
bool store, float min, float max) {
int32_t send_index = 0;
uint8_t buffer[8];
buffer_append_float32(buffer, min, 1e3, &send_index);
buffer_append_float32(buffer, max, 1e3, &send_index);
comm_can_transmit_eid(controller_id |
((uint32_t)(store ? CAN_PACKET_CONF_STORE_CURRENT_LIMITS :
CAN_PACKET_CONF_CURRENT_LIMITS) << 8), buffer, send_index);
}
Did someone can point me on how to send and store a maximum current value ?
Thanks
Flavio
Hi,
Did you figure this out?
Kind Regards
HI, Yes I did it and it work.
I use this command to set the max motor current "on the fly" but you can use the same routine to save it permanently using the right Can command emumered in the last code snip.
this is the routine to append the two numbers (current_min and current_max) into a int_64 to a message
invoked by a simple potentiometer that set the max current from 5 to 40 Amps (5000 -> 40000) :
This is the complete Enum commands usable in the Can protocol
Hope this help and sorry for my bad english,
Cheers
Flavio
Thank you, that worked out for me as well, much appreciated.