XPD: open-source keywin e-bike lab replacement

SO I got this all working.
I was wondering can we up the regen limit??? And how hard would it be to change some options? As well can we have 24fets and 36 fets as options?
Very cool on the Current limits :mrgreen:
Thanks very much for doing this!
 
anpaza said:
...
Floont said:
I'm looking forward to giving this a try. However, right now I'm running 132V to a Lyen 24FET controller, so I'm unsure what values to use in your program in its current state.
Is this a stock controller, or self-made?
This controller I purchased from Lyen, a well respected member our Endless-Sphere family.
anpaza said:
What program are you using to program it?
I use a Lyen version of Keywin which I hacked with a hex editor to get the values I needed into the controller. It works OK, but it is a hacked binary file and has its limitations.
anpaza said:
If it is a widespread model, you can give me a link to the modified "E-Bike Lab", I will reverse-engineer the formulas like I did for EB206-218.
24 FET 10000Watts Muscular High Current LYEN Controller $299
anpaza said:
However, if it is self-made from any stock controller by just adding extra FETs and modifying some resistor values (including the shunt), you may tweak the file xpdm/infineon.py and add your own controller. For example, let's suppose you modified an EB212 by adding 12 extra FETs and chopping down the battery voltage measuring resistor twice. In this case you would copy the section starting with <<"Name" : "EB212",>> and copy it to the end of the ControllerTypeDesc array, like this:

Code:
    {
        "Name"             : "EB224-floont",
        "PhaseCurrent2Raw" : lambda I: I * 0.625 - 7,
        "Raw2PhaseCurrent" : lambda V: 11.2 + (1.6 * V),
        "BattCurrent2Raw"  : lambda I: I * 0.624 - 1.5,
        "Raw2BattCurrent"  : lambda V: 2.404 + (1.603 * V),
        "Voltage2Raw"      : lambda U: U * 3.283,
        "Raw2Voltage"      : lambda V: V / 3.283,
    },
As an engineer, I got into programming decades ago, but times have changed rapidly and I have not kept up. So right now, although I can read your code, performing a modification and recompiling is currently beyond my skill level.
anpaza said:
...Perhaps, I can add support for a user config file (in "C:\Documents and Settings\%User%\My Documents\xpd") that adds additional controller types. With it you may easily upgrade XPD without having to modify its source code every time.
Now, that is a GREAT idea! We could have a folder containing our custom config.

We are so impressed that you have done us this service to create this open source program and are listening and responding to our requests and comments. How can we repay you?

FA
 
Doctorbass said:
I am browsing it right now... and again... THIS IS AN EXCELELNT WORK!!

Something you could add is the version that would make it perfect is displaying the version.. ex: V1.0 with the date and also the possibility for those who modified the R12 to select a factor or directly the resistor they modded so that the EBS HV and LVC value to allow higher selectable value would be automaticaly rescaled!! and the value selectable would be coresponding to the right active value!

ex. while the max EBS limit voltage is 77.7V with the OEM resistor value of around 1200ohms , we could be able to select or enter a new resistor value... or scale factor that correspond to the R12 mod so when we select the EBS, LVC or otehr affected parameters, they would be displayed with the true value! :D


Doc


I agree too, excellent work, and also second what DoctorBass says about the R12 mod scalability.

anpaza said:
Floont said:
I hope this is not very complex to understand for the average user that does controller mods, thus I don't have to write a user interface for all this stuff :D

Perhaps, I can add support for a user config file (in "C:\Documents and Settings\%User%\My Documents\xpd") that adds additional controller types. With it you may easily upgrade XPD without having to modify its source code every time.

It is not that it is so complicated to understand the changing of the formulas, and the logic behind that, it is the thought if adjusting the actual program code, compiling and all that stuff to adjust the program that would put me off, and the fear of screwing something else up...tinkering with stuff we do not really fully understand, etc.
So a user interface would be nice, but changing a config file for each controller type would be do able. OK, still the chance of putting in the wrong config settings, but at least the basic app would not be screwed with

I did read somewhere in the original documentation that one reason for this project was to make it possible to run the software from a portable device ( phone? ) for on the go re programming.
I see from your comments above that this is not yet possible. Any thoughts on what devices would be needed to run this as a mobile application ? Any ideas on what would be the most suitable platform? Win Mobile? Android? iPhone?
 
Floont said:
anpaza said:
Is this a stock controller, or self-made?
This controller I purchased from Lyen, a well respected member our Endless-Sphere family.
Heh, you tell me! Mine is from Lyen as well :) I just wasn't aware he sells 24-FET and 36-FET controllers.

Floont said:
anpaza said:
What program are you using to program it?
I use a Lyen version of Keywin which I hacked with a hex editor to get the values I needed into the controller. It works OK, but it is a hacked binary file and has its limitations.
Okay, if you can't share the program, can you at least tell me what's the shunt value on the 24-FET (and would be cool if somebody tells about the 36-FET too) compared to some known controller?

I guess it would be better if I will post a simple form which one may fill to get a new Infineon-based controller into XPD.

  • Controller model name (e.g. "EB212", "EB212/144V" etc).
  • Controller shunt resistance, as compared to some model already in XPD (e.g. "the shunt is twice smaller than in EB212").
  • Maximum voltage value controller can measure (e.g. for LVC or regen - 77.7V standard value).

This data is basically enough to write a new controller description in XPD.

Floont said:
As an engineer, I got into programming decades ago, but times have changed rapidly and I have not kept up. So right now, although I can read your code, performing a modification and recompiling is currently beyond my skill level.
The joy of Python is that you don't have to recompile anything! Just change the text file (the source code), save it, and run the program - the changes will take effect immediately. The Python interpreter reads all source files at startup, then just interprets them.
 
Well if you got a controller from him, check your paperwork /e-mails/PM's from him, and you may find a link to the Lyen.exe software that he had modified..if not PM him and he may send you a link, since you already have a controller from him. Especially if he is aware of what you are trying to achieve, he may even be able to give more help ??
 
NeilP said:
I did read somewhere in the original documentation that one reason for this project was to make it possible to run the software from a portable device ( phone? ) for on the go re programming.
I see from your comments above that this is not yet possible. Any thoughts on what devices would be needed to run this as a mobile application ? Any ideas on what would be the most suitable platform? Win Mobile? Android? iPhone?
The easiest mobile platform to port XPD to would be Maemo/Meego (and perhaps HP/Palm WebOS), because these are full-featured Linux-based platforms (only a few tweaks to user interface would be required, to better fit the small device screen). But since this is not a widespread platform (it runs mostly on Nokia N800, N810, N900 and the upcoming N950, also (Meego) on some netbooks), I'm not pushing this project very hard, since perhaps I'm one of the few people in the world that owns a Maemo and Infineon device at the same time :)

The next platform I'm keeping an eye on is Android, which is Linux-based as well, but since Android uses a non-standard graphics subsystem, the GUI of the XPD will have to be completely rewritten (unless some kind soul ports PyGTK to Android). So this project would require a substantial effort, I'm leaving it for later.

NeilP said:
Well if you got a controller from him, check your paperwork /e-mails from him, and you may find a link to the Lyen.exe software that he had modified..
Oh my, indeed I have it. I did not observed he has EB224/236 models in the list. Usually I'm using the "stock" "e-bike lab", because the Lyen version for some reason doesn't load the settings file which were saved seconds ago in the same program :)

Ok, now I have everything needed to add EB224/236.
 
Thanks for all the work on the program BTW, great contribution to make.

Okay, if you can't share the program, can you at least tell me what's the shunt value on the 24-FET (and would be cool if somebody tells about the 36-FET too) compared to some known controller?

Lyen told me to program the shunt value for my CA for my Lyen 24 Fet as 1mohm, and it seems accurate for me.

Like others, I would love it if we could program the regen limit to a higher voltage (to save me having to R12 mod), but I understand this is limited not as an aribtrary programming thing, but rather due to a function of the R12 divider, so it can't be programmed around?

\
 
Well, the Lyen version does work, but you need to be very particular with the settings when sending the data.

I seem to remember it only works with speed switch in position 2, and you often find that you have to do a complete PC reboot and fire up just the software to get it to work

Also I seem to remember that you have to press the cable transmit button, after the send button has been clicked on the software...or is it the other way round...cant remember..either way...try both ways, and hold the button down on the cable for a good second or two.

When it completes sucessfully, you get " ?? "symbol flash up and not the "OK" that you would very expcet
 
I have released a new version of XPD, 0.2.0.

This new release introduces support for Lyen variants of the Infineon controller. Do not use the "generic" controller models with Lyen controllers, as they use different shunt values, thus you will get different current limits (phase and battery).

Also in this release error handling has been improved, also support for older PySerial version 2.3 has been added, because Ubuntu and Debian distributions still ship with the old library.

  • Added the "Copy" profile button
  • Added Lyen controller modifications: 6, 9, 12, 15, 18, 24 and 36-FET versions.
  • Better error handling (will report errors rather than hanging)
  • Older PySerial 2.3 is now supported (Debian & Ubuntu)

The files, as always, can be downloaded from BerliOS project homepage.

The protocol description has been updated to include the new formulas I have deduced for Lyen controllers.
 
NeilP said:
...I seem to remember it only works with speed switch in position 2...
My hacked Lyen version does work with all three speed switch positions. The "secret" is to change the parameter "3 Speed Mode" to "0:Button Mode" which is entirely counter-intuitive. And also change "Indicate Mode" to "1:Comm GND". Both of these settings are not in the "sample" config files that come with the Lyen version I bought the controller. I agree that the program is frustrating with its idiosyncrasies, but it always eventually works with some persistance.

anpaza: Yes, the R12 shunt value is 1 megohm. I attached my hacked version of Lyen's Keywin program after I corrected the spelling and got those bizarre characters blanked out. Also included are the drivers and my current config file and some notes I took to get the thing to work.
I just might try your python program. I didn't realize it was that easy to use Python and change the program. I have to investigate it more. I assume I have to buy Python. I have to find out if will run on a Windows 7 laptop and such.

FA
 

Attachments

  • LYEN_Keywin_bob's_hack.zip
    2.8 MB · Views: 283
Floont said:
NeilP said:
...I seem to remember it only works with speed switch in position 2...
My hacked Lyen version does work with all three speed switch positions.



Sorry I put it badly and you misunderstood.

Yes, i can get it programmed to work with all three speed positions working with the Lyen edition, and yes as you say Button Mode, not switch mode.

What i was getting at was that if I remembered correctly the software would only program the controller correctly, when the physicaly handle bar switch was set in the position two position..IE both sides of the switch open...neither pin on the switch connected to the centre contact
 
Just reading the "Read Me" file you posted in the hacked version above

3 SPEED MODE - This controls the behavior of the ESC's speed switch
* 0: Switch mode - allows you to change speed on the fly using a 3-speed switch (Low, Medium, High)
1: Cycle mode - latches the value at power on. (3spd switch will not work with a 1).

Not exactly true...if set to the wrong setting and a three speed switch is used...speed changes do happen, but do seem sort of random. Worth pointing this out, as I had this problem initially and did not suspect the software.

I suspected I had wired my three speed switch incorrectly..since it was 'doing something' ...just not what I expected
 
The cycle mode of the switch meens that you are supose to cycle the switch on and off to make it change settings. So it will seem weird till you under stand it.
 
It is even more weird when you have a three position switch connected...It is designed for a momentary switch as far as I understand

Hold the switch on while powering on ...this sets the high speed ( or what ever you have set) mode

Power off and back on with the switch not pressed and the Overall Speed Limit setting is enabled
 
Floont said:
I just might try your python program. I didn't realize it was that easy to use Python and change the program. I have to investigate it more. I assume I have to buy Python. I have to find out if will run on a Windows 7 laptop and such.
You don't have to buy anything, Python is already installed on your computer as part of XPD installation (in windows-prereq.zip file). It is free software, freely available from python.org.

If you have a stock (unmodified shunt & LVC) Lyen EB224 controller, you may just install the new XPD version, it is supported now.
 
NeilP said:
Power off and back on with the switch not pressed and the Overall Speed Limit setting is enabled
Hmm, are you sure this can be done only at power-on? I was not aware of it. By reading various docs I was under the impression that you can toggle the speed setting at any time by just pushing the momentary switch. The three-position-switch, if I understand correctly, can be switched at any time?

Sorry for seemingly dumb questions, I don't have neither the switch or the button, but I'm trying to get the most correct option description in XPD.
 
Well yes it does seem to do stuff with power on, but it all seemed a bit random.

but I did have a three way switch connected, so cant really comment about how it would perform if connected correctly :D
 
This is really great work, that extends the capabilities of the original program.
This is useful for setting custom LVC(I think original version had no values between 42.5v to 50v).
I'd like to see if it can set speed less than 30%. And regen braking stronger than level 2.
 
I think setting speed less than 30% should work, although I haven't tested it. The limit of 30% in the original Parameter Designer seems completely artificial.

And about braking - unfortunately, values other than 0, 4 and 8 were tested and they don't lead to any stronger braking than existing settings :( So it seems that this is a limitation of the regen algorithm in microcontroller firmware. A guy on our Russian e-bike forum made his own controller and he managed to implement a really strong regeneration by connecting motor phases in reverse order (e.g. as for reverse direction rotation), so stronger braking is theoretically possible.

BMC v1 250w (nylon geared)
12 FET programmable Infineon controller with 4110s (running on 20A)
18s2p Konion 26650s (66v, 4.4Ah)
Max. speed 54km/h(34mph) no assist on flat
Wow, you've overclocked your 250W to >1KW. Don't you feel worried about the health of the nylon gears? :twisted:
 
I would like to beg anybody who uses XPD for the first time to keep an eye on the real current (with Cycle Analyst, or with a wattmeter), after setting the desired current limits with XPD.
I did limited testing of settings only for EB212/Lyen and EB206/Lyen controllers, the rest are untested, thus the real curent limits may happen to be larger than set.
As far as I'm aware, XPD closely mimics the behavior of Parameter Designer and will output same settings for same currents.
However, I may have forgot something somewhere, who knows.
I would feel guilty if XPD would cause someone's controller FETs to blow out due to real limits being higher than desired.
Also it would be good if those who already tested XPD with certain controller types would post a note here, something minimal like "18-FET controller limits works fine with the EB218/Lyen model" etc. Only battery current really matters, since it is computed from phase current (so, if phase current limit is way off, battery current will be incorrect as well). Of course, don't expect 100% precision, in the end, an e-bike controller is not a precision multimeter (and CycleAnalyst is not one as well). Something in the +/- 15% limits should be fine.
 
Ratttts... I had hoped this would load on my XP Pro build. Python is there and I can launch it from the DOS window... but when I double click on xpd.pyw I only get a python flash through windsows task manager and nothing stays open... and python disappears from the task manager...

Likely a build issue on my laptop... Rattts. I need to search for the Python fix.

See page 14 of this thread for the solution.
 
anpaza said:
I would like to beg anybody who uses XPD for the first time to keep an eye on the real current (with Cycle Analyst, or with a wattmeter), after setting the desired current limits with XPD.
I did limited testing of settings only for EB212/Lyen and EB206/Lyen controllers, the rest are untested, thus the real curent limits may happen to be larger than set.
Don't worry, this is standard with the old software too.
I suspect it's largely due to the block time parameter allowing a programmed period of current overshoot. It you managed to set it to 0 it may well be closer to what you program but I always set mine to a few seconds anyway.

On one of my controllers set to 57a on the old software I see peaks of 85a on my turnigy watt meter and 100a on my CA (with a supposedly correctly calibrated shunt)

anpaza, how are you with android programming ? This software run off a $100 7" android tablet would be BADASS :twisted:
 
bigmoose said:
Ratttts... I had hoped this would load on my XP Pro build. Python is there and I can launch it from the DOS window... but when I double click on xpd.pyw I only get a python flash through windsows task manager and nothing stays open... and python disappears from the task manager...

Likely a build issue on my laptop... Rattts. I need to search for the Python fix.
Try the following:
  • Open the command-line window (you call it DOS window)
  • Change the directory to where xpd is installed, e.g.
    Code:
    cd "C:\Program Files\xpd-0.2.0"
    (note the quotes)
  • Run XPD like this:
    Code:
    python xpd.pyw

Most likely it can't find one of the required libraries. In this case the above command will tell you something like "This program requires PyGTK to run". In this case you'll have to install the missing library (see the first message in thread).
 
Thanks for the tips anpaza. I am obviously not a Python guy! I found that one of the IBM service packs installed Python 2.2 on my machine a few years ago. Was able to snag this from an error file:

PYTHONCASEOK=1
PYTHONPATH=C:\IBMTOOLS\utils\support;C:\IBMTOOLS\utils\logger

Now I installed your install files to the default: C:\Python27 but the path in the laptop stayed as shown above. I cannot find the uninstall for python22 or how to change that path statement. When I tried your recommend fix from the command line, I had the same failed behavior.

Your install of Python27 had the "extras" needed to run your code, and I am thinking my machine is going to the Python22 load without the "extras." Am I on the right track?

Again apologies for the troubleshooting of the basic Python install.

Edit: Found how to change Windows environmental variables. Will reload Python27 and extras tonight and change the PYTHONPATH and see what happens!

See page 14 of this thread for the solution.
 
It looks like it's using the wrong version of Python and/or the libraries. You may just create a shortcut that points directly to the right version of Python. For this:

  • Create a shortcut to XPD.PYW (right-click on the file -> Create shortcut)
  • Open the properties of the shortcut you just created, and in the "Object" field prepend the following: "C:\Python27\pythonw.exe -E". The whole field will look now somewhat like this:
    [pre]C:\Python27\pythonw.exe -E "C:\Program Files\xpd-0.2.0\xpd.pyw"[/pre]
  • Change the icon to xpd.ico for better appearance :)
  • Move the shortcut to desktop or wherever you like it

The "-E" switch tells Python to ignore any environment variables like PYTHONPATH. With the above method you don't have to touch the environment variables at all.
 
Back
Top