Wednesday, August 3, 2022
HomeElectronicsIntroducing multitasking to Arduino | Arduino Weblog

Introducing multitasking to Arduino | Arduino Weblog


Introducing multitasking to Arduino

Alessandro RanellucciAugust 2nd, 2022

With the elevated capabilities of Arduino and different microcontroller boards, together with quicker clocks and even a number of cores, the necessity to deal with a number of duties concurrently arises extra typically than prior to now. As an example, you typically need to management motors, replace a show and detect consumer interactions on the similar time, or carry out duties which have completely different timing or await exterior occasions.

The normal manner to do that is to write non-blocking code in order that the loop() perform can run as quick as doable, updating state variables and calling the millis() perform to make sure correct timing (see the “Blink immediately” instance to be taught extra). This method results in bloated code, although, which is difficult to debug and keep, and in addition doesn’t help a number of cores.

The Scheduler library already permits writing code in a cleaner manner by splitting the sketch in a number of loop capabilities, so that every one can concentrate on a particular activity. Nevertheless, this method is known as cooperative multitasking, which implies you continue to have to keep away from blocking instructions your self. Additionally, it doesn’t help a number of cores and even when it did it doesn’t defend you from accessing the identical variables from a number of threads. Final however not least, it’s based mostly on the normal “busy loop” paradigm, which doesn’t actually assist for low energy functions the place you need to have threads relaxation as a lot as doable whereas ready for an occasion or incoming information.

How you can add multitasking to Arduino?

The purpose is to outline a standardized API that may be ported throughout all architectures and that, in step with the Arduino philosophy, will make complicated issues simple for anybody. Multitasking is a tough idea, so right here now we have loads of margin to carry the Arduino method to make this accessible to everybody.

We’re asking our technical neighborhood to be a part of the dialogue on GitHub, and we’re sharing our API proposal together with a completely working implementation as properly. Tell us your ideas and let’s work collectively to finalize this new characteristic!

This neighborhood dialogue is hosted inside the model new repository, which is the brand new house for the evolution of the Arduino language.

You’ll be able to observe any responses to this entry by means of the RSS 2.0 feed.
You’ll be able to go away a response, or trackback from your personal web site.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments