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

Electric Motors and Controllers
vex_zg   100 W

100 W
Posts: 178
Joined: Mar 06 2016 6:07pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by vex_zg » Oct 08 2017 6:18am

casainho wrote:
vex_zg wrote: In the meantime:
I asked the seller who sold me this bluetooth module if he can get more. He might be able to get some from the KT factory. Is anybody interested? I only asked because somebody here wrote BT modules can't be purchased separately.
I would like to buy 3 units of this module.
OK, I will post here when I have reply with availability/price

User avatar
stancecoke   100 kW

100 kW
Posts: 1383
Joined: Aug 02 2017 2:56pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by stancecoke » Oct 08 2017 6:52am

Support for J-LCD works partly now . Receiving Data is controlled by interrupt. See updated github branch and this video:



Sending the speed to the display is still sticky....

Bluetooth Support:
there is a plug and play solution from Lishui:
http://app.lsdzs.com/home/

The module is available at the lishui store:
http://app.lsdzs.com/home/online-store/

It works with several protocols, included the J-LCD protocol.
The module can be easily homebrewed: :wink:

regards
stancecoke

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 08 2017 8:39am

stancecoke wrote:Support for J-LCD works partly now . Receiving Data is controlled by interrupt. See updated github branch and this video:
You are the men!! :-)

On that video, the assistance level you were selecting, what did define on the firmware? the motor current? motor speed??
stancecoke wrote: The module can be easily homebrewed: :wink:
You are the men 2!! :-)
So you did document your build for the bluetooth module and it is even more complex than I thought.... and you got it working with Lishui original app :-)

I will copy-past your forum message to the HTML/notes of this documentation!! :-)

So much work and achievements! -- my girlfriend is joking saying that by now, your wife already put you out of the house :-)
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

ThierryGTLTS   1 W

1 W
Posts: 54
Joined: Jan 10 2017 8:10am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by ThierryGTLTS » Oct 08 2017 9:36am

Hi guys,

I've discovered a triple error in the S06C schematic.

+ of C1 is conected to cathode of D2, + of C3 is conected to cathode of D4, + of C14 is conected to cathode of D8, and not to Vout.
Otherwise the boostrap will not work :!:

Hope it may help in case of troubleshooting.

I have 2 S06SC (for central motor, and the waveform is also not very sinusoïdal, it is equipped with ACS711.

I also noticed that the Cheeta looks like the VESC of Benjamin Vedder, did it share the same firmware :?: :!:

Have a Nice Day.

Thierry

User avatar
stancecoke   100 kW

100 kW
Posts: 1383
Joined: Aug 02 2017 2:56pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by stancecoke » Oct 08 2017 9:41am

casainho wrote: On that video, the assistance level you were selecting, what did define on the firmware? the motor current? motor speed??
It's just used to set the duty cycle by now

Code: Select all

 pwm_set_duty_cycle ((ui8_assistlevel_global-1)*60); //for test of display communication
casainho wrote: my girlfriend is joking saying that by now, your wife already put you out of the house :-)
My whole family was laughing when I read out this sentence loud. :lol: Lucky enough, my wife is very tolerant!

regards
stancecoke

vex_zg   100 W

100 W
Posts: 178
Joined: Mar 06 2016 6:07pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by vex_zg » Oct 08 2017 11:44am

great work Stan with the lishui bt adapter / app.

I presume the app will only work with lishui controllers, and not KT controllers?

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 08 2017 12:25pm

ThierryGTLTS wrote:Hi guys,

I've discovered a triple error in the S06C schematic.

+ of C1 is conected to cathode of D2, + of C3 is conected to cathode of D4, + of C14 is conected to cathode of D8, and not to Vout.
Otherwise the boostrap will not work :!:

Hope it may help in case of troubleshooting.

I have 2 S06SC (for central motor, and the waveform is also not very sinusoïdal, it is equipped with ACS711.

I also noticed that the Cheeta looks like the VESC of Benjamin Vedder, did it share the same firmware :?: :!:
Thanks.

I just started an issue on the schematic repo, let's see if KingQueenWong can correct the schematic: https://github.com/KingQueenWong/bmsbat ... e/issues/1

Link for Cheeta??
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

User avatar
stancecoke   100 kW

100 kW
Posts: 1383
Joined: Aug 02 2017 2:56pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by stancecoke » Oct 08 2017 1:33pm

vex_zg wrote: I presume the app will only work with lishui controllers, and not KT controllers?
you are right, it has only Kingmeter and Bafang protocols implemented. (Unless you use the Open Source firmware... ;-))

Image
casainho wrote: Link for Cheeta??
viewtopic.php?f=30&t=87870&p=1317505&hi ... a#p1317505

regards
stancecoke
Attachments
Screenshot_protocol settings.png
Screenshot_protocol settings.png (130.06 KiB) Viewed 1862 times
Last edited by stancecoke on Oct 09 2017 1:59am, edited 3 times in total.

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 08 2017 1:44pm

stancecoke wrote:
vex_zg wrote: I presume the app will only work with lishui controllers, and not KT controllers?
you are right, it has only Lishui and Bafang protocols implemented. (Unless you use the Open Source firmware... ;-))
I am planning to move on to software development (professionally). I am start learning JavaScript and I think my first project may be the Android app for this project (to build experience and portofolio) -- (will be using Reactive Native javascript to develop the app).
In parallel I will keep working on the firmware but more specifically on the motor control.
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

User avatar
stancecoke   100 kW

100 kW
Posts: 1383
Joined: Aug 02 2017 2:56pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by stancecoke » Oct 08 2017 2:26pm

casainho wrote: I am planning to move on to software development (professionally).
I wish you much success!
I've played around with app development (for home automation and geocaching) a little, but I wasn't very happy with my progress... :?

Here another video, using the bluetooth module to drive the controller



regards
stancecoke

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 08 2017 2:43pm

Thanks.
stancecoke wrote: Here another video, using the bluetooth module to drive the controller
From 3 to 2, seems the motor makes a strong noise... seems that it switch from sinewave interpolation to no interpolation. Seems your motor do regen on that step... to help improve this I need to make a stable motor code so you can adopt it. Let's see If I can do it tomorrow:
- max current limit value setup
- max current regen limit value setup (regen happens when decelerating)
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

vex_zg   100 W

100 W
Posts: 178
Joined: Mar 06 2016 6:07pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by vex_zg » Oct 09 2017 3:50am

vex_zg wrote:
casainho wrote:
vex_zg wrote: In the meantime:
I asked the seller who sold me this bluetooth module if he can get more. He might be able to get some from the KT factory. Is anybody interested? I only asked because somebody here wrote BT modules can't be purchased separately.
I would like to buy 3 units of this module.
OK, I will post here when I have reply with availability/price
Seller responded that he doesn't have any BT modules to sell now (the ones like the sample I photographed)

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 09 2017 3:53am

vex_zg wrote:Seller responded that he doesn't have any BT modules to sell now (the ones like the sample I photographed)
Thank you. I will then build my own module following stancecocke documentation :-)
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 09 2017 5:31am

casainho wrote:
ThierryGTLTS wrote:Hi guys,

I've discovered a triple error in the S06C schematic.
I just started an issue on the schematic repo, let's see if KingQueenWong can correct the schematic: https://github.com/KingQueenWong/bmsbat ... e/issues/1
KingQueenWong had corrected that issue :-)
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 09 2017 5:46am

casainho wrote:Thanks.
stancecoke wrote: Here another video, using the bluetooth module to drive the controller
From 3 to 2, seems the motor makes a strong noise... seems that it switch from sinewave interpolation to no interpolation. Seems your motor do regen on that step... to help improve this I need to make a stable motor code so you can adopt it. Let's see If I can do it tomorrow:
- max current limit value setup
- max current regen limit value setup (regen happens when decelerating)
stancecoke, can you please start using the motor code from motor branch?? https://github.com/OpenSource-EBike-fir ... tree/motor

That code works well for my but only for my Q85 motor, for the other direct drive motor it has some issues that I need to understand to fix.

Code: Select all

/***************************************************************************************/
// Motor interface
void hall_sensor_init (void); // must be called before using the motor
void motor_init (void); // must be called before using the motor
void motor_set_mode_coast (void); // disable PWM output
void motor_set_mode_run (void); // enable PWM output
void motor_set_pwm_duty_cycle_target (uint8_t value);
void motor_set_current_max (uint8_t value); // steps of 0.5A each step
void motor_set_regen_current_max (uint8_t value); // steps of 0.5A each step
void motor_set_pwm_duty_cycle_ramp_inverse_step (uint8_t value); // each step = 64us
uint16_t motor_get_motor_speed_erps (void);
/***************************************************************************************/
New on this motor interface
- motor_init (): must be called before using motor. This mainly averages some ADC samples of motor current, to find the zero value.
- motor_set_current_max (): now you can define the torque for the assistance level, instead of duty_cycle - don't forget to first define motor_set_pwm_duty_cycle_target (255).
My intuition tells me that assistance level is like different fixed throttle values but where throttle is a "speed+torque".
- motor_set_pwm_duty_cycle_ramp_inverse_step (uint8_t value): it doesn't work as it should because seems motor current control interacts with this value. But you can use a very low value like 1 or 2.
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 09 2017 6:37am

Added motor OC (over current) protection, using an pin change interrupt that have the following code:

Code: Select all

#define CURRENT_MOTOR_TOTAL_OVER__PIN  GPIO_PIN_7
#define CURRENT_MOTOR_TOTAL_OVER__PORT GPIOD

  /***************************************************************************************/
  // motor overcurrent pin as external input pin interrupt
  GPIO_Init(CURRENT_MOTOR_TOTAL_OVER__PORT,
	    CURRENT_MOTOR_TOTAL_OVER__PIN,
	    GPIO_MODE_IN_FL_IT); // with external interrupt

  //initialize the Interrupt sensitivity
  EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOD,
			    EXTI_SENSITIVITY_FALL_LOW);
  /***************************************************************************************/

Code: Select all

// motor overcurrent interrupt
void EXTI_PORTD_IRQHandler(void) __interrupt(EXTI_PORTD_IRQHANDLER)
{
    motor_set_mode_coast ();
    while (1) ; // infinite loop, user will need to reset the system
}
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 10 2017 4:50am

stancecoke,

I tried the firmware with my bicycle Q85 motor and turns out it doesn't have torque (I even did disable motor max current control for testing). The only way to have torque, I tested, is with 6 steps!! But I still can't start with 6 steps and transition to sinewave.... :-(
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

User avatar
stancecoke   100 kW

100 kW
Posts: 1383
Joined: Aug 02 2017 2:56pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by stancecoke » Oct 10 2017 6:26am

casainho wrote: I tried the firmware with my bicycle Q85 motor and turns out it doesn't have torque
Hmm, I changed nothing concerning the motor.c / pwm.c functions. Have you tried the original code of the J-LCD branch, or have you merged something together? Is the motor running without load?
With the simple setting of assistLevel to dutycycle, the motor isn't running with the lab power supply properly, as with the change of the assistLevel a high current peak occurs, the power supply drops the voltage and the controller stops the motor due to undervoltage protection. With a battery the motor runs properly.

Regards
stancecoke

User avatar
stancecoke   100 kW

100 kW
Posts: 1383
Joined: Aug 02 2017 2:56pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by stancecoke » Oct 10 2017 12:18pm

Display of speed and power is working now! 8)



casainho wrote: stancecoke, can you please start using the motor code from motor branch??
Which parts do I have to merge? Just motor.c and pwm.c?

Regards
stancecoke
Last edited by stancecoke on Oct 10 2017 12:56pm, edited 1 time in total.

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 10 2017 12:30pm

stancecoke wrote: stancecoke, can you please start using the motor code from motor branch??
Which parts do I have to merge? Just motor.c and pwm.c?
[/quote]
Great progress!! :-)

Many changes... install Meld and to the folder comparition between your branch and motor branch. Meld shows you with pretty visuals the diffs and you can even merge/delete the changes.
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 10 2017 7:43pm

stancecoke wrote:
casainho wrote: I tried the firmware with my bicycle Q85 motor and turns out it doesn't have torque
Hmm, I changed nothing concerning the motor.c / pwm.c functions. Have you tried the original code of the J-LCD branch, or have you merged something together? Is the motor running without load?
With the simple setting of assistLevel to dutycycle, the motor isn't running with the lab power supply properly, as with the change of the assistLevel a high current peak occurs, the power supply drops the voltage and the controller stops the motor due to undervoltage protection. With a battery the motor runs properly.
The power supply I am using can give 10 amps which is a good value.
Seems that my direct drive motor is very different from Q85. Let's see if I can something working fro Q85. I am trying on the bicycle but with lab power supply and as soon I have something working ok I will move to a battery :-)
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

User avatar
stancecoke   100 kW

100 kW
Posts: 1383
Joined: Aug 02 2017 2:56pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by stancecoke » Oct 11 2017 3:34am

Don't put any time in this stupid way of using the assistLevel information. I was just too lazy to verify the function of the UART Communication in a more intelligent way.

I suggest to define an array with the percentage of an absolute max current (defined in an #define statement) the assistLevels should stand for.

Code: Select all

assistLevel_percentage[5] = {20, 40, 60, 80, 100};


then you can use that for the "torque simulation" mode.

Code: Select all

#ifdef TORQUE_SIMULATION
   if (ui16_PAS_Counter<timeout){
     if (ui16_PAS>ramp_end){ 
     ui8_ADC_motor_current_max=(assistLevel_percentage[(ui8_assistlevel_global-1)]/100*ADC_MOTOR_CURRENT_MAX)* ramp_end/ui16_PAS;
      }
     else{
      ui8_ADC_motor_current_max=(assistLevel_percentage[(ui8_assistlevel_global-1)]/100*ADC_MOTOR_CURRENT_MAX)
      }
    else{
       ui32_setpoint=0;
       printf("you are not pedaling!");
      }

#endif
In this way you ramp up ui8_ADC_motor_current_max with the cadence. In your existing pwm_duty_cycle_controller you then can add a simple p-controller to tune duty cycle to the recent current setpoint, instead of just decreasing the dutycycle if current is too high.


regards
stancecoke
Last edited by stancecoke on Oct 11 2017 7:09am, edited 1 time in total.

ThierryGTLTS   1 W

1 W
Posts: 54
Joined: Jan 10 2017 8:10am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by ThierryGTLTS » Oct 11 2017 4:28am

casainho wrote:
casainho wrote:
ThierryGTLTS wrote:Hi guys,

I've discovered a triple error in the S06C schematic.
I just started an issue on the schematic repo, let's see if KingQueenWong can correct the schematic: https://github.com/KingQueenWong/bmsbat ... e/issues/1
KingQueenWong had corrected that issue :-)
OK, it's right now.

Thierry

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 11 2017 9:47am

Just got the Q85 motor running well -- it starts with 6 steps/block commutation and transition to sinewave very well. Turns out I had to increase the speed at which that transition happens (before was 25 and now is 150).

Now it does have torque/force to start, I tested on my bicycle. But it needs more torque - my power supply gives only 10A and this controller can give 15A... can't wait to test on real battery with the current limit of 15A.

And for some reason, now the ui8_adc_read_motor_total_current (); don't work anymore... makes no sense but let's see if I found the reason or a workaround.
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

casainho   100 GW

100 GW
Posts: 5035
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Oct 11 2017 10:07am

stancecoke wrote:Don't put any time in this stupid way of using the assistLevel information. I was just too lazy to verify the function of the UART Communication in a more intelligent way.
I think would be great if you could use the motor code in your branch and then we could merge your branch to master and take out a stable version of the firmware.
stancecoke wrote: In this way you ramp up ui8_ADC_motor_current_max with the cadence. In your existing pwm_duty_cycle_controller you then can add a simple p-controller to tune duty cycle to the recent current setpoint, instead of just decreasing the dutycycle if current is too high.
Now I remember what you said before about slow loop current controller.

The current controller on pwm_duty_cycle_controller is low level and fast, to protect the system. For this Throttle/PAS/Torque sensor controller, I agree with you that this (PI ??) controller can run at slower speed -- this have the advantage also make possible running a more complex PI controller or something, that needs more heavy math.

Also I keep seeing the Throttle/PAS/Torque sensor as "speed+torque". Using the torque sensor, your controller would control the motor speed and the motor current max:
- read motor_get_motor_speed_erps() to get motor speed and control the motor speed by adjusting the value of motor_set_pwm_duty_cycle_target()
- adjust linearly the motor_set_current_max() from the torque sensor value

Refer to the image bellow - what do you think??

Image
- EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

Please consider a donation to help developments: paypal.me/jorgecasa

Post Reply