-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Description
At control task rates above 50kHz and PWM frequency rates close to that of the control task (such that a timing manager event ratio is set to 1), the run-time of the control task is significantly higher than it should be.
Details
There's some sort of issue with the timing manager (or perhaps statistics reporting) that causes the runtime of a task to increase significantly with certain timing manager + pwm frequency configurations.
This was tested on the controller task from the VSI tutorial.
The runtime for this task should be around 3.5us, but in some cases it is much higher (as demonstrated in this PR thread)
I did additional testing with other PWM frequencies to see where this bug occurs (with an event ratio of 1, and TASK_UPDATES_PER_SEC set to 10kHz).
Tested PWM frequencies:
250kHz - Run Mean is 22.8us
110kHz - Run Mean is 16.6us
105kHz - Run Mean is 10.2us
100kHz - Run Mean is 10.1us
95kHz - Run Mean is 10.1us
94kHz - Run Mean is 10.1us
93kHz - Run Mean is 8.4us
92kHz - Run Mean is 3.5us
91kHz - Run Mean is 3.5us
50kHz - Run Mean is 3.5us
Additional testing has confirmed that if PWM Frequency / Timing manager event ratio > 93kHz, then this bug occurs, and the severity of it appears to be somewhat linear with the PWM Frequency. (That is, having 250kHz PWM and 2 as timing manager event ratio yields a Run Mean of 22.8us still, because 250 / 2 > 93, and the timing manager event ratio has no effect on the linear scaling of this bug).
Actually, it is more like 22.4us with an event ratio of 2 (and 250kHz). Not sure what to make of any of this information.
The bug does not appear to be caused by calling analog_getf(ANALOG_IN5, &LOG_current_a); inside the control loop code. Removing the calls to analog_getf did not have impact on the severity of the bug (though it did change the runtime, but not in a way that fixed the bug at least at high PWM frequencies, did not do full testing at lower PWM frequencies).