Reading data from my sabvoton controller

Manny

10 W
Joined
Nov 23, 2011
Messages
83
Location
The Netherlands
for my Aprillia project https://endless-sphere.com/forums/viewtopic.php?f=12&t=83316 I want to read data from my sabvoton svmc96080 controller.

the usb connector on the sabvoton is not USB, luckily its just serial.

the original "programming cable" is a usb to serial converter with a usb connctor on the other end.

5IOnM.jpg


the +5v and gnd are in the same place, the D+ is the controller Tx and the D- is the controller Rx.

the communication uses the modbus protocol @ 19200 baudrate.

the PC software sends a code to write a register twice(just to be sure i guess) to start the communication. without this when requesting data all the data will be zero.

after the start code the PC software requests the same data continuously.

the data requested is the info you see on the main screen of the PC software.
I know what most of the data represents, some is still unknown.

I made a simple and crude ardino sketch that reads the data and sends the battery voltage to the arduino serial terminal. this code needs work. it is not fault tolerant it doesn't check the CRC on the incoming data. For my project I need to combine this code and the stepper motor code, and I like to do battery state of charge tracking to display on the dial.

the .xlsx file is all i know at the moment.
 

Attachments

  • Protocol.xlsx
    11.6 KB · Views: 721
Absolutely awesome, a gillion thanks to you Manny!

I'm still not sure about how this protocol works exactly (I'm not really a programmer), but I'll try the code that you provided and see if I can extrapolate the other data. I would like to display the followings on my dashboard:
-Battery voltage (should be no problem since the code you posted is designed for that)
-Phase current, or Battery current, (I think that battery current may be easier to display)
-Controller temperature
So let me know if at some point you discover how to access these data :)

I would also love to be able to program on the fly, like having a button to enable/disable regen, lower or upper flux weakening, and battery max current.
No idea if this would be feasible though.

Again, thanks a lot, I bet this will interest many people here!
 
How do you plan to initialize the steppers?
Steppers cannot memorize their position after shutdown, so will you have some kind of endstop to caibrate it at startup?

This part is really not a problem for me but I'm curious about how you plan to do it,
 
Dui said:
-Battery voltage (should be no problem since the code you posted is designed for that)
yes the battery voltage is in the example. i am wondering if the ratio between the data value an the real battery voltage is the same for all models of the sabvoton.

Dui said:
-Phase current, or Battery current, (I think that battery current may be easier to display)
phase current is easy if your not using the flux weakening. if your using that you need to do some calculation between the "Torque current fbk" and the "Weaken current fbk". there is no readout on the pc software for the battery current :( hopefully it is some were in the data. hard to test on the workbench.

Dui said:
-Controller temperature

the controller temp is one of the parameters i will check my controller.

the arduino programe uses two serial ports one to talk to the pc and one to talk to the controller. the controller connects to pin 10 and 11 (and GND, +5V is not conected).

Dui said:
How do you plan to initialize the steppers?
Steppers cannot memorize their position after shutdown, so will you have some kind of endstop to caibrate it at startup?
Exactly
 
This is great! I've been working on a display for my Ebike, and this is way cleaner than what I was going to do. Basically, my setup is an Arduino with a cheap $15 LCD display. The Arduino talks directly to the controller and displays information on the screen. The arduino & screen powered via a 12V -> 5V buck converter, which is in turn powered by a Main Battery -> 12V buck converter. I know running series buck converters isn't the best, but I needed 12V for my lights and I just hate wasting power using the onboard linear regulator. I got communication up and running yesterday, and everything works great while the bike is standing still.

The problem I'm trying to figure out now is as soon as I give it any throttle (actually, as long as the wheel is spinning), all the data from them controller is garbage. When the wheel stops spinning, everything returns to normal. After further investigation, every bit from the controller is a "1" when the wheel is spinning. That sounds a lot like a grounding problem, but I am sharing a ground between my display and the Sabvoton via the "USB" cable and the regulator that the display is running off of.

As a troubleshooting step, I put my bike on a stand and plugged my laptop in with the official Sabvoton app, and I did NOT see the same behavior. I got consistent data at all speeds. So there is definitely something wrong with my setup... If anyone has any ideas, I'm all ears!
Thanks,
 
As a follow up, all the bits are not "1". It looks like I just have a crazy amount of noise on my data line that's causing it to pick up errant bytes. I should be getting 57 bytes back, but instead I'm getting much more...
 
No luck with the bypass caps. Working on isolation now. Waiting on some parts to be delivered. I'm debating scrapping my arduino screen and just using a $50 Android Fire tablet. A simple BT adapter should provide all the isolation needed. I might try brushing up on my Android development while I'm waiting on the opto-isolators to ship. The downside is that you'd have to keep the tablet charged, whereas the arduino ran directly off the bike battery. I suppose I could just leave the switching regulators running all the time to keep the tablet topped off and ready to go.
 
Thanks again Manny for starting this topic, and thanks Alan for the isolation advice. I got everything buttoned up yesterday, and it's working great! It's not very pretty right now (I still need to clean some stuff up), but it's perfectly functional. I ended up developing the dashboard in .Net. It's what I use everyday at work, and I'm way quicker doing things in .Net than I am in Android Studio. Right now, everything is running on an Intel PC stick, but it should be relatively easy to get it to run on a Raspberry Pi or similar SBC using Mono. If anyone is interested, I'll post the sources once I clean things up.

Any HDMI screen would work. I went with this one because it was already in a decent case:
https://www.amazon.com/gp/product/B01I1N8ZQ8/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1

So far, the screen displays:
* battery State of Charge - I'm just using a SOC estimation based on no-load voltage assuming 20S pack. This could be changed very easily to any pack configuration.
* Speed - There's a wheel size constant that needs to be changed for different wheel sizes.
* Motor and Controller Temperature - these are plotted on an area chart at the bottom of the screen. The window period is approximately 3 minutes
* Pack voltage & average cell voltage (Pack V / # series cells)

The battery SOC estimation will only update when the throttle is completely "off" to prevent the voltage sag under load from impacting the estimated SOC. This means that if you go wide open throttle non-stop, the battery SOC will never update, and it will report no change until you release the throttle. A future improvement would be to create a definable battery source resistance and account for voltage sag under load. This should be doable since the controller reports both battery current and battery voltage. This would allow SOC updates to happen at any load.

Has anyone else noticed the offset in the returned value for motor temperature? The value returned by the controller increases by about 5-10 degrees C when the wheel is spinning. I observed this behavior both in the official Sabvoton app and my application. I tried to correct for this offset in software, but it's not perfect.

IMG_20170926_172810.jpg

 
Great resource.

I'm currently researching a way to DIY a Bluetooth dongle for this.
 
https://www.amazon.com/KEDSUM-Arduino-Bluetooth-Wireless-Transceiver/dp/B0093XAV4U/ref=cm_cr_arp_d_product_sims?ie=UTF8

In theory, you should be able to run jumpers from the "USB" (aka serial) female output onto this board... Pretty convenient considering you even have 5V right there on the USB female!

Then setting the baudrate and profile via command line should let this act as a native passthrough.

What do you guys think? Will this work?
 
Let's find out on Saturday.
 

Attachments

  • Screen Shot 2017-12-07 at 3.13.03 PM.png
    Screen Shot 2017-12-07 at 3.13.03 PM.png
    15.7 KB · Views: 9,116
I'm kind of new to this, please forgive me if my questions are trivial.
Can we do something similar to the drives that have been manufactured by other companies?
if we can how do we eavesdrop on the communication between the controller and the computer?
Should i connect the d+ and the d- pins to the Arduino after the Serial to USB converter or before it ?
 
I'm sorry But how do i find which side is the UART side. The Bigger Side(The one that goes to the computer ) or the smaller side
 
I'm reading 63 bytes and not 57 bytes, Is there something wrong with the connection or baud rate??
 
I've been trying from the morning still i am not receiving any data can someone help me out please
 
my controller has a wire to change the motor direction. you can switch that wire with the arduino.

i don't know if the system status changes when in revers. maybe check that with the pc program
 
Back
Top