Closed jalinei closed 1 month ago
Testing should be done to check if #57 is solving this High priority issue.
I have tested the frequency with the Setting multiple PWM
code.
There is still a behavior that is left:
spin.pwm.initFrequency(frequency);
, the frequency
value given is the minimum. Here's the prescaler information
After some testing, I cannot get the frequency to be lower than 10kHz. If I start at 10kHz, I cannot raise the frequency above 190kHz.
At 20kHz I cannot go beyond 383kHz At 50kHz I cannot go beyond 957kHz At 200kHz I cannot go beyond 3831kHz
Experimentally, I find that the maximum frequency is 19.15 times higher than the minimum frequency.
At 50kHz I cannot go beyond 957kHz At 200kHz I cannot go beyond 3831kHz
This behaviour seems normal to me Luiz. We do need to test wether the control task is succesfully launched or nor in the interval specified in initFrequency. [minimal_frequency, maximal_frequency].
What I understand from your comment is that we should clarify the capabily and spread of the upper frequency bound. This can be discussed in a separate issue and IMO without the "high priority" tag.
However here I expect that we conclude wether or not the control task correctly triggers in "reasonable" bounds let say between 20kHz to 200kHz, that for any multiple of the carrier frequency we do enter the critical task.
The PWM does not start below 10kHz
Initfrequency has no "upper bound". The frequency given to it creates the "lower bound" but that is it.
void PwmHAL::initFrequency(uint32_t init_frequency)
+1 overload
This function initialize the frequency
Parameters:
init_frequency – frequency in Hz
Warning:
this function must be called BEFORE initialiazing any timing unit. the frequency initialized becomes the MINIMUM possible. use it BEFORE initialization of the timing unit.
We can add in the documentation that the maximum frequency is 19.15 times the initial frequency.
I worked on the test a little further. Instead of using the serial port, I use the LED to test that the critical task is working. I get a blinking led that becomes faster over time and stops after a while. This is due to the fact that when the critical task is initialized, the micro-controller calculates the number of master reset repetition it needs for calling the critical task. Whenever the critical task becomes too fast, this become an issue.
Initfrequency has no "upper bound". The frequency given to it creates the "lower bound" but that is it.
void PwmHAL::initFrequency(uint32_t init_frequency) +1 overload This function initialize the frequency Parameters: init_frequency – frequency in Hz Warning: this function must be called BEFORE initialiazing any timing unit. the frequency initialized becomes the MINIMUM possible. use it BEFORE initialization of the timing unit.
If you set two arguments in pwm.initFrequency(freq_low, freq), the prescaler is calculated in a way that the range [freq_low, freq] can be obtained. It is true that freq is not really the "real" upper bound, but the pwm should be able to output a signal with a frequency between [freq_low, freq] without any guarantee above that range. I do not see the inconvenient with that approach.
I tried again and the init frenquency works down to 650Hz with the critical task working fine.
Summary of our discussion on the matter. We currently miss:
We should provide the user with the necessary data in our code and information in our documentation.
From the current code we can retrieve most of the information. The only information missing is the resolution.
I've updated the hrtim driver and the pwnHAL to retrieve all the data that is listed above. This is treated by commits 57e0b1a , f420184 and 9a7420e
Major issue that derives from https://gitlab.laas.fr/owntech/power-api/core/-/issues/57
We should check that
pwm
engine is correctly running at any frequency ifcriticalTask
source issource_tim6
Only 200Khz was tested with SPIN and TWIST
scheduling_define_uninterruptible_synchronous_task
returns-1
for all kind of problems which makes debugging non trivial.criticalTask
is not an integer multiple of thepwm
source_pwm
in the javadocs snippet.source_pwm
frequencycriticalTask
frequencyIt has to be clearly documented that PWM carrier can not be slower than
criticalTask
frequency if HRTIM iscriticalTask
clock source. This issue is also midly linked with #32