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

Got my STLink in the mail last week. Can confirm the $6 Aliexpress knockoff version works fine. Managed to fix my spare controller (actually my first KT 18 FET controller that came with the first kit I bought, a SVPR version that came with IRFB4110 FETs (4.2mA RDS on, very nice) from Pasionebike). Ran it successfully for a year of 48V/45A/2000W and 5000 hard, hilly kilometres. Started shutting off intermittently, usually after/during long hill and low pack voltage. Eventually it wouldn’t start up. Noticed the LM317 feeding the 7805 had no output. The big resistor that steps down battery voltage and feeds the LM317 gets hot and while looking at the board you could see a brown burn mark on the PCB where it goes in. Resistor tested fine but had high resistance in the trace at this leg going to the 317. Had to wire in a small ~1cm jumper wire from the bottom of the resistor to pin U2B feeding the 317 input. Controller works fine now. Originally thought it was the 7805 because I had no throttle voltage and controller wouldn’t boot up. Replaced the 7805 first, to no avail. Anyway.

Soldered in a 4-pin header on the programming ports. I also have two other KT controllers, both 45A/18 FET 48/52V, one SVPR and one ZWS, both with Toshiba TK150E09NE FETs (not quite as exotic, but still good with 6.5mA RDS on). All have LSHC 63V 470uF capacitors on V+ battery, but the first controller came with only one (other location left blank). The other two have both spots populated with two caps. Between the two sine wave versions I also noticed different PCB revisions. My first controller put the ACS758 sideways on the B phase and the programming ports start with the 5V line on the opposite side (order reversed). This controller was purchased in 2019 from Pasionebike, PCB has 2016 stamped on it. The newer SVPR has 2018 stamped on the board, purchased in 2020 from Pasionebike. ZWS is from CSC, bought in 2021 as part of a 1500W kit. Newer controllers have slightly thicker phase wires as well. So now my spare sine wave controller is fixed and set up as my OSF test mule.

Used the 48V DD-12FET presets as a starting point. Left Cal A at 46, battery/phase current at 100/300, for ~22A draw on the battery to test around the 1000W level. Voltage calibrations were correct for 48V. Not using regen for now. Left throttle min/max at 43/182 (corresponds with .84V to 3.57V). Motor specific angle of 238 is perfect and same as the other 1500W DD “leafmotor” user. Didn’t notice a difference with the experimental anti-jitter on or off. I thought the factory sine wave controller was smooth and quiet compared to the ZWS. This is beyond what I expected — it’s eerily silent. Not even a slight hum of the factory SVPR program. More torque than before at 1000W at low speed. Top end is similar, which is what should be expected as duty cycle goes up and you have the same amount of current from the battery as before. Must be more phase amps at low speed than stock fw. Very nice.

I use throttle-only and like the “Throttle follows assist level” setting. Finally the assist level actually does something, and it’s nice to kick down to 100-300W to get the most range when cruising.

I had very slight oscillation at Gain I = 0.2, so after reading some posts here I set it to 0.1. I had a problem at first of the bike moving forward with no throttle input. You would start up the controller, it wouldn’t move, but as soon as you pushed the bike forward with no throttle input it would power forward (very weakly) a bit. After searching and reading this thread, I saw Stancecoke’s post about altering Cal B current initialization in adc.c code from -= 1 (slightly negative biased) to += 1 (slightly positive biased). This was in response to someone who thought the motor was dragging too much, but I had the opposite problem. At first, I tried going from -= 1 to += 1. Way worse, the bike would move as soon as it was turned on with no throttle input. Ended up trying Cal B -= 2 and that fixed it. Bike stays put when turned on/pushed forward.

From what I understand, adc.c deals with the analog-digital inputs of the microcontroller. In this case, we are looking at a value (Cal B) that offsets the PWM duty cycle that is constantly calculated when on (in response to throttle signal, among other things), right? Cal B offsets the calculated PWM duty cycle by a little bit to add/subtract so that the current at rest/no throttle input can be zeroed? Since the OSF does not shut off PWM at rest, is this even related to the throttle signal (and min/max) at all, and simply the right offset will let the bike rest without dragging or powering itself forward?

Is it coincidental that altering Cal B -= 1 to -= 2 fixed the problem and that I should be raising the throttle min? Would a throttle min setting too low cause a non-zero reading at startup?

Is the reason that the resting state/coasting/throttle response behavior are so different from the stock firmware because the OSF works in such a fundamentally different way? From what I gather so far: It uses an 8-bit sine wave lookup table to generate a sine wave current, indirectly. This is done by mapping each value 0-255 of the period of an 8-bit sine wave to a voltage (0-255) with a corresponding MOSFET PWM duty cycle (again 0-255 is 0-100% with 8 bits). Perhaps you just store a quarter of the period as a table to get a higher-resolution wave using 256 unique values with 8-bits, and you do sign operations and add/subtract to get the full period. Likewise, you only need to store one wave in a lookup table to save memory, and can generate three identical waves 120 degrees apart from this single one for the other two phases. Is it true that you do this calculation on a single phase for saving CPU time (it's a 16MHz 8-bit processor), but then add/subtract to get the other phases, and it goes through this loop every single PWM cycle (at ~16KHz PWM frequency, so you have <1000 cycles to do this for a 16MHz processor), right? So it's doing this constantly, whether accelerating, coasting, or at rest, and the outer control loops are making sure that battery current max, speed max, phase current max, low/high voltage etc are not exceeded and also reading the throttle/regen input and responding accordingly. Is this correct?

So the current sensor zero-crossing is compared with the hall sensor signal once the wheel is turning fast enough for reliable output. Rotor position (0-255 is 360 degrees) gets interpolated for the 60 degrees between each hall signal (based on a speed estimate?). It is the zero crossing measured on phase current B sensor that allows us to do a "simplified" form of FOC (field-oriented motor control). The "proper" way is to measure current directly of each phase, representing a 3-d a,b,c coordinate system --> Park transform to 2-d orthogonal Iq and Id currents --> Clark transform to single dimension rotating coordinate system with one current (controlling it in a loop to keep the 2-d Iq and Id always orthogonal is FOC) --> inverse Clark transform --> inverse Park transform --> back to a,b,c phases and now you have the next PWM duty cycle (creating the sinusoidal voltage output of each phase 120 degrees apart). Too mathematically intense for the STM8 apparently. There is a very interesting article linked in one of the project creators' sites explaining this.

Not sure if advance/correction would be calculated every PWM cycle like the wave generator. This is what the angle correction is, and we want it because PWM duty cycle controls voltage, which then induces current, and current lags the voltage by some time (current phase lags voltage 90 degrees in alternating current in frequency domain) because inductors (motor coils) resist changes in current, and thus you advance so that the current peaks when the coil lines up with the magnet and the motor runs quieter, more efficiently, and produces more torque/amp. The faster/more variable the rotational speed of the motor, the more important this becomes: if the voltage is set to peak at the moment the hall signal fires (supposed to be aligned so it's when coils/magnets, i.e. poles line up), the current flow in the inductive coils will follow the exponential curve and always take the same time to reach it's peak value (which is the peak phase current). The faster the motor spins, the worse it gets: the current peak is out of alignment at an increasing angle. Setting a static advance offset is no good. It only best at a specific speed. So the program adjusts the advance based on the difference between the zero-crossing point on phase B current sensor and the hall signal clock edge to try to make the zero-crossing happen as close to 90 degrees from the hall signal (where you want it to peak). This is simplified FOC because it has the same effect: keeping the Iq and Id currents orthogonal is the same as advancing the phase of the wave generator by the perfect amount. The program must also scale the amplitude of the sine wave depending on 0-100% throttle signal.
 

Attachments

  • tempImagegoVGmf.gif
    tempImagegoVGmf.gif
    5.9 MB · Views: 1,052
  • tempImagemMKZbX.gif
    tempImagemMKZbX.gif
    4.6 MB · Views: 1,051
  • tempImagejVbSkQ.gif
    tempImagejVbSkQ.gif
    3.6 MB · Views: 1,052
  • tempImageOLek5Q.gif
    tempImageOLek5Q.gif
    6.4 MB · Views: 1,054
  • tempImagevFxhAu.gif
    tempImagevFxhAu.gif
    4.7 MB · Views: 1,055
Okay I finally got hold of a proper cable and the motor is wired up. But I experience these problems:

#1 Throttle does nothing - I can see it produces values in the app, so it's correctly wired and works. But there is no effect of it at all
Immediately upon power on, the motor goes full speed in the air. In spite of no response from either throttle or PAS.
Once the motor is spinning I can see that it produces correct phase ring, so on that front it looks okay.

#2 The speed is not shown properly - despite patching correct wheel size in the java tool (used 26inch template to find correct value)

#3 Braking produces current peak - if I short the brake pins and pull the lever, there is extra current going into the motor. On geared hub it should ideally just stop the commutation cycle, as there is no regen anyway. Enabling PWM auto off shows no effect.

PAS sensor is not yet installed, so I'd go throttle only for now. Does anyone have a suggestion for possible fix?
Motor is of geared hub type (bafang g040)
 
Sorry for the off topic ... I have big problems with a linshui control unit, purchased new together with its display and torque sensor.
https://it.aliexpress.com/item/4000038619326.html?spm=a2g0s.9042311.0.0.6dde4c4dkpGqIs
On the stand the control unit worked, even if it worked badly, the engine stopped with a delay of about 3 seconds when you stopped pressing on the pedals and this was dangerous. Any sensitivity adjustment on the display was inoperative.
tested on the road, after 100m it has stopped working, it has an E30 error, communication error but obviously there is no problem with the connections. No form of reset of the display is possible.
Any idea? Unfortunately I think I threw away about $ 200 :-(
2) It's possible to flash the new firmware on this controller?

3) a friend of mine gave me a eunorau control unit for torque sensor. Can I try to use it with my torque sensor? (mine is a T9 model), I have searched and it seems to me that there is a difference in the supply voltage, is that right?
thank you
 
Anyone got cruise control to work?
It can be reactivated in the main.c, but it behaves like it's broken, even brake pins no longer stop the motor, and it activates immediately.

This commit suggests it was probably working before:
https://github.com/stancecoke/BMSBattery_S_controllers_firmware/commit/e95f747f8e0d1bd2c28ca07eb20622ed1afb38e2#diff-8ddec1eafd2893191cf97a6f99e9568108d0623c62cfe20010fb84f142ed46a9
 
I am tinkering with the open source firmware and I have made the firmware work with the LCD8H almost as stock now. The big trick to get it working is setting the second xor variable in the if statement to 23. I found this with a simple program, which tested a bunch of numbers and notified me when the calculated CRC's matched.
Eventually I want to try to add field weakening. I have seen that it is as simple as increasing the advance angle, but I wonder if the FOC control loop will undo the increase? Since the angle for the lookup table is calculated by the motor specific angle and the FOC correction value. So if the controller goes in the field weakening state, should the FOC angle correction loop be disabled temporarily?
 
OutsMarted said:
I found this with a simple program,
Same advice as every time: read the wiki FAQs. There is a online compiler example, how to find the right XOR value :wink:

https://github.com/stancecoke/BMSBattery_S_controllers_firmware/wiki

regards
stancecoke
 
stancecoke said:
OutsMarted said:
I found this with a simple program,
Same advice as every time: read the wiki FAQs. There is a online compiler example, how to find the right XOR value :wink:

https://github.com/stancecoke/BMSBattery_S_controllers_firmware/wiki

regards
stancecoke

Well it was probably even less work than going to the FAQ, but do you know about the other questions I had in my previous post?
OutsMarted said:
Eventually I want to try to add field weakening. I have seen that it is as simple as increasing the advance angle, but I wonder if the FOC control loop will undo the increase? Since the angle for the lookup table is calculated by the motor specific angle and the FOC correction value. So if the controller goes in the field weakening state, should the FOC angle correction loop be disabled temporarily?
 
OutsMarted said:
So if the controller goes in the field weakening state, should the FOC angle correction loop be disabled temporarily?
no, I would simply add a term that increases the advance angle with speed, if the duty cycle reaches 100%

Saying, tune the angle position, where you are searching for the zerocrossing.
https://github.com/stancecoke/BMSBattery_S_controllers_firmware/blob/18fdd5ce9479425b2fba97a2997f7b2d5f4d27f5/motor.c#L166

regards
stancecoke
 
andrea_104kg said:
centr.jpgNow i find this Little controller. Is It suitable for the new firmware? I want to use at 48... It's right?centr2.jpg
The mosfet of which I can read the text can handle 84V I think, so in that area you are okay, but the capacitors may be 50V rated, I can't really read the rating on them. If they are 50V rated you should upgrade them and maybe also put a bigger resistor in front of the LM317 or change it to a buck converter.
 
OutsMarted said:
andrea_104kg said:
centr.jpgNow i find this Little controller. Is It suitable for the new firmware? I want to use at 48... It's right?centr2.jpg
The mosfet of which I can read the text can handle 84V I think, so in that area you are okay, but the capacitors may be 50V rated, I can't really read the rating on them. If they are 50V rated you should upgrade them and maybe also put a bigger resistor in front of the LM317 or change it to a buck converter.
thanks, I hadn't noticed the capacitors which are actually 50v. I have another problem, I can't find a step down for 48v battery, (54.6v max) unfortunately they are all for a maximum of 40v or they are very large, any ideas? I tried putting a small step up on the 5v line from the ECU but the current is not enough, all the outputs drop to 2.6v :-(
 
andrea_104kg said:
thanks, I hadn't noticed the capacitors which are actually 50v. I have another problem, I can't find a step down for 48v battery, (54.6v max) unfortunately they are all for a maximum of 40v or they are very large, any ideas? I tried putting a small step up on the 5v line from the ECU but the current is not enough, all the outputs drop to 2.6v :-(
There are cheap 120V/90V to 12V 3A modules on aliexpress that are a good fit for this.
Another thing to consider might be the resistor divider to the processor to read the battery voltage.
If you use that functionality you might want to check that you won't burn out a I/O pin.
 
thanks, on italian ebay i find this https://www.ebay.it/itm/403271837007 i hope it works :) on aliexpress i must wait 03/2022 :-(
i don't understend how it's calculated the throttle min and max :-(
for last, mya controller it's sensorless, it's a problem?
 
andrea_104kg said:
thanks, on italian ebay i find this https://www.ebay.it/itm/403271837007 i hope it works :) on aliexpress i must wait 03/2022 :-(
i don't understend how it's calculated the throttle min and max :-(
for last, mya controller it's sensorless, it's a problem?
A lot of people and me use this one:
https://a.aliexpress.com/_vlAJAe and the delivery is like 2-4 weeks for me usually and I live in europe too.
Throttle min and max you can determine in at least three ways. 1. By printing the ADC value (I dont know the name in the code now) or setting throttle min and max to 0 and 255 and then seeing what the momentary_throttle value does. Then you can twist your throttle and view the max value and the min value when the throttle is at the zero position.
2. By looking at the throttle value in the blu osec app and do the same approach as in 1.
3. By measuring the voltage on the throttle at min and max position and then:
Throttle_min=voltage_min/5*255
Throttle_max=voltage_max/5*255

I think this firmware only works for sensored motors, but I dont know for sure.
 
Really many thanks! I also have a sensored controller, the motor has sensors ... I wanted to test with a secondary controller, but I will sacrifice the main controller :) If you are curious you can see the experimentation here (italian) http://www.jobike.it/forum/topic.asp?TOPIC_ID=80959

The engine is a q100h, I saw that in the java program there are settings for the q128 which shouldn't be very different ...
 
Sorry if I'm always asking but the electrical connections are not clear to me. With the step up I feed the torque sensor (red and black wires) then there are the two output wires, white to the accelerator and green to the pas. But I am not clear if you need to make a connection from the step up output (negative) to the black wire of the pas and the accelerator on the control unit .... otherwise the control unit does not detect any voltage ... is that right?
 
andrea_104kg said:
Sorry if I'm always asking but the electrical connections are not clear to me. With the step up I feed the torque sensor (red and black wires) then there are the two output wires, white to the accelerator and green to the pas. But I am not clear if you need to make a connection from the step up output (negative) to the black wire of the pas and the accelerator on the control unit .... otherwise the control unit does not detect any voltage ... is that right?
Usually the step down converter minus is connected to the output minus if it is not an isolated voltage converter. So it will probably work without connecting the output minus, but there may be some resistance in the minus trace of the converter.
 
Hi everybody,

This is my first post on ES, mainly to thank you guys for this great firmware which I've been testing the past few months.

I have a 3k turbo 3T on 48V with KT48SVPRC 18fet.
I have used it up to 100A battery, 200A phase (only short bursts because I am reaching max speed quite fast)

I'd like to share some observations that could be useful :

- I have a KT-LCD1. It works with the firmware, except for the speed wich stays at 0. Thus, it goes into sleep every 5min and stops the controller... So I am now using the controller without LCD.

- Indeed, as reported a few times, the implemented cruise function that can be activated in main.h does not seem to work.
I have coded a new one which acts directly on the throttle input seen by the software (either the real input, or a cruise one).
It works and I can share it if you like.

- I was not suppose to do that but at one point I used the bike without the LCD (by shorting the red and blue wires) when I had programmed it with the KT-LCD3 option. It was a very bad idea, it bugged after a few minutes and did not respond, stuck in full throttle... this was one month ago and I just finished healing :)

- Indeed, as reported before, you cannot replace the mosfets on 18fet and expect it to work right along. I replaced the original mosfets (gate charge 80 nC) with FDP2D3N10C (120 nC) and I burned 3 as soon as I tried throttling a little. It instantly cut power, so I tried to unplug and replug the battery... bad idea again since the + and - of the controller were actually shorted :)
I think the setup needs a lower gate resistor (it seems that the original resistor is 33ohm) or a longer dead time.
I tried with a longer dead time and less mosfets (12), fried again, and putting the original mosfets back, fried again. Seems that the first fry fried more than mosfets, supposedly fried something on the gate driver side of the board...


- On this 18fet controller, the voltage drop in the power resistor before the LM317 is 29V with the open firmware. This means that the voltage provided by the LM317 with an empty battery or a large voltage sag could easily be much lower than 15V, and even lower than 5V, therefore not correctly closing fets... It always worked well for me even with 48V and 10V voltage sag, but it seems very important to replace it with 12/15V buck converter (which I just did).

- I have not been able to use BluOSEC. It seems to connect well with HC-05, but as soon as I power the controller, the app crashes.

- I am currently modifying the controller with 100V caps and mosfets in order to run at 23s li-ion (not fully charged, probably around 90V max). I have cut the metal case in order to solder MLCCs between the + and - buses, along the whole buses (about 50 MLCC, 500 µF total). I hope this will save my mosfets from voltage spikes when I will run 90V and 200A phase :)

Best rides to all :)
 
jm1090 said:
- Indeed, as reported a few times, the implemented cruise function that can be activated in main.h does not seem to work.
I have coded a new one which acts directly on the throttle input seen by the software (either the real input, or a cruise one).
It works and I can share it if you like.
It would be most welcome, thanks.
Cruise control is the only puzzle piece here for me missing to make this a FW of choice.
 
iaval said:
jm1090 said:
- Indeed, as reported a few times, the implemented cruise function that can be activated in main.h does not seem to work.
I have coded a new one which acts directly on the throttle input seen by the software (either the real input, or a cruise one).
It works and I can share it if you like.
It would be most welcome, thanks.
Cruise control is the only puzzle piece here for me missing to make this a FW of choice.
Does the LCD3 also have a cruise feature? I have also made it work again with holding the down button on my LCD8, but I cannot get it to push to github... What could be wrong then?
 
jm1090 said:
- I am currently modifying the controller with 100V caps and mosfets in order to run at 23s li-ion (not fully charged, probably around 90V max). I have cut the metal case in order to solder MLCCs between the + and - buses, along the whole buses (about 50 MLCC, 500 µF total). I hope this will save my mosfets from voltage spikes when I will run 90V and 200A phase :)

Don't forget to replace ADC resistors so that you won't get overvoltage related issues :thumb:

https://endless-sphere.com/forums/viewtopic.php?f=30&t=87870&start=4475#p1661100
 
iaval said:
jm1090 said:
- Indeed, as reported a few times, the implemented cruise function that can be activated in main.h does not seem to work.
I have coded a new one which acts directly on the throttle input seen by the software (either the real input, or a cruise one).
It works and I can share it if you like.
It would be most welcome, thanks.
Cruise control is the only puzzle piece here for me missing to make this a FW of choice.

Ok, here is the modified updateRequestedTorque function in ACAcommons.c that will do cruise.
The comments might not make sense because I might have copy/paste some parts.
It cruises after about 10 secs.
It stops cruising if you reaccelerate of if you brake.


Be careful, it uses the low limit of the throttle voltage input in ADC (ADC_THROTTLE_MIN_VALUE), with a margin of 10, to detect if you have completely released throttle.

You need to precisely measure the high and low voltage of your hall throttle, and enter precisely these corresponding values in the parameter configurator. Otherwise, the cruise function might not detect that you released completely the throttle, and could be stuck in cruise (bad). Or increase margin.

Also, I have this at the beginning of the ACAcommons.c :

#include <stdio.h>
#include <stdint.h>
#include "stm8s.h"
#include "stm8s_itc.h"
#include "stm8s_gpio.h"
#include "config.h"
#include "gpio.h"
#include "adc.h"
#include "ACAcommons.h"
#include "ACAcontrollerState.h"
#include "brake.h"

static uint8_t ui8_temp;
uint32_t ui32_cruise_counter = 0;
uint8_t ui8_adc_read_throttle_mem = 0;
uint8_t ui8_cruise_state = 0;

I think I had to declare more things here than in the original ACAcommons.c (for exemple brake.h I believe), you can check what is added !




void updateRequestedTorque(void) {

if (ui8_cruise_state == 0)
{
ui16_momentary_throttle = (uint16_t) map(ui8_adc_read_throttle(), ADC_THROTTLE_MIN_VALUE, ADC_THROTTLE_MAX_VALUE, 0, SETPOINT_MAX_VALUE); //read in recent throttle value for throttle override

if (((ui16_aca_flags & TQ_SENSOR_MODE) != TQ_SENSOR_MODE)) {
ui16_throttle_accumulated -= ui16_throttle_accumulated >> 4;
ui16_throttle_accumulated += ui8_adc_read_throttle();
ui8_temp = ui16_throttle_accumulated >> 4; //read in value from adc
ui16_sum_throttle = (uint8_t) map(ui8_temp, ui8_throttle_min_range, ui8_throttle_max_range, 0, SETPOINT_MAX_VALUE); //map throttle to limits
} else {

ui16_sum_torque = 0;
for (ui8_temp = 0; ui8_temp < NUMBER_OF_PAS_MAGS; ui8_temp++) { // sum up array content
ui16_sum_torque += ui16_torque[ui8_temp];
}

ui16_sum_torque /= NUMBER_OF_PAS_MAGS;

}

if ((ui8_adc_read_throttle() < ui8_adc_read_throttle_mem + 10) && (ui8_adc_read_throttle() > ui8_adc_read_throttle_mem - 10)){
ui32_cruise_counter++;
if (ui32_cruise_counter > 500){
ui8_cruise_state = 1;
ui32_cruise_counter = 0;
}
}
else{
ui32_cruise_counter = 0;
ui8_adc_read_throttle_mem=ui8_adc_read_throttle();
}
}



else if (ui8_cruise_state == 1)
{

ui16_momentary_throttle = (uint16_t) map(ui8_adc_read_throttle_mem, ADC_THROTTLE_MIN_VALUE, ADC_THROTTLE_MAX_VALUE, 0, SETPOINT_MAX_VALUE); //read in recent throttle value for throttle override

if (((ui16_aca_flags & TQ_SENSOR_MODE) != TQ_SENSOR_MODE)) {
ui16_throttle_accumulated -= ui16_throttle_accumulated >> 4;
ui16_throttle_accumulated += ui8_adc_read_throttle_mem;
ui8_temp = ui16_throttle_accumulated >> 4; //read in value from adc
ui16_sum_throttle = (uint8_t) map(ui8_temp, ui8_throttle_min_range, ui8_throttle_max_range, 0, SETPOINT_MAX_VALUE); //map throttle to limits
} else {

ui16_sum_torque = 0;
for (ui8_temp = 0; ui8_temp < NUMBER_OF_PAS_MAGS; ui8_temp++) { // sum up array content
ui16_sum_torque += ui16_torque[ui8_temp];
}

ui16_sum_torque /= NUMBER_OF_PAS_MAGS;

}

if (brake_is_set()) {ui8_cruise_state = 0; }
else if (ui8_adc_read_throttle() < ADC_THROTTLE_MIN_VALUE + 10) {ui8_cruise_state = 2; }
}




else if (ui8_cruise_state == 2)
{

ui16_momentary_throttle = (uint16_t) map(ui8_adc_read_throttle_mem, ADC_THROTTLE_MIN_VALUE, ADC_THROTTLE_MAX_VALUE, 0, SETPOINT_MAX_VALUE); //read in recent throttle value for throttle override

if (((ui16_aca_flags & TQ_SENSOR_MODE) != TQ_SENSOR_MODE)) {
ui16_throttle_accumulated -= ui16_throttle_accumulated >> 4;
ui16_throttle_accumulated += ui8_adc_read_throttle_mem;
ui8_temp = ui16_throttle_accumulated >> 4; //read in value from adc
ui16_sum_throttle = (uint8_t) map(ui8_temp, ui8_throttle_min_range, ui8_throttle_max_range, 0, SETPOINT_MAX_VALUE); //map throttle to limits
} else {

ui16_sum_torque = 0;
for (ui8_temp = 0; ui8_temp < NUMBER_OF_PAS_MAGS; ui8_temp++) { // sum up array content
ui16_sum_torque += ui16_torque[ui8_temp];
}

ui16_sum_torque /= NUMBER_OF_PAS_MAGS;

}
if (brake_is_set()) {ui8_cruise_state = 0; }
else if (ui8_adc_read_throttle() > ADC_THROTTLE_MIN_VALUE + 20) {ui8_cruise_state = 0; }

}



//CRUISE END
}
 
iaval said:
jm1090 said:
- I am currently modifying the controller with 100V caps and mosfets in order to run at 23s li-ion (not fully charged, probably around 90V max). I have cut the metal case in order to solder MLCCs between the + and - buses, along the whole buses (about 50 MLCC, 500 µF total). I hope this will save my mosfets from voltage spikes when I will run 90V and 200A phase :)

Don't forget to replace ADC resistors so that you won't get overvoltage related issues :thumb:

https://endless-sphere.com/forums/viewtopic.php?f=30&t=87870&start=4475#p1661100

Oh yeah, would have definitely missed that, thank you :)
 
jm1090 said:
- Indeed, as reported before, you cannot replace the mosfets on 18fet and expect it to work right along. I replaced the original mosfets (gate charge 80 nC) with FDP2D3N10C (120 nC) and I burned 3 as soon as I tried throttling a little. It instantly cut power, so I tried to unplug and replug the battery... bad idea again since the + and - of the controller were actually shorted :)
I think the setup needs a lower gate resistor (it seems that the original resistor is 33ohm) or a longer dead time.
I will soon try to increase dead time from 1 to 2 µs, without changing resistors. I have removed the dead mosfets, and now I have only 12 mosfets soldered, so that should help with gate charge.

So I tried to turn on the controller with 12 mosfets soldered only, and with 2 µs dead time instead of 1... failed again, popped mosfets again :D

I believe there is more to it than only a gate charge problem...
FDP2D3N10C and CSD19530KCS don't seem to work on KT48 18fet...

I see that IRFB4110 seem to be used on KT72 18 fet. Maybe IRFB4110 would also work on KT48 18fet, despite the higher gate charge...
 
jm1090 said:
iaval said:
jm1090 said:
- I am currently modifying the controller with 100V caps and mosfets in order to run at 23s li-ion (not fully charged, probably around 90V max). I have cut the metal case in order to solder MLCCs between the + and - buses, along the whole buses (about 50 MLCC, 500 µF total). I hope this will save my mosfets from voltage spikes when I will run 90V and 200A phase :)

Don't forget to replace ADC resistors so that you won't get overvoltage related issues :thumb:

https://endless-sphere.com/forums/viewtopic.php?f=30&t=87870&start=4475#p1661100

Oh yeah, would have definitely missed that, thank you :)
Thanks for the writeup :bigthumb:
I'm not at my test rig, but I'll give it a spin later.
Two questions tho - would it be difficult to modify it so that it disengages once pedalling stops (no PAS input), as well as the first two conditions (brake+throttle position change)?

And also have you noticed any throttle lag with DD motor?
 
Back
Top