etransport / py9b

Ninebot/Xiaomi electric scooter communication library
GNU General Public License v3.0
78 stars 20 forks source link

Help needed for communication with external BMS #4

Open TheAndi opened 5 years ago

TheAndi commented 5 years ago

Hey guys,

first of all thanks for the great work!

I got myself a external Ninebot (ES2) battery for my own DIY scooter. So far this works kind off, but with some drawbacks.

My problem is, that I can't charge it through the charging port. When I apply the charging voltage to the battery, the blue flashing (heartbeat) LED flashes red and current only flows in short pulses (so no charging). As you are quite experienced with this hardware, do you know what is required to make it charge with the charging port? Does it need the rest of the scooter and how does it sense its presence?

Nevertheless, I can charge the battery trough the P+/- connection (normally going to the scooter). But this might not be the intended way, so I'd be glad to get the other port working.

Then I also tried to communicate with the BMS using a FDTI breakout (I checked everything with the scope, so I'm very sure the electrical side is fine).

But this also doesn't work... I tried several of your "readbms"-scrips but they get no response.

Scanning...
[(u'COM4 0403:6001', u'COM4')]
Connected
> 5AA5013E230100108CFF
< 00
> 5AA5013E230100108CFF
> 5AA5013E230100108CFF
> 5AA5013E230100108CFF
> 5AA5013E230100108CFF
No response !

When I send commands to the BMS the blue LED starts flashing very fast but nothing else happens. The only response I always get is a 0x00 in sync with the heartbeat (this stops when the LED flashes fast).

I would be very thankful for any advice!

Andreas

flowswitch commented 5 years ago

Hello Andreas, BMS's TxD output is open drain, so you need a pullup resistor (something like 5k) between FTDI's RxD and VIO. The charging should work without any prior communications. What charger do you use? That behavior looks like some parameter (charging current/voltage) is going out of range tripping the protection (the original charger supplies no more than 41.5V 1.7A). BTW, once you get the comms working you can try capturing an error cause from BMS status register. Charging via P- port can be dangerous - that port bypasses overcharge protection hardware.

TheAndi commented 5 years ago

Hi flowswitch,

thank you very much for your answer. It kept me motivated to keep on trying. It turned out that in order to talk to the external BMS I still need to use 0x22 (internal BMS), most probably 0x23 gets redirected by the ESC to 0x22. Concerning the pullup you were right. The internal pullup of the FTDI is not enough to get clear reading.

After some coding and reformatting the values I achieved to all the registers: grafik btw if you wanna have my quick and dirty code to display the data in a nice and readable way just aks :)

BUT: I still have the problem of not being able to charge using the charging port. I'm charging with powersupply with CV/CC, that is finetuned to match your mentioned values. Still the same behavior (0,5s charging then 2s nothing in a cylce).

I can see the pulsating current in the BMS readout which precisely is -1750mA and the "isCharging"-bit turns 1 constantly along with the flashing red LED. The other bits except the "config valid" one are 0. So no fault...

My suspicion is that this behavior has something to do with the (unconnected) C+/C- port on the BMS. This port is used to pass trough the charging current to the internal battery of the scooter, right? And this output turns to ~41,5V as soon as I attach the charger.

Could it be that the C+/C- port has to be loaded (to simulate a charging internal battery) in order for the external one to charge properly? Or does anyone know another reason for this behavior?

Again, I am very thankful for any hint!

A tiny little second question: As I already tripped the overcurrent protection of the BMS with my scooter while going fast, do you know what the current limit of this battery/BMS is? grafik Can you confirm that this is the actual rated output? This would lead to a maximum current of around 20A but my ESC is set to 15A (I_battery max.) and still triggered it, that's why I am asking.

Thanks again!

flowswitch commented 4 years ago

Not sure if you still need my answer (the Github notification system is a bit crazy). The problem with charging is this: “...precisely is -1750mA”. The charging current must be lower than 1700mA, that’s the protection limit value and your charger is tripping it. Try lowering the current to something like 1650mA.

rickyelopez commented 4 years ago

@TheAndi any chance you still have that hackey code? I also just picked up some of these batteries for a separate project, and I'd love to have a look. Thanks!

TheAndi commented 4 years ago

@rickyelopez I'll have a look soon and report back to you. I am still not able to charge mine through the BMS :/

flowswitch commented 4 years ago

Updated info: unlike the Xiaomi M365 battery that can be charged standalone, Ninebot ES battery requires an active communication to enable charging. No special requirements, just send any valid packet periodically (i.e. read status register).

rickyelopez commented 4 years ago

What is the payload to send over UART to get the unit to report the register values?

flowswitch commented 4 years ago

cmd=01, arg=reg_index, payload = { size } See i.e. this: https://github.com/etransport/py9b/blob/7e454d761823820063b8333db704a3ded25132d2/read_esc_ll.py#L27

nopbxlr commented 4 years ago

Downgrade the battery to BMS122 firmware. It doesn't have the communication check there.

rickyelopez commented 4 years ago

Has anybody tried reverse engineering the firmware or circuit? I gave the firmware a shot with this but didn't have much luck

flowswitch commented 4 years ago

The circuit is pretty similar to this M365 schematic). Firmware - what do you want to find out?

rickyelopez commented 4 years ago

The circuit is pretty similar to this M365 schematic). Firmware - what do you want to find out?

Nice, thanks for that! I'd like to have the firmware that's running on it so I can modify it for use with other projects. The boards seem really solid, but the scooter firmware is no use to me without knowing how it works.