FreeRTOS with multiple loop() calls

My application calls for 4 Arduinos. (I am using 4 Seeeduinos XIAO.) I plan on using the same sketch for all Seeeduinos; but they all do partially different things. Each one has a dedicated section within the sketch. Like this I have only one master sketch and do not have to remember what sketch goes with what Seeeduino, and can just upload the same sketch to each of them. I sacrifice a pins V read to assign the type of work it has to perform. The 4 assignments are as follows: GND, 3.3V, 0.4V, and 0.6-3.1V.

I started reading about interrupt pins, registers, over-clock behaviors before discovering FreeRTOS. (In my case it would be #include <Seeed_Arduino_FreeRTOS.h>) But before I dive into coding, is there anything to look out for in structuring my sketch in such a way? I guess my question is: is FreeRTOS somewhat smart, or am I asking for trouble structuring it as such?

FreeRTOS manual is 400 pages long
Lots of new things to learn.
Search for Digikey's Introduction to RTOS series of 12 lessons with code examples.
Personally I just use simple multi-tasking unless there is a pressing need for RTOS
OR
unless you are just keen to learn RTOS

This does not require an RTOS. Just use millis() to determine when to do the functions you need. Make any delay() functions are implemented using millis().

Arduino Multiple Things

I have used this technique for some rather sophisticated applications on the Arduino.

I am trying to get a distance sensor (vl53l0x) and a motor (tb6600) to run together on the same chip -- see post: Arduino single core limitation driving VL53L0X and TB6600 together

For right now it looks like it would just be easier to add another chip. I am not well versed with the SPI interface and how it taxes the chip. Also the motor needs to run at a higher seep.

That just complicates things more.

Multi-tasking in Arduino has a complete stepper example that is controlled by user input and a sensor. Give that a try.
multitaskingDiagramSmall

Almost always said by beginners and almost always it is not. Adding an extra processor should be something you do as a last resort, because it is just insufficient experience / knowledge that is bringing you to that conclusion. It is often a sign that you are tackling a project that is too advanced for your current state of knowledge.

1 Like

Same applies to the concept of an RTOS. :face_with_raised_eyebrow:

2 Likes