SolidGeek / VescUart

An Arduino library for interfacing with the VESC over UART
GNU General Public License v3.0
179 stars 91 forks source link

Features #2

Open CTSchorsch opened 5 years ago

CTSchorsch commented 5 years ago

Hi,

your lib works really fine. Thank you for your work.

Do you think it is possible to read the Temperature and the drv error too?

Greetings Georg

SolidGeek commented 5 years ago

Yeah that should be quite easy. I am actually skipping the first 4 bytes of the data received, which contains the mosfet temperature (2 bytes) and the motor temperature (2 bytes). Regarding the error you are looking for, I can get you the mc_fault_code, which can hold any of these values:

typedef enum { FAULT_CODE_NONE = 0, FAULT_CODE_OVER_VOLTAGE, FAULT_CODE_UNDER_VOLTAGE, FAULT_CODE_DRV, FAULT_CODE_ABS_OVER_CURRENT, FAULT_CODE_OVER_TEMP_FET, FAULT_CODE_OVER_TEMP_MOTOR } mc_fault_code;

I can implement it in a dev branch if you want to try it out?

CTSchorsch commented 5 years ago

Hi,

yes. This would be fine. I use your lib to write the housekeeping data to a sdcard and this values are missing :)

Georg

Am 28.11.2018 um 21:34 schrieb SolidGeek notifications@github.com:

Yeah that should be quite easy. I am actually skipping the first 4 bytes of the data received, which contains the mosfet temperature (2 bytes) and the motor temperature (2 bytes). Regarding the error you are looking for, I can get you the mc_fault_code, which can hold any of these values:

typedef enum { FAULT_CODE_NONE = 0, FAULT_CODE_OVER_VOLTAGE, FAULT_CODE_UNDER_VOLTAGE, FAULT_CODE_DRV, FAULT_CODE_ABS_OVER_CURRENT, FAULT_CODE_OVER_TEMP_FET, FAULT_CODE_OVER_TEMP_MOTOR } mc_fault_code;

I can implement it in a dev branch if you want to try it out?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

SolidGeek commented 5 years ago

Made a new branch with the changes. You can see the changes here: https://github.com/SolidGeek/VescUart/commit/87a2552f0fecd1be73e0160c7468ce80af1cedeb

And download the updated library here: https://github.com/SolidGeek/VescUart/tree/development

Let me know if it works 👍

CTSchorsch commented 5 years ago

some error in your lib

error: invalid conversion from 'uint8_t {aka unsigned char}' to 'mc_fault_code' [-fpermissive]     data.error     = message[ind];                                 ^ exit status 1

Am 28.11.18 um 22:00 schrieb SolidGeek:

Made a new branch with the changes. You can see the changes here: 87a2552 https://github.com/SolidGeek/VescUart/commit/87a2552f0fecd1be73e0160c7468ce80af1cedeb

And download the updated library here: https://github.com/SolidGeek/VescUart/tree/development

Let me know if it works 👍

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SolidGeek/VescUart/issues/2#issuecomment-442602767, or mute the thread https://github.com/notifications/unsubscribe-auth/AmZ2hM2Nr1HSwA22M0ubeYwcQoxkhcYUks5uzvlwgaJpZM4Y2S3S.

SolidGeek commented 5 years ago

I have changed the datatype of the error variable to uint8_t, should work now. Its weird, because I didn't get the error on compiling. Would you give it a try again? Just redownload the development branch 👍

CTSchorsch commented 5 years ago

Yes, thanks, now its working (compiling and values are fine) The error value is one from the mc_fault_code ENUM ?

SolidGeek commented 5 years ago

Glad to hear. Yeah the error value map directly to the mc_fault_code ENUM. So an error value of 3 would mean a DVR error etc.

CTSchorsch commented 5 years ago

Perfect :)

CTSchorsch commented 5 years ago

Do you think that there is the possibility to reduce the ram usage ? It would be nice to use your lib together with the sd lib on an arduino board. But the ram is over 80% full and this causes crashes

Edit: Arduino UNO :)

vicgwee commented 5 years ago

Is there a possibility to reduce the time taken by getVescValues()?

One option is to increase the baud rate. On my Mega, I've recorded the following times taken (averaged over 10,000 tries):

Baud Rate Time taken (ms)
9600 79.04  
40000 19.30
115200 6.98
200000 4.23
250000 3.46  

*Over 400,000 I begin to encounter some communication failures.

Wondering what's the bottleneck: unpacking the payload? or receiving the payload from VESC.

What if we could separate the function into two: requestVescValues() -- flush Serial buffer & send the request to the VESC checkVescValues() -- check the Serial buffer if the payload has been received, if so then unpack the payload and update the values of .data

Thus the code doesn't block the arduino while waiting to receive the payload.

daniel84uk commented 5 years ago

Thanks for this, i spent ages trying to figure out how to read the bloody temps lol.