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

Electric Motors and Controllers
User avatar
stancecoke
1 kW
1 kW
Posts: 456
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 » Feb 06, 2018 2:35 pm

casainho wrote:
Feb 06, 2018 4:21 am
The Bluetooth version of S06S, because I hope to start play with it when the firmware is stable.
Great! Can you check the name of the BT-module that is shown in connect screen of the Kunteng app? Here a screenshot with the Lishui BT-module (that doesn't work with the Kunteng App of course)

Thanks
stancecoke

Screenshot_20180206-203246.png
Screenshot_20180206-203246.png (38.77 KiB) Viewed 305 times

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 06, 2018 3:12 pm

On My Android 7, it just shows sometimes a device (LanQianTech) and also on Linux I saw just for some seconds a device, sometimes, when I reset the S06S:
Image

Trying on the Kunteng app, it does show another Bluetooth device but did never show the correct device.
And on Android, after clicked on the device, it seams to paired it however I never saw the LED of the module turned on.
I tested on 2 different S06S-BT controller and exchanging 3 different Bluetooth modules I have (1 extra from an old S06S-BT controller I bought before).
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 456
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 » Feb 06, 2018 3:28 pm

Does this mean, that you can't connect the app with the module?

The connection works for me, the Bluetooth Symbol is highlighted in blue colour in the upper right corner of the home screen. But there must be a handshake protocol, as the app sends "0x57" to the module in recent time intervals. If I send bytes from the module to the smartphone, they are received, but not processed.
Example from the log-file analysis by wireshark (btsnoop_hci.log created by the sniffing function in the developer tools of android):

Code: Select all

host	controller	HCI_CMD	7	Sent Unknown 0xfd57
If you could log the communication when connecting the app with the module successfully, we could analyze, what's the right answer for the handshake...

regards
stancecoke
Attachments
Screenshot_20180206-212955.png
Screenshot_20180206-212955.png (92.61 KiB) Viewed 295 times

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 06, 2018 5:42 pm

So finally I found a way to get it connecting very well, for that I had to increase the controller input voltage to at least 29V!! So I would say this Bluetooth modules only work for 36V input voltage even if they are connected to a S06S that says "24V/36V". I tested this controller and it works well with the LCD5 down to 20.5V input voltage (when the battery symbol is empty on LCD5).

Also without LCD5 connected, the Bluetooth module works -- I will later test if the controller can run the motor only with the Bluetooth module.
The Bluetooth module works even if the LCD5 is connected and working.
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 456
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 » Feb 07, 2018 4:27 am

Fine to hear, that it's working! Can you log the communication on your smartphone and upload the logfile, please? This would be great!!
Where are the blue, green and the yellow wires connected on the PCB of the controller?
Image

regards
stancecoke

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 07, 2018 4:48 am

stancecoke wrote:
Feb 07, 2018 4:27 am
Fine to hear, that it's working! Can you log the communication on your smartphone and upload the logfile, please? This would be great!!
Sorry but this is not my priority -- but I will be back to this later. Also, I would prefer to work for an app to work for our OpenSource firmware so I would not mind about their app, etc. I would instead look at maybe Arduino Android OpenSource code projects using this type of module and try to communicate with it and send/receive data to/from our firmware.
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 07, 2018 6:33 am

Looking at the way I apply PI controller, it is different from Stancecoke:
- me:

Code: Select all

pwm_set_duty_cycle_target (actual_duty_cycle_target + PI_out_value);
- Stancecoke:

Code: Select all

pwm_set_duty_cycle (PI_out_value);
Yes we are limiting to avoid negative values, as PWM can't take negative values. I got someone making the same question on Arduino forum and a very good answer -- also the results we can get with 3 different options, and yes, Stancecoke option should be the best but even like that, seems far from ideal since with negative errors on PI controller, the pwm will be immediately set to zero.

Since I am using duty_cycle_target instead, it adds a delay to increase/decrease the duty_cycle value, so maybe doing like Stancecoke + using duty_cycle_target will be a good solution.
The output of the PID is a signed value that should be passed to a routine that can drive
the motor either direction according to the sign. (...) You must have fast-decay mode (synchronous rectification) on
the H-bridge for servo drive like this, otherwise the system is highly non-linear as a whole.
But the best one may even be using the synchronous rectification PWM (as mentioned on that forum message) that we are using on our firmware, unlike the original firmware -- but that would be a big change on how the motor control works, so I think it can be explored in future.
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 456
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 » Feb 07, 2018 10:12 am

casainho wrote:
Feb 07, 2018 6:33 am
Stancecoke option should be the best but even like that, seems far from ideal since with negative errors on PI controller, the pwm will be immediately set to zero.
??? I don't understand your argumentation... The output (= duty cycle) is the sum of the proportional part and the integral part. The duty cycle will be dominated by the integral part most time, as the proportional part will be near zero most time. So a negativ error will of course reduce the duty cycle (that's the sense of the control loop) but will not set it to zero immediately....

You are using actual_duty_cycle_target as a kind of "integral" part, but I'm fearing you haven't yet understood the working principle of a pi controller. :-(

regards
stancecoke
Last edited by stancecoke on Feb 07, 2018 11:39 am, edited 1 time in total.

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 07, 2018 11:37 am

stancecoke wrote:
Feb 07, 2018 10:12 am
??? I don't understand your argumentation... The output (= duty cycle) is the sum of the proportional part and the integral part. The duty cycle will be dominated by the integral part most time, as the proportional part will be near zero most time. So a negativ error will of course reduce the duty cycle (that's the sense of the control loop) but will not set it to zero immiately....

You are using actual_duty_cycle_target as a kind of "integral" part, but I'm fearing you haven't yet understood the working principle of a pi controller. :-(
Well, I hope to understand better now -- and yes, I was wrong. I just did like that, like you do but I am setup the duty_cycle_target instead. I tested both PI controllers for current and speed and I even went to test the P and I coefficients until I got the controllers running well. And I looked at duty_cycle_target after PI output values and yes, it does not goes to 0 value but keeps almost constant.
I got the current controller working well. The speed controller to work well, without oscillating to much (without load), needed to have lower PI coefficients and was to slow for my taste... but with load on the wheel, works very well and kind of fast response.

The PI coefficients can be changed, if needed, on main.h:

Code: Select all

#define MOTOR_CURRENT_PI_CONTROLLER_KP_DIVIDEND	10
#define MOTOR_CURRENT_PI_CONTROLLER_KP_DIVISOR	1
#define MOTOR_CURRENT_PI_CONTROLLER_KI_DIVIDEND	4
#define MOTOR_CURRENT_PI_CONTROLLER_KI_DIVISOR	1

#define WHEEL_SPEED_PI_CONTROLLER_KP_DIVIDEND	35
#define WHEEL_SPEED_PI_CONTROLLER_KP_DIVISOR	3
#define WHEEL_SPEED_PI_CONTROLLER_KI_DIVIDEND	25
#define WHEEL_SPEED_PI_CONTROLLER_KI_DIVISOR	5

I also moved some code to ebike_app.c, like the state machine that looks for motor being stuck.
Also now the speed controller controls the wheel speed and not the motor speed as before.
I tested the changes on my direct driver motor Q85, S06S, 24V battery. The code is on master branch.
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 456
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 » Feb 07, 2018 12:05 pm

I took a closer look to your PI-controller code now. There are two questions:
1. Why do you set the integral part to zero immediately, if the target is zero? This will cause massive regen on a direct drive and even with a freewheeled motor this will cause high inertia forces on the rotor.

2. Why do you allow negative values for the integral part? This makes no sense as the duty cycle can't be negative, as you've already written above?

Code: Select all

void pi_controller (struct_pi_controller_state *pi_controller)
{
  static int16_t i16_error;
  static int16_t i16_p_term;

  i16_error = pi_controller->ui8_target_value - pi_controller->ui8_current_value; // 255-0 or 0-255 --> [-255 ; 255]
  i16_p_term = (i16_error * pi_controller->ui8_kp_dividend) >> pi_controller->ui8_kp_divisor;

  // reset integral term while target value = 0
  if (pi_controller->ui8_target_value == 0) { pi_controller->i16_i_term = 0; }
  pi_controller->i16_i_term += (i16_error * pi_controller->ui8_ki_dividend) >> pi_controller->ui8_ki_divisor;
  if (pi_controller->i16_i_term > 255) { pi_controller->i16_i_term = 255; }
  if (pi_controller->i16_i_term < -254) { pi_controller->i16_i_term = -254; }

  pi_controller->i16_controller_output_value = i16_p_term + pi_controller->i16_i_term;
  if (pi_controller->i16_controller_output_value > 255) { pi_controller->i16_controller_output_value = 255; }
  if (pi_controller->i16_controller_output_value < -254) { pi_controller->i16_controller_output_value = -254; }
}
regards
stancecoke

geofft
100 W
100 W
Posts: 118
Joined: Nov 09, 2012 9:41 am
Location: Berkshire UK

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

Post by geofft » Feb 08, 2018 4:52 am

Just a minor point I'd thought I'd bring to the attention of you guys - throughout the main branch code there are several misspellings of the word 'throttle' with 'throotle'. A windows search finds instances of this in the following files:-

ebike_app.lst
ebike_app.asm
main.h
ebike_app.c
config-example.h
Configuration_tool.java

....what I don't know is if any of these occurences affect the way in which the code runs. Some are just in comment lines but others seem to occur in definition type statements which may be important - I don't know.
Probably all of no importance, but maybe worth you guys checking just to be sure.. :wink:
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR 20amp, LCD3, 48v 12s lipo.

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 08, 2018 7:02 am

geofft wrote:
Feb 08, 2018 4:52 am
Just a minor point I'd thought I'd bring to the attention of you guys - throughout the main branch code there are several misspellings of the word 'throttle' with 'throotle'.
Done. Thanks.
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 08, 2018 8:39 am

stancecoke wrote:
Feb 07, 2018 12:05 pm
I took a closer look to your PI-controller code now. There are two questions:
1. Why do you set the integral part to zero immediately, if the target is zero? This will cause massive regen on a direct drive and even with a freewheeled motor this will cause high inertia forces on the rotor.

2. Why do you allow negative values for the integral part? This makes no sense as the duty cycle can't be negative, as you've already written above?
1. because I saw one time a problem with start up and I wanted to reset PI controller. Don't cause massive/max defined regen current because I am setting duty_cycle_target and not duty_cycle.
That "controller" of duty_cycle_target adds delay, I may rethink that because the idea is a protection to avoid to fast increase/decrease of duty_cycle. Maybe the algorithm can impose limitations only if the rate is over max possible value....
I changed the PI controller per you suggestion and seems to work well.

2. I wanted the PI controller to be more generic and I was limiting after the output value. Again, I just changed as your suggestion and simplified the code, as we may never need that more generic PI controller.
geofft wrote:
Feb 08, 2018 4:52 am
ebike_app.lst
ebike_app.asm
Just a note that these are temporary files and are not important, should be replaced when you build again the firmware.
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

honya96
100 W
100 W
Posts: 191
Joined: Mar 05, 2015 9:38 am
Location: Czech Republic

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

Post by honya96 » Feb 08, 2018 4:23 pm

Just an interesting find - adaptto controller has MSP430F248T processor (16Mhz, 48kb, 4kb ram) so its not "much better"?!

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 08, 2018 4:37 pm

honya96 wrote:
Feb 08, 2018 4:23 pm
Just an interesting find - adaptto controller has MSP430F248T processor (16Mhz, 48kb, 4kb ram) so its not "much better"?!
Good to know. If you have a link for pictures and other tecnhical details, would be great if you share.
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

honya96
100 W
100 W
Posts: 191
Joined: Mar 05, 2015 9:38 am
Location: Czech Republic

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

Post by honya96 » Feb 09, 2018 6:03 am

Search for: Adaptto controller teardown.

If you want to see any specific photo, I can take.

From technical details, interesting is that it can work as a boost converter and charge over 84V with just 24V supply. Voltage and current is set on display.

Supply is connected through big external inductor and capacitors to "+" of the controller/battery and any phase wire (with motor connected) noise can be heard from motor while charging so its also using its inductance?

And my personal overall opinion on the controller - not worth the money.

If enough developers interested, we can do all this with cheap kunteng.

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 09, 2018 6:36 am

Added pictures from internals of LCD5: https://opensourceebikefirmware.bitbuck ... panel.html

Added notes about the original mobile app: https://opensourceebikefirmware.bitbuck ... e_app.html

Image

Image
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 456
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 » Feb 09, 2018 10:40 am

casainho wrote:
Feb 09, 2018 6:36 am
Added notes about the original mobile app
Hmm, so it seems, that the bluetooth system is really poor.... I think we can do it much better. But we need to know, where the wires from the BT-Module are connected to on the controller PCB :wink:

regards
stancecoke

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 09, 2018 11:10 am

stancecoke wrote:
Feb 09, 2018 10:40 am
Hmm, so it seems, that the bluetooth system is really poor.... I think we can do it much better. But we need to know, where the wires from the BT-Module are connected to on the controller PCB :wink:
This is not a priority for me. Maybe someone else will but the bluetooth controller version and want to help.
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 10, 2018 9:42 am

Stancecoke, I am thinking how to improve the torque sensor code -- do you have suggestions?

The main issues is that value fluctuates a lot every cadence... I would like to detect a good value from start..
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 456
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 » Feb 10, 2018 11:30 am

casainho wrote:
Feb 10, 2018 9:42 am
Stancecoke, I am thinking how to improve the torque sensor code -- do you have suggestions?
The main issues is that value fluctuates a lot every cadence... I would like to detect a good value from start..
The torque-signal is a kind of sinusoidal whithin one crank revolution, that's physics. So I suggest to combine your and my solutions in the way, the "Forumscontroller" does it.

Code: Select all

#if CONTROL_MODE == CONTROL_MODE_TORQUE                      //human power control mode
#if defined(SUPPORT_XCELL_RT) || defined(SUPPORT_SEMPU_V1) || defined(SUPPORT_SEMPU)
    power_poti = poti_stat/102300.0* curr_power_poti_max*power_human*(1+spd/20.0); //power_poti_max is in this control mode interpreted as percentage. Example: power_poti_max=200 means; motor power = 200% of human power
#ifdef SUPPORT_TORQUE_THROTTLE                              //we want to trigger throttle just by pedal torque
    if (abs(torque_instant)>torque_throttle_min)            //we are above the threshold to trigger throttle
    {
      double power_torque_throttle = abs(torque_instant/torque_throttle_full*poti_stat/1023*curr_power_max);  //translate torque_throttle_full to maximum power
      power_throttle = max(power_throttle,power_torque_throttle); //decide if thumb throttle or torque throttle are higher
      power_throttle = constrain(power_throttle,0,curr_power_max); //constrain throttle value to maximum power 
    }
#endif

....

power_poti = min(power_poti,thermal_limit+(curr_power_max-thermal_limit)*constrain(spd/thermal_safe_speed,0,1)); //thermal limiting

    if ((power_throttle) > (power_poti))                     //IF power set by throttle IS GREATER THAN power set by poti (throttle override)
    {
        myPID.SetTunings(pid_p_throttle,pid_i_throttle,0);   //THEN throttle mode: throttle sets power with "agressive" p and i parameters        power_set=throttle_stat/1023.0*power_max;
        power_set = power_throttle;
    }
    else                                                     //ELSE poti mode: poti sets power with "soft" p and i parameters
    {
        myPID.SetTunings(pid_p,pid_i,0);
        power_set = power_poti;
}
Read the throttle value, the direct torque-signal and the human power (human power averaged over one, or at least a half crank revolution) and give the highest value to the motor. With this, the support will start from zero speed, it will oszillate at startup, but it will be smooth from the point, where the human power value is higher than the simple torque value, the thumb throttle as highest priority and overrides the other values...

regards
stancecoke

nieles
10 kW
10 kW
Posts: 631
Joined: Jul 14, 2008 5:39 pm
Location: The Netherlands

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

Post by nieles » Feb 10, 2018 1:05 pm

hi guys,

finally got my st-link dongle in the mail. so i can start playing with this project.

i got my controller reprogrammed and motor sort of running (cuts out a a certain speed)

but i got a weird problem. i can't program the controller without doing something "weird" with the java tool. once the make clean commando is run (in the cmd window) i have to issue around 10 "exit" commando's for it to proceed with the make and prog.

second problem; when i started with this this afternoon, my lcd was working. later in the day it stopped updating for some reason. i was changing all kinds of things when i noticed, so can't say for certain what caused this. could it be software? i remember i went in to the settings on the display around the time it stopped updating. (i checked C11, LCD protocol. its on 0)

i am using the master branch.

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 10, 2018 3:35 pm

nieles wrote:
Feb 10, 2018 1:05 pm
hi guys,

finally got my st-link dongle in the mail. so i can start playing with this project.

i got my controller reprogrammed and motor sort of running (cuts out a a certain speed)

but i got a weird problem. i can't program the controller without doing something "weird" with the java tool. once the make clean commando is run (in the cmd window) i have to issue around 10 "exit" commando's for it to proceed with the make and prog.

second problem; when i started with this this afternoon, my lcd was working. later in the day it stopped updating for some reason. i was changing all kinds of things when i noticed, so can't say for certain what caused this. could it be software? i remember i went in to the settings on the display around the time it stopped updating. (i checked C11, LCD protocol. its on 0)

i am using the master branch.
Great!!

Sorry, can't help with 1. issue - maybe Stancecoke. But I think you need to post screenshots / more details.

About 2., I really don't know. Again, at least put some pictures and details about your LCD model.
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

nieles
10 kW
10 kW
Posts: 631
Joined: Jul 14, 2008 5:39 pm
Location: The Netherlands

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

Post by nieles » Feb 10, 2018 7:22 pm

hi,

about point 1: i narrowed it down to a part of the make file. i put some debug statements in the makefile (the clean part)
Makefile (clean part only)

Code: Select all

ENTF = cmd /C del

clean:
	@echo "Cleaning files..."
	@clean.bat
	@echo "dbg1"
	@$(ENTF) *.asm 
	@echo "dbg2"
	@$(ENTF) *.rel
	@$(ENTF) *.lk
	@$(ENTF) *.lst
	@$(ENTF) *.rst
	@$(ENTF) *.sym
	@$(ENTF) *.cdb
	@$(ENTF) *.map
	@$(ENTF) *.elf
	@$(ENTF) *.adb 
	@echo "Done."
this is the output on the terminal:

Code: Select all

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT>make clean -f Makefile_windows --debug
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-pc-mingw32
Reading makefiles...
Updating goal targets....
 File `clean' does not exist.
Must remake target `clean'.
Cleaning files...

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT>cd stdperiphlib\src

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>del *.asm
Could Not Find C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src\*.asm

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>del *.rel
Could Not Find C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src\*.rel

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>del *.lk
Could Not Find C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src\*.lk

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>del *.lst
Could Not Find C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src\*.lst

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>del *.rst
Could Not Find C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src\*.rst

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>del *.sym
Could Not Find C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src\*.sym

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>del *.cdb
Could Not Find C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src\*.cdb

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>del *.map
Could Not Find C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src\*.map

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>del *.elf
Could Not Find C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src\*.elf

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>del *.bin
Could Not Find C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src\*.bin

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib\src>cd..

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT\StdPeriphLib>cd..
dbg1
Microsoft Windows [Version 10.0.16299.192]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT>exit
dbg2
Microsoft Windows [Version 10.0.16299.192]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\Niels\Documents\GitHub\BMSBattery_S_controllers_firmware-ALT>
note that i needed to do the "exit" to get "dbg2".

EDIT: found the issue.. for some reason it was using sh.exe instead of cmd.exe (according to google) i solved this by removing MinGW and WINAVR paths from my Environment variables.
This issue has been discussed in another thread. In short: There is not
a "real" bug in the makefile. It's more a problem of the make utility.
In the makefile there are just some commands which depend on the Windows
"shell". So the needed shell is cmd.exe (MS Windows) not sh.exe
("unix-shell"-compatible). If the mingw-make version (as in WinARM 6/06)
finds a sh.exe it uses it and seems to ignore the SHELL variable. sh.exe
can not handle some of the commands in the makefile. If sh.exe is not
found it falls back to the cmd.exe and everything works as expected.
That's why I suggest to rename sh.exe so make does not find it and uses
cmd.exe instead. This is just a workaround to get things going without
addtional downloads. Better solutions:
- use a make.exe based on the 3.81 sources
- rewrite the makefiles to avoid MS-Windows specific commands

I will modify the makefiles to be "sh.exe"-compatible as soon as I have
some time. So the code can be build with older version of make and on
non-MS-Windows-hosts without modifications. Contributions of modified
makefiles are very welcome.

Martin Thomas
about issue 2:
i have the S-LCD3. just checked with a different controller(S06P) and the display is working.
Last edited by nieles on Feb 10, 2018 7:52 pm, edited 1 time in total.

casainho
100 kW
100 kW
Posts: 1226
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 » Feb 10, 2018 7:47 pm

You are doing incorrect for clean, should be this:

Code: Select all

make -f Makefile_windows clean
And to build the code:

Code: Select all

make -f Makefile_windows
Developer of the Flexible OpenSource firmware for EBike motor controllers: https://opensourceebikefirmware.bitbucket.io/

Post Reply