Tuesday, November 18, 2008

Twike BMS emulation in Software

It's been a while since I have posted, but I have not been idle. I have just about given up with trying to get the old BMS boards working (looks like a marginal design when exposed to the elements of the batteries). I'm not sure I have any working boards out of the 5 I have. But, because I must get 2 BMS boards (or something that looks like them) to get the Twike controller firmware happy, I decided to play to my strengths and write a software emulation of the BMS. Documentation of the protocol is non existent from the manufacturer but I found a german open source project doing some of the same things to support running Lithium-Ion battery packs. Armed with a RS485 converter, the knowledge of the fact it runs at 2400 baud and a reference code base to answer some of the hard questions, I coded up a program that allows me to emulate all the operations of the firmware based BMS. I should test it this week now that I am done coding it. If this works, I will be able to try putting a partial charge on one of the battery packs and drive the car around the block. Also, I can verify all the electrical devices and switches and see which need more attention. Also, I have the twike service program (version 3.6) which is a DOS application that does all kinds of magic in talking to the BMS. To debug my program, I installed vmware server and booted DOS 6.22 on a floppy image. I installed the service program to the floppy image and could then run the service program in a window talking to a COM port. Next, I downloaded a trial version of "Virtual Serial Port Driver". This program creates pairs of COM ports connected via a virtual null modem. This lets me connect the Twike DOS service program to my C# BMS emulation program. Very cool. When I was done, the service program was completely happy so I hope the controller in the Twike will be also. Highly recommended technique.

1 comment:

Pete Allen said...


Thank you for the useful info, it's good to see some proper Twike battery hacking!
Have you got a link for the open source BMS emulator project? I've been looking for a while to use as a reference for doing an embedded BMS, but cannot find it anywhere...

Thank you!