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

Electric Motors and Controllers
User avatar
stancecoke
10 kW
10 kW
Posts: 552
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 03, 2018 1:28 pm

casainho wrote:
Apr 03, 2018 4:16 am
Please update your master branch as I just update it with my most recent code.
The recent master branch throws an error while compiling with windows. :(

Code: Select all

ebike_app.asm:366: Error: <a> machine specific addressing or addressing mode error
ebike_app.asm:403: Error: <a> machine specific addressing or addressing mode error
Can you fix that? Otherwise I have to start from an earlier commit...

regards
stancecoke

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 03, 2018 1:38 pm

I will try to compile on Linux to see. Also you can try most recent version of SDCC that I think is version 3.7.
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2


casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 03, 2018 5:38 pm

stancecoke wrote:
Apr 03, 2018 1:53 pm
the latest precompiled windows version is 3.6.0 from 2016
https://sourceforge.net/projects/sdcc/files/
From version 2018-03-04 sdcc and openocd for stm8 does no longer have to be patched. Sdcc has built in support for gdb (dwarf2 debug format) and openocd support debugging of stm8 micros.
https://stm8-binutils-gdb.sourceforge.io
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

User avatar
stancecoke
10 kW
10 kW
Posts: 552
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 04, 2018 12:11 am

Those windows binaries from your link need cygwin :shock: .
Have you ever worked with cygwin?! Please write an easy to understand tutorial how to make this version of SDCC running with windows.... It took me hours to make it work (for 3.6.0) and I think a "normal" Windows user will despair on it. A 32 bit windows version of 3.7.0 is not available at all :(

I strongly recommend to stay at revision 3.6.0 until a "one-click windows-installer" of revision 3.7.0 is available.

regards
stancecoke

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 04, 2018 2:56 am

stancecoke wrote:
Apr 03, 2018 1:28 pm
casainho wrote:
Apr 03, 2018 4:16 am
Please update your master branch as I just update it with my most recent code.
The recent master branch throws an error while compiling with windows. :(

Code: Select all

ebike_app.asm:366: Error: <a> machine specific addressing or addressing mode error
ebike_app.asm:403: Error: <a> machine specific addressing or addressing mode error
Can you fix that? Otherwise I have to start from an earlier commit...
Can you please verify again? maybe from a clean checkout?
Please look and compare with my sdcc version, a make clean and make:

Code: Select all

cas@ubuntu:~/OpenSource-EBike-firmware/BMSBattery_S_controllers_firmware/firmware$ sdcc --version
SDCC : stm8 3.6.0 #9615 (Linux)
published under GNU General Public License (GPL)
cas@ubuntu:~/OpenSource-EBike-firmware/BMSBattery_S_controllers_firmware/firmware$ make -f Makefile_linux clean
Cleaning files...
Done.
cas@ubuntu:~/OpenSource-EBike-firmware/BMSBattery_S_controllers_firmware/firmware$ make -f Makefile_linux
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oStdPeriphLib/src/stm8s_itc.c StdPeriphLib/src/stm8s_itc.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oStdPeriphLib/src/stm8s_clk.c StdPeriphLib/src/stm8s_clk.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oStdPeriphLib/src/stm8s_iwdg.c StdPeriphLib/src/stm8s_iwdg.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oStdPeriphLib/src/stm8s_gpio.c StdPeriphLib/src/stm8s_gpio.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oStdPeriphLib/src/stm8s_exti.c StdPeriphLib/src/stm8s_exti.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oStdPeriphLib/src/stm8s_uart2.c StdPeriphLib/src/stm8s_uart2.c
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp4. Please contact sdcc authors with source code to reproduce.
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oStdPeriphLib/src/stm8s_tim1.c StdPeriphLib/src/stm8s_tim1.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oStdPeriphLib/src/stm8s_tim2.c StdPeriphLib/src/stm8s_tim2.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oStdPeriphLib/src/stm8s_adc1.c StdPeriphLib/src/stm8s_adc1.c
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:iTemp0. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp1. 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:iTemp0. Please contact sdcc authors with source code to reproduce.
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp1. Please contact sdcc authors with source code to reproduce.
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oStdPeriphLib/src/stm8s_flash.c StdPeriphLib/src/stm8s_flash.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -owatchdog.c watchdog.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -ogpio.c gpio.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -outils.c utils.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -ouart.c uart.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oadc.c adc.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -obrake.c brake.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -opas.c pas.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -owheel_speed_sensor.c wheel_speed_sensor.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -otimers.c timers.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -opwm.c pwm.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oeeprom.c eeprom.c
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -omotor.c motor.c
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp146. Please contact sdcc authors with source code to reproduce.
/home/cas/software/stm8-binutils/bin/sdcc -c -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  -oebike_app.c ebike_app.c
ebike_app.c:165: 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:iTemp7. Please contact sdcc authors with source code to reproduce.
/home/cas/software/stm8-binutils/bin/sdcc -IStdPeriphLib/inc -I.  -mstm8 -Ddouble=float --std-c99 --nolospre --out-fmt-elf --debug  main.c StdPeriphLib/src/stm8s_itc.rel StdPeriphLib/src/stm8s_clk.rel StdPeriphLib/src/stm8s_iwdg.rel StdPeriphLib/src/stm8s_gpio.rel StdPeriphLib/src/stm8s_exti.rel StdPeriphLib/src/stm8s_uart2.rel StdPeriphLib/src/stm8s_tim1.rel StdPeriphLib/src/stm8s_tim2.rel StdPeriphLib/src/stm8s_adc1.rel StdPeriphLib/src/stm8s_flash.rel watchdog.rel gpio.rel utils.rel uart.rel adc.rel brake.rel pas.rel wheel_speed_sensor.rel timers.rel pwm.rel eeprom.rel motor.rel ebike_app.rel
main.c:131: warning 126: unreachable code
stm8-size main.elf -A
main.elf  :
section             size    addr
DATA                 107       1
INITIALIZED          335     108
SSEG                   3     443
HOME                 131   32768
GSINIT                30   32899
GSFINAL                3   32929
CODE               25136   32932
INITIALIZER          335   58068
.debug_line        26719       0
.debug_loc          6600       0
.debug_abbrev       2681       0
.debug_info        31291       0
.debug_pubnames    11646       0
.debug_frame         432       0
Total             105449


stm8-objcopy -O binary -R DATA -R INITIALIZED -R SSEG -R .debug_line -R .debug_loc -R .debug_abbrev -R .debug_info -R .debug_pubnames -R .debug_frame main.elf main.bin
cas@ubuntu:~/OpenSource-EBike-firmware/BMSBattery_S_controllers_firmware/firmware$ 
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

User avatar
stancecoke
10 kW
10 kW
Posts: 552
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 04, 2018 3:07 am

casainho wrote:
Apr 04, 2018 2:56 am
Can you please verify again? maybe from a clean checkout?
Please look and compare with my sdcc version, a make clean and make:
Still the same :-(

Code: Select all

C:\Users\admin>sdcc -v
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/h
c08/s08/stm8 3.6.0 #9615 (MINGW64)
published under GNU General Public License (GPL)

Code: Select all

ebike_app.asm:366: Error: <a> machine specific addressing or addressing mode error
ebike_app.asm:403: Error: <a> machine specific addressing or addressing mode error
regards
stancecoke

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 04, 2018 3:13 am

So, since we are both using the same compiler version that we want strategically use, I suggest for you to go commit over commit backwards and try build. When we find the commit the gives problems, I can try look at the code -- I know for instance, that I can't do:

Code: Select all

void function_name (void)
{
  static uint8_t var_name = 0;
}
The compiler fails with static variables that has an initial value... and that makes the current code to has a lot of local variables :-( -- even still fails with SDCC 3.7.0...
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 04, 2018 3:18 am

Or maybe you can try this most recent exe windows version: https://sourceforge.net/projects/sdcc/f ... w32-setup/
- here also: https://qa.debian.org/watch/sf.php/sdcc
If they work for you, I can build for me on Linux. Also, if for some reason you decide to build version 3.7.0, we can them share the exe files on our project page, I think it will work.
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

User avatar
stancecoke
10 kW
10 kW
Posts: 552
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 04, 2018 6:39 am

the latest commit that compiles is the "WIP" from 7 days ago. All newer commits throw that error.

I think the problem is caused by the "Motor cool" switch in the ebike_app_state_machine function. If I comment this out, the compiling works.

regards
stancecoke

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 04, 2018 12:42 pm

stancecoke wrote:
Apr 04, 2018 6:39 am
the latest commit that compiles is the "WIP" from 7 days ago. All newer commits throw that error.

I think the problem is caused by the "Motor cool" switch in the ebike_app_state_machine function. If I comment this out, the compiling works.
I just see regular and simple code on that commits. Also ebike_app_state_machine wasn't changed on that commits...
Some ideas:
- please make sure your Makefile has the some options for the compiler
- I can't replicate this issue so for me is very hard...
- maybe we are out of RAM memory??
- move to SDCC 3.7 and you build it and then we share the executable for others
- find SDCC 3.7 executable from someone...

I rode today my Q85 geared motor, torque sensor, 24V battery, with current master branch code and it works well, smooth.
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

User avatar
stancecoke
10 kW
10 kW
Posts: 552
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 04, 2018 1:19 pm

casainho wrote:
Apr 04, 2018 12:42 pm
- maybe we are out of RAM memory??
I think, that's the point. With commenting out some lines, even some certain single line, e.g. line 189

Code: Select all

//ebike_app_set_error (EBIKE_APP_ERROR_06_SHORT_CIRCUIT);
it works.

So I think we have to use some optimizing compiler settings or rework the code and throw away unnecessary things...

But I will stop at this point, as I'm not that familiar with the code in the master branch.

I had a look to the linux/windows makefiles, the compiling options are the same except the -elf vs. -ihx option, but i get the same error with the -elf option. Deleting the --debug option doesn't help also.

regards
stancecoke

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 04, 2018 1:27 pm

stancecoke wrote:
Apr 04, 2018 1:19 pm
casainho wrote:
Apr 04, 2018 12:42 pm
- maybe we are out of RAM memory??
I think, that's the point. With commenting out some lines, even some certain single line, e.g. line 189

Code: Select all

//ebike_app_set_error (EBIKE_APP_ERROR_06_SHORT_CIRCUIT);
it works.

So I think we have to use some optimizing compiler settings or rework the code and throw away unnecessary things...

But I will stop at this point, as I'm not that familiar with the code in the master branch.

I had a look to the linux/windows makefiles, the compiling options are the same except the -elf vs. -ihx option, but i get the same error with the -elf option. Deleting the --debug option doesn't help also.
I must say I don't know how to see ram usage, I already tried but I didn't figured out. Also, strange that you are getting this issue but not me...

I need to know how to clear see ram usage, so we know when we need to reduce the features. I think I will try SDCC 3.7.0 and see if I can get ram usage, initialization of static variables inside functions. This will take time. I am sorry we can't follow together as I think most of the firmware runs very well and with advantages over original one. And this project will make 1 year on day 25 of this month April.
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

royco
10 µW
10 µW
Posts: 5
Joined: Mar 26, 2018 12:31 am

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

Post by royco » Apr 04, 2018 5:21 pm

Has anybody successfully used the firmware compatible controllers on RC outrunner sensorless motors commonly seen on friction drives? Or maybe on sensored versions of the motor?

Quick searches seem to point to high rpms of these motors being a problem for ebike controllers, is this something that the firmware can overcome?

1N4001
10 mW
10 mW
Posts: 22
Joined: Nov 28, 2017 7:55 am

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

Post by 1N4001 » Apr 05, 2018 2:30 am

A small hint, when you want to find the commit that broke something, you can use git bisect. This way you don't have to test every single commit, only log2(commits)

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 05, 2018 4:02 am

royco wrote:
Apr 04, 2018 5:21 pm
Has anybody successfully used the firmware compatible controllers on RC outrunner sensorless motors commonly seen on friction drives? Or maybe on sensored versions of the motor?

Quick searches seem to point to high rpms of these motors being a problem for ebike controllers, is this something that the firmware can overcome?
Must say I never owned an RC motor or controller, I don't know nothing about that world. But someone told me that yes, they run at very high rpms and because of that they only implement 6 steps/block commutation and not sinewave/FOC like motors of ebikes and motor cycles.
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 05, 2018 4:17 am

stancecoke wrote:
Apr 04, 2018 1:19 pm
casainho wrote:
Apr 04, 2018 12:42 pm
- maybe we are out of RAM memory??
I think, that's the point. With commenting out some lines, even some certain single line, e.g. line 189

Code: Select all

//ebike_app_set_error (EBIKE_APP_ERROR_06_SHORT_CIRCUIT);
it works.
Maybe not RAM yet, because STM8S105C6T6 has:
- flash: 32kbytes
- RAM: 2kbytes
- EEPROM: 1kbytes

For what I found about SDCC, memory usage can be found on generated map file and RAM are DATA + INITIALIZED sections, and they start at 0 address and goes up to 0x1ba (on my compiled firmware), which is 436 bytes, so we are far from the 2048 bytes limit. Also I think there is other dynamic RAM usage that is stack and it should use RAM as needed when we call functions and I think compiler can't verify that usage because it is dynamic... but again, I think we are far from the 2048 limit.

Stancecoke, can you please verify on your compiled firmware? just to validate my analysis.
Last edited by casainho on Apr 05, 2018 4:20 am, edited 1 time in total.
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 05, 2018 4:18 am

1N4001 wrote:
Apr 05, 2018 2:30 am
A small hint, when you want to find the commit that broke something, you can use git bisect. This way you don't have to test every single commit, only log2(commits)
Didn't know about that. Thanks!!
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

User avatar
stancecoke
10 kW
10 kW
Posts: 552
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 05, 2018 7:30 am

casainho wrote:
Apr 05, 2018 4:17 am
Stancecoke, can you please verify on your compiled firmware? just to validate my analysis.
I don't know how to do that analysis. I have attached two Hex- and Map-files (Master WIP commit and High Speed Motors fork), perhaps you can analyse them.

regards
stancecoke
Attachments
Hexfiles.zip
(151.04 KiB) Downloaded 7 times

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 05, 2018 3:46 pm

You need to look at main.map file. Will be easier for you to understand.
Sorry I am at home
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 06, 2018 3:41 am

Here is my main.map file:

Image
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 06, 2018 3:46 am

stancecoke wrote:
Apr 05, 2018 7:30 am
casainho wrote:
Apr 05, 2018 4:17 am
Stancecoke, can you please verify on your compiled firmware? just to validate my analysis.
I don't know how to do that analysis. I have attached two Hex- and Map-files (Master WIP commit and High Speed Motors fork), perhaps you can analyse them.
So I looked at the map files of your zip file:
Master: 0x1c7 | 455 bytes
HighSpeedMotor: 0x1fb | 507 bytes

So, master even uses less RAM than HighSpeedMotor. So, the issue should not be because of RAM limitations.
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

User avatar
stancecoke
10 kW
10 kW
Posts: 552
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 06, 2018 3:59 am

casainho wrote:
Apr 06, 2018 3:46 am
So, the issue should not be because of RAM limitations.
Hm, I played around a little how to avoid the error, but I couldn't find a clue. :-(

regards
stancecoke

casainho
100 kW
100 kW
Posts: 1453
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 06, 2018 4:03 am

stancecoke wrote:
Apr 06, 2018 3:59 am
casainho wrote:
Apr 06, 2018 3:46 am
So, the issue should not be because of RAM limitations.
Hm, I played around a little how to avoid the error, but I couldn't find a clue. :-(
When I build, I get some warning that compiler gives, but something for compiler developers. Sometimes I think I have luck that the code works... :-)
What I mean is that we should use most recent version, I think should be the best. I need to try SDCC 3.7.0. Can't you try a recent version to see if the issue disappears?
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

User avatar
stancecoke
10 kW
10 kW
Posts: 552
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 06, 2018 4:23 am

casainho wrote:
Apr 06, 2018 4:03 am
Can't you try a recent version to see if the issue disappears?
Sorry, I don't want to waste hours struggeling with cygwin again :shock:

A workaround is to comment out line 189 of the ebike_app.c, then it works, why ever and I can try to improve the PAS-processing

Code: Select all

//ebike_app_set_error (EBIKE_APP_ERROR_06_SHORT_CIRCUIT);
regards
stancecoke

Post Reply