stancecoke said:
I think you know the documentation of Shane Colton? He describes the determination of the best advance angle from the motor characteristics in detail on pages 48ff.
https://github.com/EGG-electric-unicycle/documentation/blob/master/Shane_Colton/3phduo.pdf
I think will work as a triangle, with sides: V, IwL and (E + IR). I would go with sides V and IwL and that way, Sin teta = IwL / V.
I = (ADC_current*ADC_step)/duty_cycle
w = 6.2831853 * motor_ERPS
L = measure value specific to motor
V = duty_cycle * battery_voltage
Sin-1 ((ADC_current*ADC_step)/duty_cycle * 6.2831853 * motor_ERPS * L) / (duty_cycle * battery_voltage) = teta
where Sin-1 will be stored in a table.
I did put on the STM8 running at 16MHz, with nothing more running on background, it took 775us to do a similar long operation using floats:
Code:
f_8 = (f_1 * f_2 * f_3 * f_4 * f_5) / (f_6 * f_7);
f_8 = f_1 * f_8;
So, if STM8 is busy 66% of time, it may take about 2.5ms to do it. This means that in worst case scenario, at 4000 RPMS, 1 ERPs = 1.875ms, so we could adjust the angle at least every 2 ERPs. This is not far from Kunteng KT controllers, were we do the FOC only every 1 ERPs.
Even some of that operations may be done with integers 32 bits and that will boost 10x, which may mean we can have the same results as Kunteng KT controllers.
Does it make sense??