Is it possible to do multitasking in arduino
Is it possible to do multitasking in arduino
Hi Al,
There are a few projects for Arduino RTOS if you google it. Also you can use timer interrupt to perform tasks like this one
http://chrisbarlow.wordpress.com/2012/09/13/reliable-task-scheduling-with-arduino-avr/
However Arduino's (depending which board) resources is too limited to do multitasks (depending on what kind of task you are doing). Sometime a properly designed pooling method in a loop works better. It all depends on what you want to do.
Cheers
JP
Hi Al,
There are a few projects for Arduino RTOS if you google it. Also you can use timer interrupt to perform tasks like this one
http://chrisbarlow.wordpress.com/2012/09/13/reliable-task-scheduling-with-arduino-avr/
However Arduino's (depending which board) resources is too limited to do multitasks (depending on what kind of task you are doing). Sometime a properly designed pooling method in a loop works better. It all depends on what you want to do.
Cheers
JP
Its software so you can design a piece of code that can essentially multitask by executing a chunk of task for some time and then move to the next task. This is called scheduling and is an OS concept. In microcontroller what me experience is that you are looking to do simple things like receive UART Data, run an LCD, read some sensors, write to a memory card etc etc and you are possibly confused as to how you can make sure everything happens correctly. There are a couple of ways to do this:
1. an RTOS. A piece of code which will manage things for you. Loads of info available and the advantage is that they reduce complexity(somewhat) but have the disadvantage that you need to have some knowledge on the subject and then how to use and if you have enough space. etc. For a lot of complicated tasks this approach is preffered.
2. Interrupts: mircontrollers have interrupts that allow you to execute pieces of code when an even happens e.g. button pushed. pin toggle, usart byte is received, a timer overflows(you set the time interval). This is good enough for a lot of small tasks. Things that can be automated are usually put on interrupts while one or two tasks are put in the main loop. You need to be careful how you configure things because sometimes you end up with bad code that makes your application "stuck" somewhere.
3. Interrupts and state machines: You can write state machine code that is basically saying DIY Scheduler. This is simpler that it seems that there are a good number of books that show you how to write the right code. You can use a time to trigger the SM to jump between tasks but then again it depends on how you like to code.
In Summary I can say that it is possible in a variety of ways but unless you specify your exact intentions, I cannot revert with a definite answer.
Hope this helps.
Cheers,
IP