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

Hey Guys,
We are working on a 14S Battery pack and no PAS, wanted to understand how get the controller working in this mode for a 14FET Controller 1000W. Also is there as a way to derate the motor? As in, limit the power output to something like 350W.
 
Hi! I am completely unable to get the thing to generate an ihx file using any of the tools. Any help would be appreciated. I'll give the details if you could help. Thanks!
 
crank2giri said:
Hey Guys,
We are working on a 14S Battery pack and no PAS, wanted to understand how get the controller working in this mode for a 14FET Controller 1000W. Also is there as a way to derate the motor? As in, limit the power output to something like 350W.
Go to the source files and read config-example.h file.
 
DarkDD said:
Hi! I am completely unable to get the thing to generate an ihx file using any of the tools. Any help would be appreciated. I'll give the details if you could help. Thanks!

P.S. I am trying to compile on Windows.

Commenting a line in ebike_app.c works with OSEC parameter configurator. But I want the slightly higher configurability of the firmware configurator tool.

Can I use OSEC configurator and edit config.h then use the .bat file?

I notice that the firmware configurator tool generates a smaller config file...
 
Basia said:
Sometimes the wheel starts to rotate itself without pressing the throttle.
Two possibilities:
1. turn the throttle slightly while switching on the system, then release it after a few seconds
2. Put a small offset to the variable ui8_adc_throttle_offset in the adc.c, as you did it for the battery current before.

Code:
for (ui8_i = 0; ui8_i < 16; ui8_i++)
  {
    ui16_counter = TIM2_GetCounter () + 10; // delay ~10ms
    adc_trigger ();
    while (!ADC1_GetFlagStatus (ADC1_FLAG_EOC)) ; // wait for end of conversion
    ui16_adc_throttle_offset += UI8_ADC_THROTTLE;
  }
  ui16_adc_throttle_offset -= 8;
  ui16_adc_throttle_offset >>= 4;

  ui8_adc_throttle_offset = ui16_adc_throttle_offset;
}

Basia said:
what to choose? pwm directly or current / speed?

You should use current/speed setting.

regards
stancecoke
 
DarkDD said:
Commenting a line in ebike_app.c works with OSEC parameter configurator. But I want the slightly higher configurability of the firmware configurator tool.

Can I use OSEC configurator and edit config.h then use the .bat file?

please post the output of the cmd window, so we can see what's going wrong.
As written several times before, you can use any texteditor to modify the config.h and just double click on start_compiling.bat to start the compiling and flashing process.
The java tool is not editig the existing config.h but overwrites it with the recent settings in the tool.
@casainho: are there new parameters in the config.h since the last update of the java-tool?

regards
stancecoke
 
stancecoke said:
The java tool is not editig the existing config.h but overwrites it with the recent settings in the tool.
@casainho: are there new parameters in the config.h since the last update of the java-tool?
No and in fact, I now think it is not a good idea that software as it takes much time to update. I prefer as a developer, the config-example.h and I think it is not a problem for this users.

Also, I think that having your software version and branch of firmware is a confusion, because I see others like Basia asking things that I don't know which versions are using.

I think would be better to:
- remove the firmware configuration tool and keeping an updated config-example.h, if possible with even more examples/information.
- remove the links to your firmware branch, from the user documentation but keep on developer notes

Also I am more and more away of this project because right now I almost have no ebikes using KT controllers. I just replaced my girlfriend bicycle with a new one and with TSDZ2. My son bicycle will be the next. The only bicycle with a KT controller is another one for me but has a direct drive motor Q11, that his heavy and slow (with 48V battery just runs at about 25km/h when near discharged while TSDZ2 can keep the 35km/h or more) -- seems I bought a bad quality/old technology direct drive motor.
My experience with TSDZ2 is much better than with hub geared motors like Q85 or Q100. I only miss a motor with direct drive for having regen but I don't have one that I know is relative cheap and good.

So, Stancecoke, I hope you can keep developing and improving current code. I am on TSDZ2 code and luckily, is almost the same technology so I hope to share what I learned. But I plan to keep reading here but I will also have no hardware to test new things or understand possible issues of new users.

KT motor controllers are clear better hardware than TSDZ2, and are much easier to develop for!! And even the LCDs, as I am using KT LCD3 with TSDZ2 instead original LCD.

 
Sad to read, that you want to quit this project.... :(

I think there's no problem with the Java Tool, it makes the firmware usable for people who don't have computer skills like you or me :)

If there's a bug in the Java Tool, I can fix it easily. But for this we need the feedback of the users.
I think Basia is using your master. I don't know anyone who uses my fork...

regards
stancecoke
 
stancecoke said:
I've pushed the 5-step-version to a new branch now.
https://github.com/OpenSource-EBike-firmware/BMSBattery_S_controllers_firmware/tree/feature/offroad_mode_5_step

I left the initial values for the step-durations at one second. The tolerance is now settable in the main.h. It is set to 0.8s now.

You can start the code at any time. To make sure, to begin from the start, pull the lever for a few seconds first.

I'll try it in hardware tomorrow.

regards
stancecoke

@stancecoke: I still haven't been able to get offroad mode to trigger. I've been using the exact same timing as your video, also tried various different settings for the timers in main.h but haven't once seen it trigger. I think something's not right, not sure if anyone else has got this to work, I haven't seen any other feedback for this.

No rush for this, I can see you have other help requests to deal with first. If there's anything you want me to try with this though, please ask.... :wink:
 
I've commented out the print commands now, please try again. If this doesn't work, I can't do any more, as I have no LCD3...
But even if this works, the power cut at the speed limit is not implemented in casainhos code yet. So the offroad mode will only work with P3=0.

regards
stancecoke
 
stancecoke said:
Basia said:
Sometimes the wheel starts to rotate itself without pressing the throttle.
Two possibilities:
1. turn the throttle slightly while switching on the system, then release it after a few seconds
2. Put a small offset to the variable ui8_adc_throttle_offset in the adc.c, as you did it for the battery current before.

Code:
for (ui8_i = 0; ui8_i < 16; ui8_i++)
  {
    ui16_counter = TIM2_GetCounter () + 10; // delay ~10ms
    adc_trigger ();
    while (!ADC1_GetFlagStatus (ADC1_FLAG_EOC)) ; // wait for end of conversion
    ui16_adc_throttle_offset += UI8_ADC_THROTTLE;
  }
  ui16_adc_throttle_offset -= 8;
  ui16_adc_throttle_offset >>= 4;

  ui8_adc_throttle_offset = ui16_adc_throttle_offset;
}

Basia said:
what to choose? pwm directly or current / speed?

You should use current/speed setting.

regards
stancecoke

nothing has changed, after one minute the wheel starts to twitch. short pulses are applied to the wheel. I do not understand anything (((
[youtube]ipzApnPyH0I[/youtube]
 
stancecoke said:
DarkDD said:
Commenting a line in ebike_app.c works with OSEC parameter configurator. But I want the slightly higher configurability of the firmware configurator tool.

Can I use OSEC configurator and edit config.h then use the .bat file?

please post the output of the cmd window, so we can see what's going wrong.
As written several times before, you can use any texteditor to modify the config.h and just double click on start_compiling.bat to start the compiling and flashing process.
The java tool is not editig the existing config.h but overwrites it with the recent settings in the tool.
@casainho: are there new parameters in the config.h since the last update of the java-tool?

regards
stancecoke

Hey! Thanks for the quick reply! I edited the config file and got somewhere. Still having an issue..

Code:
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp143. Please contact sdcc authors with source code to reproduce.
sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-ihx --debug  -oebike_app.c ebike_app.c
ebike_app.c:179: warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp0. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp16. Please contact sdcc authors with source code to reproduce.
ebike_app.asm:390: Error: <a> machine specific addressing or addressing mode error
ebike_app.asm:427: Error: <a> machine specific addressing or addressing mode error
removing ebike_app.rel
make: *** [ebike_app.rel] Error 1


Doing the following in ebike_app.c lets me build though...

Code:
 //ebike_app_set_error (EBIKE_APP_ERROR_06_SHORT_CIRCUIT);


i.e. commenting that line...


P.S. I can keep giving you feedback and also help in dev once I get the toolchain down properly! Shall dual boot my system soon!
 
stancecoke said:
Sad to read, that you want to quit this project.... :(

I think there's no problem with the Java Tool, it makes the firmware usable for people who don't have computer skills like you or me :)

If there's a bug in the Java Tool, I can fix it easily. But for this we need the feedback of the users.
I think Basia is using your master. I don't know anyone who uses my fork...
Seems that more people want to use the firmware. I think would be good to have a good documentation and force users to read it before asking for help. Other way I think will be to much work and repetitive questions.

I can also write on main page that this project is no longer being maintained and that new users may or may not get help when asking question on the forum.

What do you prefer?
 
DarkDD said:
stancecoke said:
DarkDD said:
Commenting a line in ebike_app.c works with OSEC parameter configurator. But I want the slightly higher configurability of the firmware configurator tool.

Can I use OSEC configurator and edit config.h then use the .bat file?

please post the output of the cmd window, so we can see what's going wrong.
As written several times before, you can use any texteditor to modify the config.h and just double click on start_compiling.bat to start the compiling and flashing process.
The java tool is not editig the existing config.h but overwrites it with the recent settings in the tool.
@casainho: are there new parameters in the config.h since the last update of the java-tool?

regards
stancecoke

Hey! Thanks for the quick reply! I edited the config file and got somewhere. Still having an issue..

Code:
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp143. Please contact sdcc authors with source code to reproduce.
sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-ihx --debug  -oebike_app.c ebike_app.c
ebike_app.c:179: warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp0. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp16. Please contact sdcc authors with source code to reproduce.
ebike_app.asm:390: Error: <a> machine specific addressing or addressing mode error
ebike_app.asm:427: Error: <a> machine specific addressing or addressing mode error
removing ebike_app.rel
make: *** [ebike_app.rel] Error 1


Doing the following in ebike_app.c lets me build though...

Code:
 //ebike_app_set_error (EBIKE_APP_ERROR_06_SHORT_CIRCUIT);


i.e. commenting that line...


P.S. I can keep giving you feedback and also help in dev once I get the toolchain down properly! Shall dual boot my system soon!
Which version of SDCC are you using? must be 3.7.0. If is different, why did you decide to use another version?
 
casainho said:
stancecoke said:
Sad to read, that you want to quit this project.... :(

I think there's no problem with the Java Tool, it makes the firmware usable for people who don't have computer skills like you or me :)

If there's a bug in the Java Tool, I can fix it easily. But for this we need the feedback of the users.
I think Basia is using your master. I don't know anyone who uses my fork...
Seems that more people want to use the firmware. I think would be good to have a good documentation and force users to read it before asking for help. Other way I think will be to much work and repetitive questions.
I think it would be more important to unify things. Not knowing the structure of the project and the different parts seems to be the main source of confusion. I know it's not my place to demand things, but it would definitely improve understanding among newbies.


Multiple forks, separate documentations, different branches, several ways to create configs (including outdated ones!)... I'm not surprised that people are confused.

Multiple forks: Yours and Stancecoke's. Ideally (really, ideally) you would merge them and have a #define to switch between different behaviors at compile time.

Separate documentations: Why is there this with almost no content, and this? Then the Windows instructions here which look completely different. Plus there's Stancecoke's German docs page. This should all be in one place, with different languages kept in sync as best as possible. A Wiki would be ideal, as it encourages others to contribute aswell and allows for corrections and improvements.

Different branches: They are necessary, I know that. Maybe add to the documentation how they differ from the main branch.

Config files: I understand the need to have a Windows tool for those not comfortable editing header files. But as we could see multiple times now, it needs to be kept in sync with features and changes at all times to be useful. Either that, or just force people to edit the header file. Which would be less comfortable, but better in the long run (with appropiate documentation)
 
Hmm, it would be interesting, which tutorial the recent users were following and where problems occured. If you follow this chapter for chapter, there should be no problem!

As written before: If there's a bug in the OSEC_Parameter_Configurator.jar , please report it, then I'll fix it.

But you are right, we should delete things, that are old and/or not working.

regards
stancecoke
 
1N4001 said:
casainho said:
stancecoke said:
Sad to read, that you want to quit this project.... :(

I think there's no problem with the Java Tool, it makes the firmware usable for people who don't have computer skills like you or me :)

If there's a bug in the Java Tool, I can fix it easily. But for this we need the feedback of the users.
I think Basia is using your master. I don't know anyone who uses my fork...
Seems that more people want to use the firmware. I think would be good to have a good documentation and force users to read it before asking for help. Other way I think will be to much work and repetitive questions.
I think it would be more important to unify things. Not knowing the structure of the project and the different parts seems to be the main source of confusion. I know it's not my place to demand things, but it would definitely improve understanding among newbies.


Multiple forks, separate documentations, different branches, several ways to create configs (including outdated ones!)... I'm not surprised that people are confused.

Multiple forks: Yours and Stancecoke's. Ideally (really, ideally) you would merge them and have a #define to switch between different behaviors at compile time.

Separate documentations: Why is there this with almost no content, and this? Then the Windows instructions here which look completely different. Plus there's Stancecoke's German docs page. This should all be in one place, with different languages kept in sync as best as possible. A Wiki would be ideal, as it encourages others to contribute aswell and allows for corrections and improvements.

Different branches: They are necessary, I know that. Maybe add to the documentation how they differ from the main branch.

Config files: I understand the need to have a Windows tool for those not comfortable editing header files. But as we could see multiple times now, it needs to be kept in sync with features and changes at all times to be useful. Either that, or just force people to edit the header file. Which would be less comfortable, but better in the long run (with appropiate documentation)
I agree in all the points!! Even on the wiki and maybe the best way is to use the github wikis.

But let's see if Stancecoke or others are able to help and improve on this.
 
apple2 said:
Guys, can you point me to the biggest controller that can run this? I want in!

72v 70A 24FET.

If you cant find it anywhere, this Is KT company dealer chn_1@163.com.

I dont know if they are still making them.
 
casainho said:
DarkDD said:
stancecoke said:
DarkDD said:
Commenting a line in ebike_app.c works with OSEC parameter configurator. But I want the slightly higher configurability of the firmware configurator tool.

Can I use OSEC configurator and edit config.h then use the .bat file?

please post the output of the cmd window, so we can see what's going wrong.
As written several times before, you can use any texteditor to modify the config.h and just double click on start_compiling.bat to start the compiling and flashing process.
The java tool is not editig the existing config.h but overwrites it with the recent settings in the tool.
@casainho: are there new parameters in the config.h since the last update of the java-tool?

regards
stancecoke

Hey! Thanks for the quick reply! I edited the config file and got somewhere. Still having an issue..

Code:
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp143. Please contact sdcc authors with source code to reproduce.
sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-ihx --debug  -oebike_app.c ebike_app.c
ebike_app.c:179: warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp44. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp32. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp0. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp16. Please contact sdcc authors with source code to reproduce.
ebike_app.asm:390: Error: <a> machine specific addressing or addressing mode error
ebike_app.asm:427: Error: <a> machine specific addressing or addressing mode error
removing ebike_app.rel
make: *** [ebike_app.rel] Error 1


Doing the following in ebike_app.c lets me build though...

Code:
 //ebike_app_set_error (EBIKE_APP_ERROR_06_SHORT_CIRCUIT);


i.e. commenting that line...


P.S. I can keep giving you feedback and also help in dev once I get the toolchain down properly! Shall dual boot my system soon!
Which version of SDCC are you using? must be 3.7.0. If is different, why did you decide to use another version?

Yes! you're right. I'm using SDCC 3.6.0. I can't seem to find a windows SDCC 3.7.0... And I don't know how to build it from sources :? :oops:

Also yeah FAQ would be good since all the confusion of the bitbucket pages, this incredibly large forum thread and all the branches!

You think you'd have the time to generate a few hex files if I gave you the config?
 
DarkDD said:
Yes! you're right. I'm using SDCC 3.6.0. I can't seem to find a windows SDCC 3.7.0...

Please read the tutorial, there you will find the link to the precompiled windows files and the instruction how to install them. SDCC 3.7.0 is only available for 64bit systems with windows.

regards
stancecoke
 
casainho said:
But let's see if Stancecoke or others are able to help and improve on this.

So we should clean up the github repository and focus on one tutorial.
My suggestion:
1. Delete all branches except the master and the feature/offroad 5 Step
2. Set all tutorial links (in our signatures and in the first post of this thread) to the windows instructions. I can add a link to the detailed developer area there.
3. Update the first post of this thread with a sceenshot of the recent release of the OSEC tool.

regards
stancecoke
 
stancecoke said:
I've commented out the print commands now, please try again. If this doesn't work, I can't do any more, as I have no LCD3...
But even if this works, the power cut at the speed limit is not implemented in casainhos code yet. So the offroad mode will only work with P3=0.

regards
stancecoke

That works ok now, I find I can trigger the code at virtually every attempt. I guess it's not a rhythm you're likely to hit by accident, but no big deal if you do in reality.
Unfortunately P3=0 isn't really an option for me, so this seems to be as far as this feature will go - a real shame as this could have been a nice feature fully implemented with legal speed, wattage and throttle limits being applied. Hopefully casainho may find time in the future to implement this, but I realise he's heavily involved with other projects just now.
 
stancecoke said:
casainho said:
But let's see if Stancecoke or others are able to help and improve on this.

So we should clean up the github repository and focus on one tutorial.
My suggestion:
1. Delete all branches except the master and the feature/offroad 5 Step
2. Set all tutorial links (in our signatures and in the first post of this thread) to the windows instructions. I can add a link to the detailed developer area there.
3. Update the first post of this thread with a sceenshot of the recent release of the OSEC tool.

May I suggest that instead of maintaining a java tool and editing a header file that the configuration go in a text file with a fairly common format, perhaps just key=value pairs or a .INI file format. Then have a script to generate config.h from the file as part of the build process. This would let us extract just the configurable items into something with simpler syntax than a .h file. The generator script could check for missing items or logical conflicts too and provide more user friendly error messages.
 
stancecoke said:
DarkDD said:
Yes! you're right. I'm using SDCC 3.6.0. I can't seem to find a windows SDCC 3.7.0...

Please read the tutorial, there you will find the link to the precompiled windows files and the instruction how to install them. SDCC 3.7.0 is only available for 64bit systems with windows.

regards
stancecoke


Ended up using a snapshot version of their executable. They have those till 3.7.1 and it compiled beautifully!

Fiddling around with the settings now trying to get the motor to turn! I'm using just a throttle... Its drawing current but can't seem to get it to turn and returns error 6... Trying to figure out! Any Ideas?
 
Back
Top