Page 1 of 1

Chibios vs. Control Application what setup gives max speed

Posted: Thu Aug 21, 2014 9:58 am
by tecnologic
Hi All,

my current project is a motion control application for my master thesis. i have a 32kHz PWM runninig triggering the ADC (Thanks Giovanni, this works now :)). Every second cycle of the ADC measurering the ADC callback is called and signals an binary semaphore. The semaphore releases a task which calculates the control loop. This works fine so far on an STM32F3.

My Chibios is set up V3 standard with tickless mode. I thought when i get context switches with 16kHz why have a Systick permanently running. But i think Tickless mode is slower in context switching times due to the more complex scheduleing logic am i right?

Would i gain overall execution time when i setup lets say a 100Hz fixed Tick? Cause the rest of my application has no real need for performance.

I would like to stay with the setup with the sem triggering a control thread, to me it seems a good architecture, to give the os the control of this. If not i would have a 20µs and longer highest priority Interrupt, which whould be out of reach for the Os. And i would kill my Serial communication and other low prio things.

So how to setup the os correctly for a high freqency control algorithim?

Regards

Tec

Re: Chibios vs. Control Application what setup gives max spe

Posted: Thu Aug 21, 2014 3:00 pm
by Giovanni
Hi,

Context switch should not be affected, there is a performance loss (very limited) where virtual timers are used only, when setting a timer for timeouts for example. The system overall should be more efficient because MUCH less interrupts are server, the jitter is greatly reduced.

Try the benchmarks, I decided to make tickless the default after testing in both modes.

Giovanni

Re: Chibios vs. Control Application what setup gives max spe

Posted: Thu Aug 21, 2014 4:07 pm
by tecnologic
OK, i'am not realy familiar with tickless mode inner workings so i thought the contextswitch ould be more complex.
So then CH_CFG_ST_FREQUENCY is only the freqency used for the rt timer for the os timings, so increesing or decreesing has no performance benefit?

Is there an good paper or article how tickless switching is done?

My understanding is that u queue all os events and set the timer to the next time the os needs to handle an event?
I think is STM32 Ports u used TIM2 for this, why not the systick?

Thanks

Tec

Re: Chibios vs. Control Application what setup gives max spe

Posted: Thu Aug 21, 2014 4:13 pm
by Giovanni
The kernel knows what are the next events because it has an ordered list of active timers. Instead of having an interrupt for each tick, the interrupt is scheduled directly to the next known event.

The only problem is the system time itself, without a system tick the variable cannot be incremented, this is why the systick mode uses an HW counter as system time.

The systick timer is too limited and cannot implement the feature, it is meant only for fixed ticks.

Giovanni

Re: Chibios vs. Control Application what setup gives max spe

Posted: Thu Aug 21, 2014 4:50 pm
by tecnologic
Ok Thanks for the explanation, then i was not completly wrong with my assumptions.

Regards

Tec