At this stage, I would like to finalise some changes before moving some code in separate files and use conditional #include.
This could probably be done but take care that later on, I expect to remove all those options and just keep the best one.
I created the new options (#define) to allow to test each new functionality one by one so, better isolate bugs.
About lead angle: In principe lead angle should increase with speed (erps) and with current. In main branch, only current was taken into account. In TSDZ2, it was based on (1/2 * current + 1/2 current /duty_cycle). Here I consider than duty cycle varies logically from 0...1 (in fact it varies from 0 to 255 because OSF does not manage fractional).
In my new version with DYNAMIC LEAD_ANGLE = 2, I plan to set a basis value based on erps and the ESC should adjust slightly.
At this stage, I do not focuss to much on lead angle. I would already be happy if the motor runs with the new code (increasing precision of rotor position) and with no pll, no dynamic hall positioning, no dynamic lead angle.
When this works, we can test the option in a wel defined sequence.
About the value of current: I was not able to compare the real current with the values provided by OSF. For TSDZ2, mbrusa made test and saw that to convert ADC (10bit) to Amp, he add to multiply by 16 and divide by 100. I first did the same for TSDZ2 (still reducing the ADC from TSDZ8 from 12 bits to 10bits to keep the same ratio). Ebikestuff made tests (at the very beginning of OSF TSDZ8) and he said that the values provided by OSF matches the real measurements he made. That is why I kept this ratio. If you now see that the values does not matches, best is to change the ratio that is defined in main.h
#define BATTERY_CURRENT_PER_10_BIT_ADC_STEP_X100 16 // 0.16A x 10 bit ADC step
This could probably be done but take care that later on, I expect to remove all those options and just keep the best one.
I created the new options (#define) to allow to test each new functionality one by one so, better isolate bugs.
About lead angle: In principe lead angle should increase with speed (erps) and with current. In main branch, only current was taken into account. In TSDZ2, it was based on (1/2 * current + 1/2 current /duty_cycle). Here I consider than duty cycle varies logically from 0...1 (in fact it varies from 0 to 255 because OSF does not manage fractional).
In my new version with DYNAMIC LEAD_ANGLE = 2, I plan to set a basis value based on erps and the ESC should adjust slightly.
At this stage, I do not focuss to much on lead angle. I would already be happy if the motor runs with the new code (increasing precision of rotor position) and with no pll, no dynamic hall positioning, no dynamic lead angle.
When this works, we can test the option in a wel defined sequence.
About the value of current: I was not able to compare the real current with the values provided by OSF. For TSDZ2, mbrusa made test and saw that to convert ADC (10bit) to Amp, he add to multiply by 16 and divide by 100. I first did the same for TSDZ2 (still reducing the ADC from TSDZ8 from 12 bits to 10bits to keep the same ratio). Ebikestuff made tests (at the very beginning of OSF TSDZ8) and he said that the values provided by OSF matches the real measurements he made. That is why I kept this ratio. If you now see that the values does not matches, best is to change the ratio that is defined in main.h
#define BATTERY_CURRENT_PER_10_BIT_ADC_STEP_X100 16 // 0.16A x 10 bit ADC step
