ch> val
ch>
Input voltage: 26.29 V
Temp: 24.29 degC
Current motor: 0.23 A
Current in: 0.00 A
RPM: 0.0 RPM
Duty cycle: 0.1 %
Ah Drawn: 0.0000 Ah
Ah Regen: 0.0000 Ah
Wh Drawn: 0.0000 Wh
Wh Regen: 0.0000 Wh
Tacho: 2 counts
Tacho ABS: 2 counts
Fault Code: FAULT_CODE_NONE
void GetValues()
{
unsigned char buff[9];
int32_t ind = 0;
buff[ind++] = 2;
buff[ind++] = 5;
buff[ind++] = COMM_GET_VALUES;
uint16_t crc = crc16(buff + 2, 5);
buff[ind++] = crc >> 8;
buff[ind++] = crc;
buff[ind++] = 3;
WriteArray(buff,9);
}
benj said:So I've been trying to get data back from my VESC this weekend, but no joy so far.
I'm using an Arduino, and based largely on pkondratyuk's code, just modified to call COMM_GET_VALUES which should return me a nice stream of data about voltages, amps, RPMs, etc.
I am no expert on Arduino or serial communication, but I expect to call this, then see a return stream from the VESC uart, but it seems to stay silent.
It might be worth mentioning that I can talk to VESC perfectly, and control it over uart from the same Arduino setup.
This is the function I've got:
Code:void GetValues() { unsigned char buff[9]; int32_t ind = 0; buff[ind++] = 2; buff[ind++] = 5; buff[ind++] = COMM_GET_VALUES; uint16_t crc = crc16(buff + 2, 5); buff[ind++] = crc >> 8; buff[ind++] = crc; buff[ind++] = 3; WriteArray(buff,9); }
I don't pass a val, only a command.
I wasn't sure if this was a large or small packet (2 or 3 for 2nd byte).
My VESC is running 1.6 firmware.
Anyone got any ideas or tips that may help? Thanks!
void GetValues()
{
unsigned char buff[9];
int32_t ind = 0;
buff[ind++] = 2;
buff[ind++] = 1; // This is the length of the payload. Just one in this case.
buff[ind++] = COMM_GET_VALUES;
uint16_t crc = crc16(buff + 2, ind - 2);
buff[ind++] = crc >> 8;
buff[ind++] = crc;
buff[ind++] = 3;
WriteArray(buff, ind);
}
(uint8_t [256]) messageReceived = {
[0] = '\x02'
[1] = '8'
[2] = '\x04'
[3] = '\0'
[4] = '\xec'
[5] = '\0'
[6] = '\xec'
[7] = '\0'
[8] = '\xec'
[9] = '\0'
[10] = '\xec'
[11] = '\0'
[12] = '\xed'
[13] = '\0'
[14] = '\xed'
[15] = '\0'
[16] = '\xed'
[17] = '\xff'
[18] = '\xff'
[19] = '\xff'
[20] = '\xfd'
[21] = '\0'
[22] = '\0'
[23] = '\0'
[24] = '\x01'
[25] = '\x03'
[26] = '\xb6'
[27] = '\0'
[28] = '\0'
[29] = 'S'
[30] = '\x96'
[31] = '\0'
[32] = '\xea'
[33] = '\0'
[34] = '\0'
[35] = '\0'
[36] = '/'
[37] = '\0'
[38] = '\0'
[39] = '\0'
[40] = '\0'
[41] = '\0'
[42] = '\0'
[43] = '\x04'
[44] = 'W'
[45] = '\0'
[46] = '\0'
[47] = '\0'
[48] = '\t'
[49] = '\0'
[50] = '\0'
[51] = '\x7f'
[52] = '\xa9'
[53] = '\0'
[54] = '\0'
[55] = '\x7f'
[56] = '\xa9'
[57] = '\0'
[58] = '\xf5'
[59] = '<'
[60] = '\x03'
}
(uint8_t [256]) payload = {
[0] = '\x04'
[1] = '\0'
[2] = '\xec'
[3] = '\0'
[4] = '\xec'
[5] = '\0'
[6] = '\xec'
[7] = '\0'
[8] = '\xec'
[9] = '\0'
[10] = '\xed'
[11] = '\0'
[12] = '\xed'
[13] = '\0'
[14] = '\xed'
[15] = '\xff'
[16] = '\xff'
[17] = '\xff'
[18] = '\xfd'
[19] = '\0'
[20] = '\0'
[21] = '\0'
[22] = '\x01'
[23] = '\x03'
[24] = '\xb6'
[25] = '\0'
[26] = '\0'
[27] = 'S'
[28] = '\x96'
[29] = '\0'
[30] = '\xea'
[31] = '\0'
[32] = '\0'
[33] = '\0'
[34] = '/'
[35] = '\0'
[36] = '\0'
[37] = '\0'
[38] = '\0'
[39] = '\0'
[40] = '\0'
[41] = '\x04'
[42] = 'W'
[43] = '\0'
[44] = '\0'
[45] = '\0'
[46] = '\t'
[47] = '\0'
[48] = '\0'
[49] = '\x7f'
[50] = '\xa9'
[51] = '\0'
[52] = '\0'
[53] = '\x7f'
[54] = '\xa9'
}
(bldcMeasure) values = {
avgMotorCurrent = -17783250
avgInputCurrent = 120.32
dutyCycleNow = 0
rpm = 4
inpVoltage = 2227.19995
ampHours = 0.230399996
ampHoursCharged = 836.633605
tachometer = 0
tachometerAbs = 0
fault_code = 11108096
}
erwincoumans said:You seem to run an old VESC furmware, can you try with the latest one? Also, I would leave UART speed default to 115200.
benj said:erwincoumans said:You seem to run an old VESC furmware, can you try with the latest one? Also, I would leave UART speed default to 115200.
Thanks for the tips. I have to run at 9600 because the Adafruit UART only runs at that speed.
I'm also stuck on Firmware 1.6 as updating via BLDC tool isn't working for me. I've tried OSX and Windows variants, and firmware 1.7 to 1.14, but none of them seem to stick.
BLDC reports that the FW upload works, but when I power cycle the VESC, it's still stuck on 1.6. Going to look for a stlink programmer, perhaps that will fix it?
benj said:erwincoumans said:You seem to run an old VESC furmware, can you try with the latest one? Also, I would leave UART speed default to 115200.
Thanks for the tips. I have to run at 9600 because the Adafruit UART only runs at that speed.
I'm also stuck on Firmware 1.6 as updating via BLDC tool isn't working for me. I've tried OSX and Windows variants, and firmware 1.7 to 1.14, but none of them seem to stick.
BLDC reports that the FW upload works, but when I power cycle the VESC, it's still stuck on 1.6. Going to look for a stlink programmer, perhaps that will fix it?