XPD: open-source keywin e-bike lab replacement

Get all your technical information about electric bikes here.
User avatar
methods   10 GW

10 GW
Posts: 4506
Joined: Aug 08 2008 12:08pm
Location: Santa Cruz CA
Contact:

Re: XPD: open-source keywin e-bike lab replacement

Post by methods » Jul 13 2013 4:31pm

I suggest running 3 heavy gauge cables up to the handlebars.... when you want to slow down start rubbing the wires together :o Two will get you DUG DUG DUG DUG... three will send you right over the bars with the most amazing regen you have ever felt. The only trick is figure out how to get all that plasma and heat back into the battery.

Good alternative if you need a front light. Crowbar brakes are good for all sorts of things.

-methods
Increasing battery voltage and controller current limit will result in a non linear experience

User avatar
amberwolf   100 GW

100 GW
Posts: 27380
Joined: Aug 17 2009 6:43am
Location: Phoenix, AZ, USA, Earth, Sol, Local Bubble, Orion Arm, Milky Way, Local Group
Contact:

Re: XPD: open-source keywin e-bike lab replacement

Post by amberwolf » Jul 13 2013 4:35pm

iovaykind wrote:Has there been any development in regen settings other than 0(none), 4(weak), 8(strong), or 255(unlimited)?
I would guess that would require a change in the actual MCU programming in the controllers themselves--not something possible without the source code to them, and the ability to completely reflash the MCU.

Well, you could write your own code for the controller MCUs, but you'd be starting from scratch to do that, and presumably would need the developer's info for each MCU type from the chip manufacturers.

jovae49   1 µW

1 µW
Posts: 2
Joined: Sep 12 2013 10:42am

Re: XPD: open-source keywin e-bike lab replacement

Post by jovae49 » Sep 13 2013 8:19am

gwhy! wrote:I will also post this up this is my v3 adaptor. The capacitor fixed quite a lot of issues for me when using the lead on different pc's .
V3 programming wiring.jpg
Hello,
There was an error on this scheme. The switch should not be connected to the +5 V but the 0V. Here is the right schema:
Image

To see on our forum in France : http://cyclurba.fr/forum/259421/customi ... ionID=3279#

User avatar
gwhy!   1 MW

1 MW
Posts: 1651
Joined: Jun 08 2011 3:47pm
Location: Bristol, Uk

Re: XPD: open-source keywin e-bike lab replacement

Post by gwhy! » Sep 14 2013 4:42pm

I have my switch in the +5, so my diagram was correct for my setup but I dont really think it makes that much difference what line its in, i just think its better in the + line from a electrical point of view.

kifukarider   10 W

10 W
Posts: 71
Joined: May 06 2013 3:05am

Re: XPD: open-source keywin e-bike lab replacement

Post by kifukarider » Sep 26 2013 4:31am

Thank you Andrey!

I've downloaded XPD and it's awesome. It is so much better than the old hexed config programs.

I wanted to compare the output of XPD before I sent data to the controller. I installed some virtual serial ports and collected the data using debug-read-EB3xx.py. I only found one difference between the hexed software and XPD in which data[27]=3 is hard coded. The hexed programs set data[27] to the index of the controller type. Setting data[27]=3 would indicate EB312. I modified my copy of XPD from trunk and included a patch below in case you're interested.
  • 1:EB306
  • 2:EB309
  • 3:EB312
  • 4:EB315
  • 5:EB318
xpdm/infineon3.py.diff

Code: Select all

Index: xpdm/infineon3.py
===================================================================
--- xpdm/infineon3.py	(revision 67)
+++ xpdm/infineon3.py	(working copy)
@@ -79,6 +79,7 @@
         "Raw2BattCurrent"  : lambda R: (0.71 * R) - 0.1,
         "Voltage2Raw"      : lambda U: U * 3.184,
         "Raw2Voltage"      : lambda R: R / 3.184,
+        "ControllerType"   : 1,
     },
     {
         "Name"             : "EB309",
@@ -88,6 +89,7 @@
         "Raw2BattCurrent"  : lambda R: (0.71 * R) - 0.1,
         "Voltage2Raw"      : lambda U: U * 3.184,
         "Raw2Voltage"      : lambda R: R / 3.184,
+        "ControllerType"   : 2,
     },
     {
         "Name"             : "EB312",
@@ -97,6 +99,7 @@
         "Raw2BattCurrent"  : lambda R: (1.43 * R) - 0.1,
         "Voltage2Raw"      : lambda U: U * 3.184,
         "Raw2Voltage"      : lambda R: R / 3.184,
+        "ControllerType"   : 3,
     },
     {
         "Name"             : "EB315",
@@ -106,6 +109,7 @@
         "Raw2BattCurrent"  : lambda R: (1.43 * R) - 0.1,
         "Voltage2Raw"      : lambda U: U * 3.184,
         "Raw2Voltage"      : lambda R: R / 3.184,
+        "ControllerType"   : 4,
     },
     {
         "Name"             : "EB318",
@@ -115,6 +119,7 @@
         "Raw2BattCurrent"  : lambda R: (2.14 * R) - 0.06,
         "Voltage2Raw"      : lambda U: U * 3.184,
         "Raw2Voltage"      : lambda R: R / 3.184,
+        "ControllerType"   : 5,
     },
     {
         "Name"             : "EB306/CellMan",
@@ -124,6 +129,7 @@
         "Raw2BattCurrent"  : lambda R: (1.43 * R) - 0.1,
         "Voltage2Raw"      : lambda U: U * 3.184,
         "Raw2Voltage"      : lambda R: R / 3.184,
+        "ControllerType"   : 1,
     },
     {
         "Name"             : "EB309/CellMan",
@@ -133,6 +139,7 @@
         "Raw2BattCurrent"  : lambda R: (1.43 * R) - 0.1,
         "Voltage2Raw"      : lambda U: U * 3.184,
         "Raw2Voltage"      : lambda R: R / 3.184,
+        "ControllerType"   : 2,
     },
     {
         "Name"             : "EB312/CellMan",
@@ -142,6 +149,7 @@
         "Raw2BattCurrent"  : lambda R: (2.86 * R) - 0.1,
         "Voltage2Raw"      : lambda U: U * 3.184,
         "Raw2Voltage"      : lambda R: R / 3.184,
+        "ControllerType"   : 3,
     },
     {
         "Name"             : "EB318/CellMan",
@@ -151,6 +159,7 @@
         "Raw2BattCurrent"  : lambda R: (4.28 * R) - 0.06,
         "Voltage2Raw"      : lambda U: U * 3.184,
         "Raw2Voltage"      : lambda R: R / 3.184,
+        "ControllerType"   : 5,
     },
 ];
 
@@ -171,6 +180,7 @@
         "Widget"      : infineon.PWT_COMBOBOX,
         "Range"       : (1, len (ControllerTypeDesc)),
         "GetDisplay"  : lambda prof, v: ControllerTypeDesc [v - 1]["Name"],
+        "ToRaw"       : lambda prof, v: v,
     },
 
     "PhaseCurrent" :
@@ -677,7 +687,7 @@
         "SensorAngle",
         "PASMaxSpeed",
         "LimitCruise",
-        3,
+        "ControllerType",
         0,
         0,
         0,
Last edited by kifukarider on Sep 26 2013 9:04am, edited 1 time in total.

cwah   10 GW

10 GW
Posts: 4181
Joined: Jul 24 2011 5:42am
Location: Between paris and london

Re: XPD: open-source keywin e-bike lab replacement

Post by cwah » Sep 26 2013 5:53am

Can it work for mac?
Help me find my stolen electric brompton: http://bit.ly/1a0vbBC and Bosch Sinus B3 http://bit.ly/1eV0WQz

kifukarider   10 W

10 W
Posts: 71
Joined: May 06 2013 3:05am

Re: XPD: open-source keywin e-bike lab replacement

Post by kifukarider » Sep 26 2013 8:58am

cwah wrote:Can it work for mac?
I'm going to have to go ahead and confidently say yes. However, it won't be simple.

XPD needs:
  • Python 2.7
    Python runs on Windows, Linux/Unix, Mac OS X, and has been ported to the Java and .NET virtual machines.
    http://python.org/
  • PyGTK 2.24
    PyGTK applications are truly multiplatform and they're able to run, unmodified, on Linux, Windows, MacOS X and other platforms.
    http://www.pygtk.org/
  • PySerial 2.6
    This module encapsulates the access for the serial port. It provides backends for Python running on Windows, Linux, BSD (possibly any POSIX compliant system), Jython and IronPython (.NET and Mono).
    http://pyserial.sourceforge.net/pyserial.html

    Relevent Mac OS X support code from http://sourceforge.net/p/pyserial/code/ ... alposix.py

    Code: Select all

    elif plat[:6] == 'darwin':   # OS X
    
        version = os.uname()[2].split('.')
        # Tiger or above can support arbitrary serial speeds
        if int(version[0]) >= 8:
            def set_special_baudrate(port, baudrate):
                # use IOKit-specific call to set up high speeds
                import array, fcntl
                buf = array.array('i', [baudrate])
                IOSSIOSPEED = 0x80045402 #_IOW('T', 2, speed_t)
                fcntl.ioctl(port.fd, IOSSIOSPEED, buf, 1)
        else: # version < 8
            def set_special_baudrate(port, baudrate):
                raise ValueError("baud rate not supported")
    
        def device(port):
            return '/dev/cuad%d' % port
    
        baudrate_constants = {}
    

cwah   10 GW

10 GW
Posts: 4181
Joined: Jul 24 2011 5:42am
Location: Between paris and london

Re: XPD: open-source keywin e-bike lab replacement

Post by cwah » Sep 26 2013 5:55pm

Thanks, I'm already drowning :lol:

I don't even know how to install them on my mac with the source :lol:
Help me find my stolen electric brompton: http://bit.ly/1a0vbBC and Bosch Sinus B3 http://bit.ly/1eV0WQz

kifukarider   10 W

10 W
Posts: 71
Joined: May 06 2013 3:05am

Re: XPD: open-source keywin e-bike lab replacement

Post by kifukarider » Sep 28 2013 12:16am

cwah wrote:Thanks, I'm already drowning :lol:

I don't even know how to install them on my mac with the source :lol:
If getting it running natively on Mac OS X is to much, you could always install VirtualBox with Windows 7 inside. There are binaries for all of the necessary Python components for Windows. Then it's just of a matter importing the USB serial device into VirtualBox which is straightforward. If you have any ambition to program your controller, I think it is worth the effort.

e-doc   1 mW

1 mW
Posts: 13
Joined: Jul 11 2012 3:57pm

Re: XPD: open-source keywin e-bike lab replacement

Post by e-doc » Dec 04 2013 6:26am

Does XPD works with EB312 controllers?

How to install on a (very) old WinXP notebook?

I want to use the RS232 serial port without using a USB-to-RS232-serial-converter. Is this possible?
I know in this case I have to use a RS232-level-to-TTL-level-converter (MAX232).

User avatar
anpaza   10 W

10 W
Posts: 69
Joined: Dec 07 2010 5:24pm

Re: XPD: open-source keywin e-bike lab replacement

Post by anpaza » Dec 04 2013 8:33am

kifukarider wrote:Thank you Andrey!
I wanted to compare the output of XPD before I sent data to the controller. I installed some virtual serial ports and collected the data using debug-read-EB3xx.py. I only found one difference between the hexed software and XPD in which data[27]=3 is hard coded. The hexed programs set data[27] to the index of the controller type. Setting data[27]=3 would indicate EB312. I modified my copy of XPD from trunk and included a patch below in case you're interested.
Thank you a lot! I had the impression the byte 27 is just always '3' standing for third version of the controller (e.g. EB3xx) but it seems I just checked with EB312 :)

Anyways, it looks like that byte is not used anyway, as nobody had any problems programming all types of controllers. However, I have included your patch and it will be in next version. Thank you once again! :)

As for MacOS, you need a relatively recent PySerial version that supports MacOS. XPD itself will list any /dev/tty.usbserial* devices it finds in the drop-down list. Of course, you will also need to set up PyGTK.

I would be glad if someone could put up a working instruction for MacOS, as I don't have access to any Mac. I get regularily questions about this.

P.S. I'm sorry to appear here so seldom... I work on two jobs, and doing some volunteer work, so I have literally zero free time.

User avatar
anpaza   10 W

10 W
Posts: 69
Joined: Dec 07 2010 5:24pm

Re: XPD: open-source keywin e-bike lab replacement

Post by anpaza » Dec 04 2013 8:40am

e-doc wrote:Does XPD works with EB312 controllers?
How to install on a (very) old WinXP notebook?
Just like on any other windows system.
e-doc wrote: I want to use the RS232 serial port without using a USB-to-RS232-serial-converter. Is this possible?
I know in this case I have to use a RS232-level-to-TTL-level-converter (MAX232).
That's possible, under Windows that'll work out of the box (serial ports are always COM*), under Unix you'll have to modify xpdm/scanposix.py and add /dev/ttyS* to the list of serial ports to show in the drop-down list, under Mac you'll have to add /dev/cuad* to that list.

And don't forget the level converter, you'll blow the controller if you connect RS-232 directly (it uses +/- 12V voltage levels while MCU wants 0-5V).
Also you'll have to get somewhere +5V to feed the MCU, otherwise it won't work (and you need a way to turn +5V on or off, to be able to reset the MCU).

User avatar
anpaza   10 W

10 W
Posts: 69
Joined: Dec 07 2010 5:24pm

Re: XPD: open-source keywin e-bike lab replacement

Post by anpaza » Dec 04 2013 8:57am

jovae49 wrote:
gwhy! wrote:I will also post this up this is my v3 adaptor. The capacitor fixed quite a lot of issues for me when using the lead on different pc's .
There was an error on this scheme. The switch should not be connected to the +5 V but the 0V. Here is the right schema:
Image
That's interesting and it could help to the problem that many experience that controller isn't accepting commands even after the voltage switch being turned off and on again.
That could happen because of the parasitic feed via the TX pin, the switch on VCC won't interrupt the TX pin, thus the MCU could not be RESET by interrupting the VCC line.
By interrupting the GND we will cut off the voltage feed both through VCC and TX pins, thus this approach looks more safe. But the button should be normally OFF, on your drawing it's normally ON.

The best would be to use a dual-switch button to interrupt both GND and VCC... and perhaps even to short the VCC side of the controller to GND (when the power to controller is OFF), to discharge the VCC capacitor inside the controller.
Last edited by anpaza on Dec 04 2013 9:38am, edited 1 time in total.

e-doc   1 mW

1 mW
Posts: 13
Joined: Jul 11 2012 3:57pm

Re: XPD: open-source keywin e-bike lab replacement

Post by e-doc » Dec 04 2013 9:06am

Thank you, Anpaza.

efergy kb   10 mW

10 mW
Posts: 29
Joined: Oct 08 2013 8:43am
Location: Sydney

Re: XPD: open-source keywin e-bike lab replacement

Post by efergy kb » Mar 21 2014 9:01pm

I bought the 12 FET IRFB3077 INFINEON CONTROLLER (MOTOR WITH HALL SENSORS) from EM3EV from Paul.

How do i know which profile i should be using by default with XPD?
There is a profile '12FET default' preset 2 different controller version Infineon 2 & 3.

Been advised from LBS (who are also on this forum) to set it lower than the factory as it will shorten the life of my batter
I'm trying to set the battery current limit & phase limit down. Batter from 30 to 20, and Phase from 'x' to 30A

DAND214   1 GW

1 GW
Posts: 3165
Joined: Aug 10 2008 8:28pm
Location: About 1200 miles south of Chicago, in sunny/rainny Port Richey, Florida!

Re: XPD: open-source keywin e-bike lab replacement

Post by DAND214 » Mar 21 2014 10:19pm

Could you list what you are trying to control.
Notor, battery v & ah and bike and weight.

I don't think you will be happy with 30a phase. that is like putting a 24v battery in a 48v system.

If you bought it from Paul, why not use his software and his settings first. Then make adjustments. I know there is no way to see what your controller is set at before reprogramming it. paul should have a factory setting that you can adjust.

I do know that 30a phase didn't work for me.

Dan

efergy kb   10 mW

10 mW
Posts: 29
Joined: Oct 08 2013 8:43am
Location: Sydney

Re: XPD: open-source keywin e-bike lab replacement

Post by efergy kb » Mar 22 2014 6:56am

Nuts! its too late now. I've already resetted to one of the profiles on XPD! ;p
i'll get on to Paul.

The eLBS said the battery from Paul are good for a first ebike, He's just advised to lower the amps on the controller to try prolong the life of the battery.

MAC 8T Rear, Controller Type: 12 Fet 40A (36-52V, IRFB3077), Battery: 50V 12.3Ah 580Whr
http://www.changebike.com/product_fb_df-609D-W.html 13kg folding mountain bike.
Also - how do i know which model this is? EB312 or EB212?

@Dan - what do you mean the 30a phase didn't work for you? Do you have a similar battery?

User avatar
izeman   10 GW

10 GW
Posts: 4919
Joined: Jun 21 2011 8:25am
Location: vienna, austria
Contact:

Re: XPD: open-source keywin e-bike lab replacement

Post by izeman » Mar 22 2014 7:18am

just open the controller. there it's written on the board. 312 or 212. i don't think there is a way to determine from the outside. on the other hand if this is quite new it's 100% a 3xx series. 2xx where sold some 2 years ago.
and especially for the mac paul started bundling it with the 3xx controllers as they match better with high rev motors.

User avatar
izeman   10 GW

10 GW
Posts: 4919
Joined: Jun 21 2011 8:25am
Location: vienna, austria
Contact:

Re: XPD: open-source keywin e-bike lab replacement

Post by izeman » Mar 22 2014 7:20am

also take care the programmer cable is wired differently for the two controllers! not big deal to adjust, but you need to do it.

DAND214   1 GW

1 GW
Posts: 3165
Joined: Aug 10 2008 8:28pm
Location: About 1200 miles south of Chicago, in sunny/rainny Port Richey, Florida!

Re: XPD: open-source keywin e-bike lab replacement

Post by DAND214 » Mar 22 2014 9:03am

I am running a 8t MAC with a EB312.
battery wise has been from 12s or 15s LiPo. The motor was very weak if I ran 30a battery and anything less than phase 2x battery.

Rather sure you have a EB312 since Paul only lists the programming cable for it. Unless you bought it a few years ago, which he didn't offer that battery back then.

I am guessing the it's the INR18650-20R cells which are rated for 10C. Which pack do you have? The 580 w/h or the ??

All you can do is try it. Don't like it change it, that is what this is all a bout.

Dan

User avatar
Obiwan007   1 kW

1 kW
Posts: 331
Joined: Dec 16 2012 11:46pm
Location: Northern California

Re: XPD: open-source keywin e-bike lab replacement

Post by Obiwan007 » Mar 28 2014 1:15am

I have just read through this whole thread and please let me say thanks to you all for the fine work and help over the last couple years. Anpaza, well done! It has been a big help to me and I feel a bit better equipped to work out the problems I am having flashing the controller on my just finished build http://endless-sphere.com/forums/viewto ... =2&t=55605. Got some good techie friends though so I am sure we can get it sorted. May have a few questions later. Am currently working on safely installing this cruise module with teklektik (another saint):
image.jpg
image.jpg (183.18 KiB) Viewed 3821 times
I just really like the convenience of it over the CA method. Hope to report back with instructions on the CA V3 thread when we get it working properly. Obiwan

bart1006   10 W

10 W
Posts: 90
Joined: Sep 24 2012 11:10am
Location: Zwolle

Re: XPD: open-source keywin e-bike lab replacement

Post by bart1006 » Apr 08 2014 1:28am

kifukarider wrote:
cwah wrote:Thanks, I'm already drowning :lol:

I don't even know how to install them on my mac with the source :lol:
If getting it running natively on Mac OS X is to much, you could always install VirtualBox with Windows 7 inside. There are binaries for all of the necessary Python components for Windows. Then it's just of a matter importing the USB serial device into VirtualBox which is straightforward. If you have any ambition to program your controller, I think it is worth the effort.

I didn't see this thread. But i got the XPD working on my MacBook Pro. It was a little bit of a struggle but if some of you are interested i can tell what i did.
If it works for more people we could share the information how we got it to work.

Let me know if somebody would also like to try it!

User avatar
Obiwan007   1 kW

1 kW
Posts: 331
Joined: Dec 16 2012 11:46pm
Location: Northern California

Re: XPD: open-source keywin e-bike lab replacement

Post by Obiwan007 » Apr 08 2014 10:00am

Bart, I would love the information on how to get this working on a Mac. Please do expound! Obiwan

bart1006   10 W

10 W
Posts: 90
Joined: Sep 24 2012 11:10am
Location: Zwolle

Re: XPD: open-source keywin e-bike lab replacement

Post by bart1006 » Apr 11 2014 6:09am

Obiwan007 wrote:Bart, I would love the information on how to get this working on a Mac. Please do expound! Obiwan
Ok here we go ;-)

Download the XPD software for mac:
http://prdownload.berlios.de/xpd/xpd-0.3.2.tar.bz2
Just unzip somewhere you prefer.

Download the driver for the usb serial cable:
http://plugable.com/drivers/prolific
And I followed the instruction on this site to check if everything went well:
http://plugable.com/2011/07/12/installi ... ent-page-2
remember the IODialinDevice my one was “/dev/tty.usbserial” you will need it later on.

Download and install Python:
https://www.python.org/download/

Download and install pySerial:
https://pypi.python.org/pypi/pyserial >> pyserial-2.7.tar.gz (md5)
Unzip it and install it from the Terminal program:
Go to the pyserial directory the command looks something like this if (you are in the directory where you unzipped it):
cd pyserial-2.7
and run the following command
sudo python setup.py install

Change settings in for XPD software:
Go to the directory where you unzipped XPD.
There you will find the file “scan_posix.py” in map xpd-0.3.2/xpdm.
Change de code “(glob.glob('/dev/ttyUSB*')): “ to the information of IODialinDevice which we found in step two. For me I had to change it to “(glob.glob('/dev/tty.usbserial*')): “

That’s it!
When you start xpd you get an error that the file xpd.svg can’t be openend. That’s not a problem. I think you can change it by first change the file type in something Mac knows and change the reference in the gui.xml.

danoulz   10 mW

10 mW
Posts: 20
Joined: Sep 08 2009 9:49am

Re: XPD: open-source keywin e-bike lab replacement

Post by danoulz » Apr 25 2014 7:29am

joss76 wrote: other , I test yesterday to use XPD whith EB806 board but it's don't work ? it's though a XC846 infineon chip ...
I too have a 6-FET controller, Infineon XC846 chip, EB806 board (which is supported by KeyWin Ebike-Lab ParameterDesigner.exe).
I am right in assuming that the EB206 settings will not work in XPD?

Many thanks! Regards, Dan

Post Reply