OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Electric Motors and Controllers
dkmorb
1 mW
1 mW
Posts: 10
Joined: Nov 28, 2017 12:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by dkmorb » Nov 28, 2017 4:16 pm

Yes sir! It works now!
I've to buy the controller now :-) How long does it take the controller to arrive from bmsbattery.com?

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 29, 2017 3:32 am

dkmorb wrote:
Nov 28, 2017 4:16 pm
Yes sir! It works now!
I've to buy the controller now :-) How long does it take the controller to arrive from bmsbattery.com?
Good you could build the firmware -- and I just tested and added battery voltage max protection while regen.

For me that I am in Portugal, after the ship, takes about 2 weeks for the package arrive in UK and after another 1 week from UK to Portugal. You may ask why they send first to UK, that way It will not stop in Portugal customs for more 2 or 3 weeks and I don't pay taxes.

I can ask them to ship very fast like by DHL, it may just take 1 week but I will have to pay a lot on customs as also extra fees for DHL work on customs, etc....

What I do is asking for the cheaper even if slower shipment, buy extra hardware, like some units of controllers, LCDs, etc so I can play with them and repair if something burn during the development :-)
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 29, 2017 3:37 am

stancecoke, I added to the master the battery max voltage protection while regen and it works as expected. Now we can use again a lab power supply for development but it will simple not brake. (I don't remember if you added already this feature to your fork).
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
100 W
100 W
Posts: 299
Joined: Aug 02, 2017 2:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by stancecoke » Nov 29, 2017 4:07 am

casainho wrote:
Nov 29, 2017 3:37 am
I added to the master the battery max voltage protection while regen and it works as expected.
That's great and should protect the hardware of battery and controller!
casainho wrote:
Nov 29, 2017 3:37 am
(I don't remember if you added already this feature to your fork).
I'm not planning to implement all that stuff in my fork, as my aim is still to close my fork. I can't afford to spend much time in our project at the moment.
dkmorb wrote:
Nov 28, 2017 4:16 pm
I've to buy the controller now :-)
You can get the controller at aliexpress, too. Shipping might be cheaper there.
https://de.aliexpress.com/store/group/S ... 98312.html

regards
stancecoke

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 29, 2017 6:16 am

dkmorb wrote:
Nov 28, 2017 1:19 pm
Hi all, I'm new here.
I'm trying to compile your code (...)
Can you please share with us some information, so we can understand better your needs:
1. can you please tell us why are you interested to use the firmware?
2. what bicycle type do you have, what is the kind of usage?
3. which motor, battery pack voltage?
4. do you use throttle, PAS, torque sensor, regen brakes?
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

dkmorb
1 mW
1 mW
Posts: 10
Joined: Nov 28, 2017 12:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by dkmorb » Nov 29, 2017 9:30 am

Hi guys,
I want to order on digikey some mosfets; i find a80nf70.
I would to try a personal build using ir2110 too.

dkmorb
1 mW
1 mW
Posts: 10
Joined: Nov 28, 2017 12:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by dkmorb » Nov 29, 2017 9:35 am

1. can you please tell us why are you interested to use the firmware?
I'm interested in electric motor and so now I want to experiment, but i'm a professional programmer (db layer C#, almost)
2. what bicycle type do you have, what is the kind of usage?
I haven't a bike, but I would go to work by bike
3. which motor, battery pack voltage?
I would like to buy and drive a big motor (1500W / 2000W)
4. do you use throttle, PAS, torque sensor, regen brakes?
Well...i don't know :-)

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 29, 2017 9:43 am

dkmorb wrote:
Nov 29, 2017 9:35 am
1. can you please tell us why are you interested to use the firmware?
I'm interested in electric motor and so now I want to experiment, but i'm a professional programmer (db layer C#, almost)
I thought that making a generic motor controller using S series controller that can be controlled by UART and Arduino, could be interesting for playing with brushless motors using Arduino.

For what kind of application wold you use the motor for?
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

dkmorb
1 mW
1 mW
Posts: 10
Joined: Nov 28, 2017 12:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by dkmorb » Nov 29, 2017 10:11 am

So we are tuned on the same subject! o mundo é pequeno...

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 29, 2017 10:34 am

dkmorb wrote:
Nov 29, 2017 10:11 am
So we are tuned on the same subject! o mundo é pequeno...
Sim :-)

If you can give more details of what you are looking for, we can think of it and maybe try to develop for a generic motor controller as also keep developing for EBike application. It is much simple to develop if we know the real needs of the application.
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 29, 2017 1:59 pm

My Q11 is now working very well - I had corrected a bug on the motor code.
Then I moved to S12S controller and my EBike 48V - with this, the Q11 motor runs at 42 km/h. Then I configured regen current to 25A and recorded the following video -- regen very strong and fast!! -- not mechanical braking were used:



I did some ride tests and is really great and strong the ebrake (although I used for riding, 15A for regen). I was using the torque sensor and configured regen current = 0 so I can coast my legs/pedals when I want a rest but as soon I use brakes, regen current is configure to 15A and I get the strong ebrake/regen. When I release brakes, I get regen current again = 0 and I can pedal and stop pedaling and rest my legs when I want.

Next, I want to use my torque sensor + PAS that I added:
Image
Image

and I will use both signals to detect when I stop rotating the pedals and move them backwards, and count how many PAS signal changes/steps I moved and apply a regen current that will scale with the number of backwards PAS steps. The torque sensor have 12 magnets equally spaced that give 24 PAS signal changes/steps per crank revolution and this should be a nice resolution to be able to ebrake nicely and smooth :-)
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

dkmorb
1 mW
1 mW
Posts: 10
Joined: Nov 28, 2017 12:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by dkmorb » Nov 29, 2017 4:33 pm

42 Kh/h
42 kh/h !!! WTH!!! May be this is too dangerous for a bike! Or not? Is this q11 a 500W motor?

dkmorb
1 mW
1 mW
Posts: 10
Joined: Nov 28, 2017 12:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by dkmorb » Nov 29, 2017 4:49 pm

For what kind of application wold you use the motor for?
Well, at the moment, I would build a "simple" little bike like this one:
https://i.ytimg.com/vi/2XLFEvYwaB8/maxresdefault.jpg

So, what kind of mosfet can I order from digikey to build a little and simple controller?
I found this N-Channel Power Mosfet stp80nf70...is it suitable?

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 29, 2017 5:26 pm

I can't help about build or mod a controller. I suggest you to buy S12S controller of 48V 40A, about 2kwh. They also have a 72V version.

The Q11 is a 1kw motor. The cables don't seem to handle much more, they seem to have the same size as their 250 and 500w motors. But the motor seems robust.

I drive up to 45km/h and that is the max speed to where I can pedal, as I like to pedal. In my city we have some large amd long bike lanes.
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 30, 2017 5:45 am

For got to say that I found I were using one LCD5 from were I was not receiving any data and I went o look and found it has a different CRC ^ ? than the other LCD5 and I was able to get it working, right now the current code is:

Code: Select all

    // see if CRC is ok
    if (((ui8_crc ^ 10) == ui8_rx_buffer [7]) 	|| // some versions of CRC LCD5 (??)
	((ui8_crc ^ 9) == ui8_rx_buffer [7]) 	|| // CRC LCD5
	((ui8_crc ^ 2) == ui8_rx_buffer [7])) 	   // CRC LCD3
    {
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 30, 2017 9:53 am

I just implemented and did some rides with the regen ebrake like coast brakes

How does it wok?
- ebike rider can pedal forward as usual or stop pedaling for rest
- when ebike rider want to ebrake for reducing speed (without using mechanical brakes), needs to rotate backwards the pedals
- one full rotation of the pedals equals to 24 points and I implemented in a way that 5 point of backwards rotation gives the full ebrake power, while 1 point gives 1/5 of the full ebrake power and so on

The implementation needs in fact 6 points, and the first one is a neutral point that is needed to detect pedal rotating backward. This point also works well as a hysteresis.

I did some rides and on the video, I did ebrake so strong that I almost did fall...

Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

honya96
10 mW
10 mW
Posts: 31
Joined: Mar 05, 2015 9:38 am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by honya96 » Nov 30, 2017 11:26 am

I think that its not a good way of applying regen for most users. Try variable regen with something like this http://s.aliexpress.com/FnQJ7f6F if the controller cant see analog voltage input, then this module will convert output voltage of brake lever (hall thumb throttle as brake) to pwm.

What about the torque controll throttle? Is it implemented?

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 30, 2017 12:17 pm

honya96 wrote:
Nov 30, 2017 11:26 am
I think that its not a good way of applying regen for most users. Try variable regen with something like this http://s.aliexpress.com/FnQJ7f6F if the controller cant see analog voltage input, then this module will convert output voltage of brake lever (hall thumb throttle as brake) to pwm.

What about the torque controll throttle? Is it implemented?
Yes, maybe not for everyone. For ones like me, that live on flat lands and have some background on fixed bikes, this is nice. Or maybe the ones that are used to coast brakes.

The controller have at least 2 analog inputs: throttle and torque sensor.

Yes, torque control throttle and "torque + speed" control.
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
100 W
100 W
Posts: 299
Joined: Aug 02, 2017 2:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by stancecoke » Nov 30, 2017 1:01 pm

Puh, luckily you didn't tumble off the bike!

As I see in the code, you have used the pad X4 also!
But I can't find a direction detection for PAS2 in the code. Has the additional PAS an internal direction detection?
honya96 wrote:
Nov 30, 2017 11:26 am
(hall thumb throttle as brake)
This solution is already implemented in the torque-simulation fork.

Regards
stancecoke
Last edited by stancecoke on Nov 30, 2017 1:46 pm, edited 1 time in total.

1N4001
1 µW
1 µW
Posts: 4
Joined: Nov 28, 2017 7:55 am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by 1N4001 » Nov 30, 2017 1:20 pm

I've been following this project for a dew days now and I must say that I'm impressed. You guys are doing a great job!

The idea of doing regen when pedaling backwards is great. Add a bit of a delay until the regen sets in you you have a great solution that doesn't need additional hardware.


I have a question of my own. I am planning on running a S12SN (possibly even the 72V variant) with this firmware. Since it was only tested on the S6 and S12S, I am wondering if it can work. I can tweak and play around some (Linux dev environment is available), but I am no match for your programming skills. So do you think it might be possible and worth a try?

daffy99
100 mW
100 mW
Posts: 38
Joined: Jul 16, 2017 2:15 am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by daffy99 » Nov 30, 2017 1:54 pm

casainho wrote:
Nov 30, 2017 9:53 am
- when ebike rider want to ebrake for reducing speed (without using mechanical brakes), needs to rotate backwards the pedals
That's a very interesting idea! Has this ever been used before?

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 30, 2017 8:36 pm

stancecoke wrote:
Nov 30, 2017 1:01 pm
As I see in the code, you have used the pad X4 also!
But I can't find a direction detection for PAS2 in the code. Has the additional PAS an internal direction detection?
Yes, thanks for sharing that info about X4 -- and I used it as a digital input pin. I also put your info on the notes.

I use both signals to get the direction and count how many steps, see the image:
Image
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 30, 2017 8:47 pm

1N4001 wrote:
Nov 30, 2017 1:20 pm
I've been following this project for a dew days now and I must say that I'm impressed. You guys are doing a great job!

The idea of doing regen when pedaling backwards is great. Add a bit of a delay until the regen sets in you you have a great solution that doesn't need additional hardware.

I have a question of my own. I am planning on running a S12SN (possibly even the 72V variant) with this firmware. Since it was only tested on the S6 and S12S, I am wondering if it can work. I can tweak and play around some (Linux dev environment is available), but I am no match for your programming skills. So do you think it might be possible and worth a try?
Thanks for the feedback.

On the current implementation, there is a distance (1/24 steps) after the direction inversion (and this can be increased) that is a null. The result is very good, at least for me :-)

So, I own a S12S (S12P moded to S12S) and I it works very well with current firmware. The 72V version I don't know which changes are between the 48V and 72V versions, but I would say only the voltage resistor that reads the battery voltage (not counting with changes on capacitors, etc to handle the higher voltage). That difference I think you will be able to find using a multimeter.

I think someone will want to use the most powerful version of this controllers, and would be great to get knowledge on how to use them. I think Kunteng sells even an higher current version than BMSBattery sells. But go with BMSBattery if you can, because no BMSBattery versions may have some significant changes in hardware, mainly on the available cables/inputs to the microcontroller.
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 947
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 30, 2017 8:48 pm

daffy99 wrote:
Nov 30, 2017 1:54 pm
casainho wrote:
Nov 30, 2017 9:53 am
- when ebike rider want to ebrake for reducing speed (without using mechanical brakes), needs to rotate backwards the pedals
That's a very interesting idea! Has this ever been used before?
I am not aware that anyone had implement this idea before. But this is very similar to coast brakes. Also near the fixed gear bikes.
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

geofft
10 mW
10 mW
Posts: 27
Joined: Nov 09, 2012 9:41 am
Location: Berkshire UK

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by geofft » Dec 01, 2017 4:14 am

I also have been watching this thread with great interest and would like to add my congratulations to you guys on your efforts so far. Will definitely be trying your firmware sometime in the future, I'm no coder but can usually follow instructions to get these things loaded up and working.

Just a small question for casainho regarding the S12P to S12S mod you describe in the link. When this mod is done is the controller still run sensorless or do you add the three hall wires and run it sensored? I ask this as I have a S09P sensorless controller (ordered in error) that I would like to mod to S09S sinewave/sensored operation - is that possible? - unfortunately I have found that my Q128H does not run well in sensorless mode.

Geoff.
BBS02 V2 48v 750w, 12s lipo.
Q128H, S06S 17amp, 48v 12s lipo.

Post Reply