multi-tasking with mega?

Hi,

I see in this forum topic /YaBB.pl?num=1198250369/4
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:
thanks
Dave

background:
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
devices:
one timer
digital input to read radio-control-servos settings (PWM input for course change)
outputs:
update heading target variable

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

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

outputs:
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
devices:
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.