multi-tasking with mega?


I see in this forum topic /
that freertos requires quite a bit of memory...
But given the 8k RAM on the mega it seems like a collection of 4 or 5 tasks might be a reasonable approach to my problem ...

I am after comments and advice :slight_smile:

Objective - sail-by-wire model boat (to try different techniques for control, trim etc)

Rough idea of task assignment and devices..
Task 1: monitor radio-control channels for course correction/adjustment
one timer
digital input to read radio-control-servos settings (PWM input for course change)
update heading target variable

Task 2: monitor boat heading, heal, velocity and location - set control corrections.
accelerometer (SPI interface)
maybe compass (UART interface)
maybe gps (UART interface)

given acceleration (heel) and sail position and desired change of course is it possible? [yes, requires tack]

Directly adjusts foil angles (rudder, daggerboard) by servos via PWM.

Set target on winches; take in, let out, hold.

2 or 3 winches...
task 3: main sail
task 4: jib sail
task 5: ballast location
three digital outputs: direction, enable, drive
(maybe) analogue input: tension sensor
(maybe) digital input: position coding
Using feedback take-in or release line to achieve control changes..

later: some layouts require winches operating against each other, one controlling, the other just maintaining minimum tension to avoid tangles..

Google the Timer3 library. It will trigger interrupts at a given interval. With enough creative coding (and interrupts), it may just work. Trust me, I've had similar problems doing a lot of stuff at once with my Mega.