KT motor controllers -- Flexible OpenSource firmware for BMSBattery S/Kunteng KT motor controllers (0.25kW up to 5kW)

stancecoke said:
just follow the tutorial that's linked in my signature!

regards
stancecoke
it's not very clear. works or not.
how do I find firmware version?
https://opensourceebikefirmware.bitbucket.io/windows_instructions/index5.html
 
You have to follow chapter 3 for the software installation. There are all necessary links.

I don't know, if the Java Tool works recently at casainhos master branch. If it doesn't work, please restore the config.h from the zip and just double-click on Start_Compiling.bat in the "firmware" folder.

https://github.com/OpenSource-EBike-firmware/BMSBattery_S_controllers_firmware/archive/master.zip

regards
stancecoke
 
How to correctly configure the FOC ?
Motor - https://www.alibaba.com/product-detail/CZJB-JB-8-8-inch-electric_60748113719.html?spm=a2700.7724856.2017115.106.692622e68xXYRY
 
Basia said:
How to correctly configure the FOC ?
Motor - https://www.alibaba.com/product-detail/CZJB-JB-8-8-inch-electric_60748113719.html?spm=a2700.7724856.2017115.106.692622e68xXYRY
Read config-example.h file.
 
casainho said:
Basia said:
How to correctly configure the FOC ?
Motor - https://www.alibaba.com/product-detail/CZJB-JB-8-8-inch-electric_60748113719.html?spm=a2700.7724856.2017115.106.692622e68xXYRY
Read config-example.h file.
Can I program the FOC with the battery and motor connected?
 
Hello.

This is my first post here, so I'm going to explain my first electric bike project with some detailed info. I received this badly beaten bike without the original LCD(Bafang C965 -clone, 800U) and e-brakes. Apparently those were stolen from the previous owner. All that was left for me to begin my project with were the motor, PAS, controller(36V, 15A) and the battery. The original bike was 28" and I'm installing these parts to my 26" mtb, so I need to buy shorter spokes etc... I want to keep the bling bling low as to prevent it from stolen that easily and thus I would like to have my bike so that I'ts not controlled by LCD and buttons. I'm also trying to save money here and I have understood that it is possible to reprogram bafang controllers to bypass LCD so that option is my route to go if it would be possible with this project. I also want a throttle with full power when needed. Optionally I would like to have a cheat mode so that I can change the motor performance at flight in case of inspection(only PAS and 25kph allowed here in Finland). In that case cruise mode at the throttle would be cool too when the "legality cheat" is activated.

My motor is this Shengyi Hybrid rear hub motor: http://www.syimotor.com/productDe_5.html
Battery is this 36V 10ah Li-ion: https://www.verkkokauppa.com/fi/product/53005/ffgfn/GZR-MTB-ja-UTB-akku

The original bike didn't have a throttle, so I ordered an universal one from Aliexpress and I'm currently waiting it to arrive. In the meantime I was studying the endless river of controllers with similarity to mine and came accross this project to find out that my controller looks very much like the BMSBattery/Kunteng KT -controllers. So, long story short. I ordered my ST-LinkV2 from ebay and also soldered the male pins to the pcb. If this controller is not fit for this project for some reason I can also buy a suitable one somewhere.

I need your help here. First of all some basic stuff;
1. Can you tell from my pictures is my controller suitable for this firmware?
2. When connecting the ST-Link v2 to my computer should the controller be powered by my e bike battery?
3. How can I tell what my controller's firmware is to get the original backup file? Can I somehow read it with the ST-Linkv2 connection?
4. Are my connections to ST-link v2 right? The arrangement of wires seems a bit different than what the project page picture shows.
5. When my throttle arrives. Where should I solder it to my pcb leads?
6. What are those two insulated black lumps of wires inside the controller case?
7. There was one lead coming out from the controller that had red and brown wires attached to a plug. I thought this is main power plug so I soldered a switch to the ends to act like one. If this is wrong. Please correct me.

Since this post has some offtopics like the throttle installation questions, I'm more than happy to start a new thread for my project if it seems fit. Thank you so much from this hard work you have already done to help me dive in to this whole e bike controller swamp I cannot seem to get up on my own ever again. :)

Here are some pictures. Feel free to ask for more in-depth ones if needed to help answering my questions.
nNUN4Ys

K5uKmuK

XkkxQD4

DN8XIw5

yvzcWPz


all above pictures at: https://imgur.com/a/9FbEq3I
 
Basia said:
casainho said:
Basia said:
How to correctly configure the FOC ?
Motor - https://www.alibaba.com/product-detail/CZJB-JB-8-8-inch-electric_60748113719.html?spm=a2700.7724856.2017115.106.692622e68xXYRY
Read config-example.h file.
Can I program the FOC with the battery and motor connected?
Don't know if you mean FOC as the firmware.
I program the firmware with battery and motor connected. But my 5V wire of STLinkV2 is not connected to the board. Also my battery has a BMS for protection in case something goes wrong. Also the ebike wheel is on the air, because for some fail, motor can start.
 
Valopallo said:
This thread is for KT/BMSBattery motor controllers only.
 
casainho said:
Valopallo said:
This thread is for KT/BMSBattery motor controllers only.

Ok. So the controller that I have is not KT nor BMSBattery even though it's very similar looking?
How do I know can this one be programmed?


For the other assembly questions I will start my own thread. ;)
 
Valopallo said:
I need your help here. First of all some basic stuff;
1. Can you tell from my pictures is my controller suitable for this firmware?
2. When connecting the ST-Link v2 to my computer should the controller be powered by my e bike battery?
3. How can I tell what my controller's firmware is to get the original backup file? Can I somehow read it with the ST-Linkv2 connection?
4. Are my connections to ST-link v2 right? The arrangement of wires seems a bit different than what the project page picture shows.
5. When my throttle arrives. Where should I solder it to my pcb leads?
6. What are those two insulated black lumps of wires inside the controller case?
7. There was one lead coming out from the controller that had red and brown wires attached to a plug. I thought this is main power plug so I soldered a switch to the ends to act like one. If this is wrong. Please correct me.

Hi Valopallo, I'm not a developer or an expert on this stuff, but I'll try to help with your questions where I can.

1. This firmware will only work with the Kunteng sine wave controllers (S06S or S12S from BMS battery, or the equivalents from PSWpower). You would be best to start with one of these, then you would have all the connection diagrams you need.

2. When flashing the firmware you can power from the STlink if you have connected the +5v wire, otherwise you can use the controller main battery power.

3. You won't be able to read the original Kunteng firmware and this will be lost once you re-flash the new firmware. Probably best if you get it all working and prove your hardware is ok with the stock firmware before you try the new.

4,5,6,7...will all be easy if you get the Kunteng controller.
 
Hm, new findings about regen.
I tried to improve the algorithm for Advance Angle adjustion at regen, but it seems the value ui8_position_correction_value has almost no influence on the zero crossing of the phase current.
In the naming of the graphs in the pictures mean
ui8_position_correction_value - ui16_BatteryCurrent - dutycycle- ui16_motor_speed_erps

maybe this is because the quite low dutycycle...
It is interesting, that the phase current is higher at lower erps, but a guy at the pedelecforum reported the same behaviour.

regards
stancecoke

Phase current at different advance angles.PNG
 
stancecoke said:
Hm, new findings about regen.
I tried to improve the algorithm for Advance Angle adjustion at regen, but it seems the value ui8_position_correction_value has almost no influence on the zero crossing of the phase current.
Today I also tried my direct drive motor and regen. It doesn't work well...

ui8_position_correction_value has almost no influence on the zero crossing of the phase current
You mean in regen mode, right? If so, do you have an idea what we should do?

stancecoke said:
In the naming of the graphs in the pictures mean
ui8_position_correction_value - ui16_BatteryCurrent - dutycycle- ui16_motor_speed_erps
I would like to understand you graphs and experience. Can you please explain?

stancecoke said:
maybe this is because the quite low dutycycle...
It is interesting, that the phase current is higher at lower erps, but a guy at the pedelecforum reported the same behaviour.
You mean at regen or motor mode?
 
Code:
motor.c:560: warning 94: comparison is always false due to limited range of data type
motor.c:601: error 20: Undefined identifier 'LI_ION_CELL_VOLTS_0'
motor.c:608: error 20: Undefined identifier 'LI_ION_CELL_VOLTS_MAX'

make sure, that LI_ION_CELL_VOLTS_0 and LI_ION_CELL_VOLTS_MAX are defined in the config.h
Don't use the Java-Tool, it's not up to date. Extract the zip file again and have a new try!

Why do you use eclipse?! Do you want to implement new features to the firmware?

regards
stancecoke
 
stancecoke said:
Code:
motor.c:560: warning 94: comparison is always false due to limited range of data type
motor.c:601: error 20: Undefined identifier 'LI_ION_CELL_VOLTS_0'
motor.c:608: error 20: Undefined identifier 'LI_ION_CELL_VOLTS_MAX'

make sure, that LI_ION_CELL_VOLTS_0 and LI_ION_CELL_VOLTS_MAX are defined in the config.h
Don't use the Java-Tool, it's not up to date. Extract the zip file again and have a new try!

Why do you use eclipse?! Do you want to implement new features to the firmware?

regards
stancecoke

Extract zip archive and run start_compiling.bat and writeoptionbytes.bat? Java-tool only for configuration?
 
Basia said:
Extract zip archive and run start_compiling.bat and writeoptionbytes.bat? Java-tool only for configuration?

All user relevant parameters are defined in the config.h. You have to modify the config.h according to your system, e.g. the battery setup.
You can use any text editor to edit the config.h, with eclipse it's quite comfortable. The meaning of each parameter is decribed in chapter 4. DESCRIPTION OF THE GUI of the tutorial (not up to date) and in the config-example.h (up to date)

The Java-Tool is just another way to modify the config.h It overwrites the existing config.h with the settings of the GUI. As casainhos latest changes of relevant parameters are not implemented in the Java-Tool yet, compiling doesn't work with the config.h that's created by the Java tool at the moment, I will update the Tool soon.

The writeoptionbytes.bat has to be run only once to remove the write protection, this works with the Java Tool, too.

The start_compiling.bat has to be run every time you want to flash changed parameters to the controller.

regards
stancecoke
 
casainho said:
ui8_position_correction_value has almost no influence on the zero crossing of the phase current
You mean in regen mode, right? If so, do you have an idea what we should do?

The whole post is about regen mode. I have no idea what to do at the moment. I will do some further test on my testbench. The shown data in the graph is from a real test ride.

casainho said:
I would like to understand you graphs and experience. Can you please explain?

89-289-33-20 in the graph means
ui8_position_correction_value = 89
ui16_BatteryCurrent = 289
dutycycle = 33
ui16_motor_speed_erps = 20

The data is from a single regen braking from appr. 20km/h to 0 km/h (see decreasing erps)

regards
stancecoke
 
stancecoke said:
casainho said:
ui8_position_correction_value has almost no influence on the zero crossing of the phase current
You mean in regen mode, right? If so, do you have an idea what we should do?

The whole post is about regen mode. I have no idea what to do at the moment. I will do some further test on my testbench. The shown data in the graph is from a real test ride.

casainho said:
I would like to understand you graphs and experience. Can you please explain?

89-289-33-20 in the graph means
ui8_position_correction_value = 89
ui16_BatteryCurrent = 289
dutycycle = 33
ui16_motor_speed_erps = 20

The data is from a single regen braking from appr. 20km/h to 0 km/h (see decreasing erps)
I would like to understand why there are 4 sinewaves on the graph...
 
casainho said:
I would like to understand why there are 4 sinewaves on the graph...

It's to show, that there is no difference in phase shift for different values of the advance angle (correction value)
x-axis: rotor position
y-axis: phase B current

regards
stancecoke
 
stancecoke said:
Hm, new findings about regen.
I tried to improve the algorithm for Advance Angle adjustion at regen, but it seems the value ui8_position_correction_value has almost no influence on the zero crossing of the phase current.
In the naming of the graphs in the pictures mean
ui8_position_correction_value - ui16_BatteryCurrent - dutycycle- ui16_motor_speed_erps

maybe this is because the quite low dutycycle...
It is interesting, that the phase current is higher at lower erps, but a guy at the pedelecforum reported the same behaviour.
Do you consider that blue line, has a higher regen current and so for different angles you have more or less regen current or that was just because the speed was different at each test?

So, duty-cycle of 33 and 21 are bout 10% of max of 255, on a 48V battery is about phase voltage 5V.

That ~300 on battery current represents how much amps?

Yes, that ERPS value is low...
 
casainho said:
Do you consider that blue line, has a higher regen current and so for different angles you have more or less regen current or that was just because the speed was different at each test?

the blue line belongs to the lowest regen current.
Calibration of battery-current:
Zero 312
1A ~ 10 digits

so a Battery current value of 307 means about -0.5A (regen)

casainho said:
So, duty-cycle of 33 and 21 are bout 10% of max of 255, on a 48V battery is about phase voltage 5V.
Yes, and I think that's why we can't influence the phase position of the phase current with the advance angle. The back-emf dominates the voltage and is only slightly superimposed by the voltage from the PWM.

If we increase the dutycycle, we will get motor mode...

casainho said:
Yes, that ERPS value is low...
Yes, but that's normal for a direct drive....

regards
stancecoke
 
Is it possible to turn on the S06S(or other KT/BMSBattery controllers) without the ON -button of LCD or LED? So the real question is, can I for example input a mimicing signal to the wire that goes to pcb's RX terminal(the wire is yellow colored at my main cable harness)? Is it that simple to awake the controller for operation and use with throttle or PAS? I need to test my wiring between motor and controller to make sure it's not damaged but cannot confirm my controller is KT/BMSBattery S for sure even it looks very similar to these. That would move me to the right direction figuring out this mystery controller of mine.
 
Back
Top