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

Electric Motors and Controllers
Post Reply
casainho
10 kW
10 kW
Posts: 953
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 25, 2017 8:37 pm

Image

This OpenSource firmware/embedded software runs on the BMSBattery S/Kunteng KT motor controllers.
The main advantages of this controllers are:
1. sine wave/"FOC": motors run silent and very efficient
2. cheap: starting at 20€
3. widely available: many online shops sell them and ship to worldwide
4. various sizes e powers: from 0.25kW up to 5kW (72V, 70A, 24 mosfets)
5. supports LCD and Bluetooth mobile app
6. schematic available: important if you want to mod/hack, repair or even build your own controller

The main advantages of our OpenSource firmware/embedded software are:
1. sine wave/"FOC" max efficiency: motors run silent and very efficient and is possible to tune a parameter to get the best efficiency possible for a specific motor
2. flexible and OpenSource: more than customization, any feature for some specific need can be easily implemented and for free (no need to pay any commercial license)
3. throttle, PAS and torque sensor: all of them are supported
4. LCD3 and LCD5: all of them are supported
5. regen/ebrake: works very well on the direct drive motors
6. motor torque controller/motor current controller
7. motor speed controller

The firmware sources are available on github and the developers and users communicate together on the Endless forum message.

Project status
As of 14 December 2017, the firmware is still experimental however we already use it on our EBikes :-)
See some videos on youtube by searching on youtube for “OpenSource firmware Ebike BMSBattery”.

Current state:
1. Tested on:
1) S06S and S12S motor controllers
2) Q85, Q100 and Q11 (direct drive) motors
3) 24V and 48V batteries
4) LCD3 and LCD5
5) throttle; PAS and pedal torque sensor
2. Features:
1) motor works well: starts with block commutation and then changes to sinewave
1- implemented “very low resolution FOC” that gives good efficiency (see next point)
2- efficiency is good, at least equal to original firmware and near to Lishui 12 fets FOC controller
1> there is one parameter that can be tweaked to make sure firmware is getting out the most efficiency possible from the controller
4- regen ebrake (see this video showing regen ebake working and Regen ebrake like coast brakes)
5- torque controller/motor current controller
6- motor speed controller
2) LCD3 and LCD5 works (not all features are implemented yet). What works:
8- shows:
1> motor speed
2> battery state
3> motor power usage
4> throttle active
5> brake active
6> some errors
9- changes:
7> assist level
8> max motor speed
9> P3: Power Assist Control Mode
10> C5: Controller Maximum Current Adjustment Mode
3) Throttle: works
4) Brakes: works
5) PAS: works
6) Torque sensor: works

Project history and motivation
I started this project on 25 April 2017 because I would like develop an OpenSource firmware for the EBike controllers. Why I am wanted to do that? because I wanted to use a well know controller that it is easy to repair/mod/adapt for my specific projects. I am developing the firmware for it, as OpenSource and I would like to share with others that have the same needs. My mission is similar to the Tesla mission (https://www.tesla.com/blog/mission-tesla): "to accelerate the advent of sustainable transport" and innovation on personal light electric vehicles.

The idea was to found a cheap and widely available EBike controller that could be programmable. I was developing, since 2015, firmware for the controllers of electric unicyles and they use the microcontroller STM32F103, that is very cheap and popular - the board is also cheap and widely available on market, that comes from China. By the way, the hoverboards controllers use the same STM32F103 microcontroller.

For EBikes, I found the most recent BMSBattery S series controllers like S06S sinewave use the STM8S105C6T6 microcontroller that is programmable, easy and cheap to develop for. There are OpenSource and cheap development tools for it.

BMSBattery sells the S series controllers, starting with S06S of 24/36V 15A (0.5kW, 6 mosfets) up to S12S of 72V 40A (2.9kW, 12 mosfets).
This controllers are developed by Kuteng (http://www.szktdz.com/en/ | http://minshine.cn/). There are available on the market in many different versions of Kuteng controllers, from 24V, 36V, 48V and 72V, with max currents of 70A (5kW, 18 mosfets).

Over the time, more and more users/developers did join the project and it was not anymore my project but a community project as I wished since the begin! You can find their nicknames and contributions on the forum message or git commits.
Last edited by casainho on Dec 14, 2017 6:45 pm, edited 18 times in total.
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

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

Re: OpenSource EBike firmware (STM8S microcontrollers)

Post by casainho » Apr 26, 2017 9:39 am

I updated the documentation notes file and seems that S06S controller continually output by UART serial port the information that is presented on the LCD controller. Also the LCD controller sends back some configurations to the S06S controller. I bet we can just connect a UART Bluetooth serial module instead of the LCD controller and make a simple Android to control the S06S controller!!

Thanks to the guy that documented the S06S LCD communications protocol:
Screenshot from 2017-04-26 15-35-05.png
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

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

Re: OpenSource EBike firmware (STM8S microcontrollers)

Post by casainho » Apr 30, 2017 12:37 pm

I did install the SDCC compiler for STM8 and I prepared the main.c and gpio.c files, they build correctly but I do not have yet a board to test.
I also have the OpenOCD scripts that will let me flash and debug the firmware.
I did commit the code to: https://github.com/OpenSource-EBike-fir ... s_firmware

I also updated the notes file with more information, mainly about how to install the development and attached some datasheets and application notes about motor control with STM8. This notes file about now about 80MBytes and can be found here: https://github.com/OpenSource-EBike-fir ... EE_xml.ctd
Image
Attachments
Screenshot from 2017-04-30 18-34-52.png
(173.4 KiB) Downloaded 71 times
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

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

Re: OpenSource EBike firmware (STM8S microcontrollers)

Post by casainho » May 08, 2017 4:02 am

I received the cheap dev board with STM8 and started to put the development tools together. Finally I just run the printf() example I found on github. So for now I was able to compile C code, debug it (breakpoints, step run, see/change variables in real time, inspect/write memory) and send strings over UART serial -- like original BMSBaterry S series controller do when communicating the S LCDs.

The firmware sources are here: https://github.com/OpenSource-EBike-fir ... s_firmware

Debug STM8 using STlinkV2, OpenOCD and Eclipse:
Image

The printf() output over UART serial:
Image
Attachments
z01.png
(227.12 KiB) Downloaded 66 times
z02.png
z02.png (47.27 KiB) Viewed 4821 times
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

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

Re: OpenSource EBike firmware (STM8S microcontrollers)

Post by casainho » May 08, 2017 4:09 am

On the last days I also finished a robust version of the firmware for FOC motor control of electric unicycles, that should also run on the hoverboards since they use the same microcontroller and IMU ics. I will use this firmware as a base for the EBike controllers.

The firmware was feature yesterday on the popular news site HACKADAY: http://hackaday.com/2017/05/07/open-sou ... verboards/

Video showing the firmware in action, controlling a motor using FOC. The motor is a direct drive one:
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

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

Re: OpenSource EBike firmware (STM8S microcontrollers)

Post by casainho » May 08, 2017 6:53 am

Finally found a way to have the documentation on the note taking software CherryTree but also have it on github as HTML page, this means google should be able to index it and users will found all the documentation when searching for it, like the main keyworks.

My workflow will be like this: keep improving the CherryTree notes file and commit the source file to github - anyone can submit an improvement/pull request to that file. At the same time, export from CherryTree to HTML and commit also to github, the output will be an update HTML page on the link: https://opensource-ebike-firmware.githu ... o--01.html
Screenshot from 2017-05-08 12-50-08.jpg
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

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

Re: OpenSource EBike firmware (STM8S microcontrollers)

Post by casainho » May 18, 2017 11:07 am

Today I received the BMSBattery S06S controllers and I was able to program and debug a first firmware that sends some strings over the wires that goes to the LCD :-)

I am updating my notes/documentation for this project here: https://opensourceebikefirmware.bitbuck ... oject.html
2017-05-18 16.40.11.resized.jpg
2017-05-18 16.42.07.resized.jpg
01.png
(106.27 KiB) Downloaded 59 times
02.png
03.png
03.png (153.44 KiB) Viewed 4694 times
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
izeman
10 GW
10 GW
Posts: 4500
Joined: Jun 21, 2011 8:25 am
Location: vienna, austria
Contact:

Re: BMSBattery OpenSource EBike firmware - STM8 microcontrol

Post by izeman » May 19, 2017 4:43 am

that's awesome work and i follow it closely. do you think there are more powerful controllers that may use your software (when it's done) as well? 250w is so super tiny ... ;)

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

Re: BMSBattery OpenSource EBike firmware - STM8 microcontrol

Post by casainho » May 19, 2017 5:07 am

izeman wrote:that's awesome work and i follow it closely. do you think there are more powerful controllers that may use your software (when it's done) as well? 250w is so super tiny ... ;)
Thank you for your feedback!! This forum misses a "like" button.

All the S series controllers from BMSBattery, the ones with 6 and 12 mosfets. Seems the more powerful they have is: "S12SN 72V1KW 40A Torque Simulation Sine Wave Controller".

This controller seems to be developed by http://www.szktdz.com/en/. Potential for this firmware work or be ported easily for every controller done with STM8S. Seems that GreenEBikeKit also sells the same controllers under different name.
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

d8veh
100 GW
100 GW
Posts: 5479
Joined: Dec 10, 2010 10:45 am
Location: Telford

Re: BMSBattery OpenSource EBike firmware - STM8 microcontrol

Post by d8veh » May 20, 2017 6:54 am

izeman wrote:that's awesome work and i follow it closely. do you think there are more powerful controllers that may use your software (when it's done) as well? 250w is so super tiny ... ;)
All the S-series controllers from BMSBattery and probably all the modern KT controllers.

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

Re: BMSBattery OpenSource EBike firmware - STM8 microcontrol

Post by casainho » May 20, 2017 2:14 pm

d8veh wrote:
izeman wrote:that's awesome work and i follow it closely. do you think there are more powerful controllers that may use your software (when it's done) as well? 250w is so super tiny ... ;)
All the S-series controllers from BMSBattery and probably all the modern KT controllers.
Hi d8veh. I found a lot of your messages helping, since some years ago, on this forum and others -- many respect for you. Really happy that you following this thread.

Can you please point a webshop for that KT controllers? I am listing here the alternative controllers with STM8: https://opensourceebikefirmware.bitbuck ... llers.html

I updated the documentation (https://opensourceebikefirmware.bitbuck ... oject.html) and here is the news:

New information I have:

STM8S105C6T6
• pin 2: resistor 2200R and a capacitor to GND. This pin goes to blue wire of undocumented connector with 2 wires (blue and black(GND))
• pin 3: resistor 2200R and a capacitor to GND. Resistor 10k to VCC. This pin goes to a header pin that is not wired
• pin 10: through one resistor, goes to BRAKE wire
• pin 15: ?? goes to a big diode..
• pin 16: goes to pin 7 LM358 (shunt current)
• pin 17: goes to pin output of ACS711 (phase B current)

Components:
• LM317 (voltage regulator): outputs 14.8V for the mosfet drivers
• 78L05 (voltage regulator): outputs 5V for the VCC
• LM358 (dual op-amp):
◇ pin7: outputs a value from shunt current (motor total current)
▪ 1.63V when motor is stopped (zero current)
◇ pin1: always at 5V. Seems it is not used and is connected to 5V with a resistor
• ACS711 (hall effect current sensor):
◇ output pin goes through a resistor (and a capacitor to ground) to pin STM8S105C6T6 pin 17 PB5/AIN5. This measures a motor phase B current (green phase wire)
▪ 2.5V when motor is stopped (zero current)
◇ fault pin is not used and is connected with a resistor to 5V

Possible motor control scheme
his cheap controllers are a 2nd generation. The first generation like BMSBAttery KU63 did only 6 step and had a shunt to measure motor total current, so no FOC nor current in phase +90º with rotor that is one of the main objectives of FOC.
The 2nd generation controllers, costs only 22€ but added a current sensor ACS712 in ne phase. Now the wave forms are sinusoidal and I think they look at the phase current to make it in +90º in phase with rotor, achieving the most important objective of FOC that is keep the motor rotating using the less energy possible (that will also result in more silent motor) -- amazing for a controller that came inside a metal box and water prof and just by 22€. It uses hall sensors only for track motor rotor position.

Explanation example of AN-8201 FCM8201 Three-Phase Sine-Wave BLDC Motor Controller document:

At 2., the middle HA is where motor flux is and the I phase current must be at 90º after, but as seen, there is a delta teta added to the point of 90º (that point is at end of positive value of HA).
At 3., the motor phase voltage (that we control) we advance delta teta and the result is the phase current will now be at 90º of middle HA (flux) -- this is the point where the motor will have more torque per amp used, the most efficient point:
234.png
234.png (117.29 KiB) Viewed 4566 times
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
machado88
1 mW
1 mW
Posts: 15
Joined: Aug 30, 2015 4:10 pm
Location: Portugal
Contact:

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by machado88 » May 21, 2017 5:00 am

Hummm... For sure looks a good controller for 22 bucks. But it is a bit far from FOC.
Yes, by maintaining rotor wingdings orthogonal to the stator field you get maximum Torque production.
However, what this enhanced controller does is that it is always trying to apply a correction to fix the angle issue that the controller itself created (confusing, right?).

FOC starts with the separation of two basics things: Magnetic Flux and Torque. So, FOC already has a pretty good estimation of the angle at any given moment (not only to maintain at 90, but to change that when doing Field-Weakening)
If you do not have those two vectors, you are basically in speed control. Some are more fancy them others, but they are still Speed controllers.

Correction: The angle estimation is unknown at standstill (if sensorless). We have to use some other fancy stuff to go around the motor startup.
LegStrong - Open-Source HW/SW controller (FOC + Bluetooth)
https://endless-sphere.com/forums/viewt ... =2&t=88285

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

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by casainho » May 21, 2017 8:05 pm

Hackaday, the popular website for Hacking news, did a quick reference to this project: http://hackaday.com/2017/05/21/hackaday ... y-21-2017/
Is not 100% correct but I think is ok and the readers can always follow the link to here and get the full information.

Image
Attachments
0zz.png
0zz.png (25.98 KiB) Viewed 470 times
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

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

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by casainho » May 23, 2017 8:39 am

I finish the code that reads the hall sensors signals - using a pin change interrupt. The firmware is here: https://github.com/OpenSource-EBike-fir ... s_firmware

#define EXTI_PORTE_IRQHANDLER 7
void EXTI_PORTE_IRQHandler(void) __interrupt(EXTI_PORTE_IRQHANDLER)
{
unsigned char hall_sensors = 0;

// read hall sensors signal pins and mask other pins
hall_sensors = (GPIO_ReadInputData (HALL_SENSORS__PORT) & (HALL_SENSORS_MASK)); // sequence: 1; 3; 2; 6; 4; 5

printf("%d\n", hall_sensors);
}

int main()
{
uart_init ();
hall_sensor_init ();
enableInterrupts ();

while (1) ;
}
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

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

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by casainho » May 23, 2017 8:58 am

I did finish taking the information about pin connections to STM8 so I can start writing the firmware. I also documented the PWM signals including the dead time, please see here:

https://opensourceebikefirmware.bitbuck ... gnals.html

---
I got one S06P controller today and compared to S06S controller:

The S06P controller don't do sine wave motor control but just 6 steps. When compared to the S06S controller:
• don't have the phase current sensor (the place is on the board but is empty)
• have a secondary board that connects to the same pins as hall sensors:
◇ have a STM8S003F3P6 (with available header to be programmed)
◇ have an LM339
◇ I would say this board does BEMF signal output to simulate the hall sensors signal, just like on the KU63 controller circuit

See the pictures here: https://opensourceebikefirmware.bitbuck ... -S06P.html
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

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

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by casainho » May 24, 2017 10:18 am

Got the ADC (pooling for now) working, reading throttle value.
Also got PWM working (PWM symetric to come) and duty_cycle value is defined by throttle value:

Code: Select all

int main()
{
  //set clock at the max 16MHz
  CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);

  gpio_init ();
  brake_init ();

  // hold here while brake is pressed -- this is a protection for development
  while (!brake_is_set()) ;

  uart_init ();
  hall_sensor_init ();
  pwm_init ();
  adc_init ();
  enableInterrupts();

  while (1)
  {
    static uint16_t adc_value;
    adc_value = adc_read_throttle ();
    pwm_set_duty_cycle_channel1 (adc_value);
    pwm_set_duty_cycle_channel2 (adc_value);
    pwm_set_duty_cycle_channel3 (adc_value);
  }
}
Next I need to put PWM working symmetric and adding the dead-time. Then I will have all the tools to run the motor:
- hall sensors working
- PWM working
- throttle working
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

Steu851
1 mW
1 mW
Posts: 13
Joined: Nov 07, 2016 10:52 am

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by Steu851 » May 24, 2017 10:27 am

Good work! Thank you!
Please don't forget PAS sensor, trottle is not legal in Europe.


Sent usingTapatalk

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

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by casainho » May 24, 2017 10:41 am

Steu851 wrote:Good work! Thank you!
Please don't forget PAS sensor, trottle is not legal in Europe.
It is far to be finished, as for be with the same quality as original firmware, I need to look at phase sensor current and find a way to adapt it to be synchronize with rotor position (hall sensors signal).

I don't use PAS, maybe you can help if you say what could be the algorithm for PAS. I know that PAS is connected to a digital only input pin to the STM8, so firmware will only be able to read it as being ON or OFF state.
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

Steu851
1 mW
1 mW
Posts: 13
Joined: Nov 07, 2016 10:52 am

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by Steu851 » May 24, 2017 11:21 am

PAS a hall sensor, used to know if pedals are tuning, one feature not present in the original firmware nice to have is to enable trottle only if pedals are tuning, always, not only when starting, we are used to call this feature 'gas legalizer'.
All legal ebike here doesn't have trottle at all, we can choose motor assistance only from display.
I apologize for my bad english.

Sent usingTapatalk

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

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by casainho » May 26, 2017 7:41 am

Got the motor running!! But for now just as 6 steps (the same as KU63, JUxx controllers), just like the original firmware does when starts the motor and run it at very low speeds, before commutate to sinewave.
As you can see on the video, throttle and brake works. I didn't implement any current control yet, I think I will leave that to the end of the project while I am running with a lab power supply.

Project documentation here: https://opensourceebikefirmware.bitbuck ... oject.html

Firmware sources: https://github.com/OpenSource-EBike-fir ... s_firmware



The code as of today:

Code: Select all

int main()
{
  //set clock at the max 16MHz
  CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);

  gpio_init ();
  brake_init ();
  while (brake_is_set()) ; // hold here while brake is pressed -- this is a protection for development
  uart_init ();
  hall_sensor_init ();
  pwm_init ();
  adc_init ();
  enableInterrupts();

  hall_sensors_read_and_action (); // needed to start the motor

  while (1)
  {
    static uint16_t adc_value;
    adc_value = adc_read_throttle ();
    adc_value = map (adc_value, ADC_THROTTLE_MIN_VALUE, ADC_THROTTLE_MAX_VALUE, 0, 1023);
    pwm_value = adc_value;

    pwm_set_duty_cycle_channel1 (pwm_value);
    pwm_set_duty_cycle_channel2 (pwm_value);
    pwm_set_duty_cycle_channel3 (pwm_value);
  }
}

// HALL SENSORS signal
void EXTI_PORTE_IRQHandler(void) __interrupt(EXTI_PORTE_IRQHANDLER)
{
  hall_sensors_read_and_action ();
}

void hall_sensors_read_and_action (void)
{
  unsigned char hall_sensors = 0;

  // read hall sensors signal pins and mask other pins
  hall_sensors = (GPIO_ReadInputData (HALL_SENSORS__PORT) & (HALL_SENSORS_MASK));

  switch (hall_sensors)
  {
    case 3:
      pwm_phase_a_enable_pwm ();
      pwm_phase_b_disable ();
      pwm_phase_c_enable_low ();

    break;

    case 1:
      pwm_phase_a_enable_pwm ();
      pwm_phase_b_enable_low ();
      pwm_phase_c_disable ();
    break;

    case 5:
      pwm_phase_a_disable ();
      pwm_phase_b_enable_low ();
      pwm_phase_c_enable_pwm ();
    break;

    case 4:
      pwm_phase_a_enable_low ();
      pwm_phase_b_disable ();
      pwm_phase_c_enable_pwm ();
    break;

    case 6:
      pwm_phase_a_enable_low ();
      pwm_phase_b_enable_pwm ();
      pwm_phase_c_disable ();
    break;

    case 2:
      pwm_phase_a_disable ();
      pwm_phase_b_enable_pwm ();
      pwm_phase_c_enable_low ();
    break;

    default:
    return;
    break;
  }
}
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

Steu851
1 mW
1 mW
Posts: 13
Joined: Nov 07, 2016 10:52 am

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by Steu851 » May 26, 2017 8:12 am

Awsome

Sent usingTapatalk

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

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by casainho » Jun 02, 2017 12:42 am

While trying to run the motor with a more advanced control scheme that original firmware does (a scheme that is used with FOC motor control) I found some issues that I tough could be because of motor and started this thread: https://endless-sphere.com/forums/viewt ... =2&t=88651

The questions are: why the original firmware of S06S (sinewave) controller makes the motor rotating with more noise, takes more current and the power supply voltage increases when a more simple way to run the motor with 6 steps (my OpenSource firmware) make less noise, uses less current and the power supply voltage don't change as expected????
And another way to control that I am trying with my OpenSource firmware, that is even more advanced than sinewave, gives even much more noise, takes much more current and increases much more the power supply voltage!!

I have some clues. The mosfet drivers are called "inverter" and as on DC-DC converters, the inverter can boost the voltage make it much more bigger than input voltage. The 6 steps uses PWM ON and the low side mosfets are always ON/OFF with no PWM. The other modes like sinewave have PWM in low side mosfets... I think the issue is a wrong dead time between high side mosfets and low side, that short circuit the motor windings or mosfets a bit and that will boost the voltage (thanks also to the capacitors on the board) but also asks more current from the power supply and will make the noise on the motor.

I will try to play with the dead time configuration on the firmware/microcontroller but I don't know what are the limitations of the board/mosfet drivers...

I already measured the dead time of original firmware:
Image

Image

More info here: https://opensourceebikefirmware.bitbuck ... gnals.html
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
KingQueenWong
100 mW
100 mW
Posts: 37
Joined: Dec 18, 2016 7:07 am

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by KingQueenWong » Jun 02, 2017 8:24 am

20170602149641074759316a7b2dfc4.jpg
How many wires should be connected?My motor failed to rotate. :(
Last edited by KingQueenWong on Jun 02, 2017 8:41 am, edited 3 times in total.

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

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by casainho » Jun 02, 2017 8:33 am

KingQueenWong wrote:How many wires should be connected?My motor failed to rotate. :(
Hi KingQueenWong!! Nice to see you here also!!!

Can you please elaborate a bit more so I can help you?? Like: do you have the same S06S controller? which motor are you using? where you able to flash the firmware??
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
KingQueenWong
100 mW
100 mW
Posts: 37
Joined: Dec 18, 2016 7:07 am

Re: OpenSource firmware BMSBattery Sxxx motor controllers ST

Post by KingQueenWong » Jun 02, 2017 8:49 am

Motor: Q100 rear driving E-bike Hub Motor
Voltage:24V
Power:350W
RPM:328
Hall sensor and sensorless Waterproof

Controller:
S06S 250W Torque Simulation Sine Wave Controller

You can enlarge the pictrue for more connected wires detail.

Post Reply