Skip to content
Anatoli Arkhipenko edited this page Mar 18, 2020 · 49 revisions

Welcome to the TaskScheduler wiki!


Big Thank you to:

Doanh Văn Lương (aka tarzan115) for creating this wiki based on my documentation! (I always wanted to do it, and always did not find the time.)

And to Uri Shaked for creating Wokwi - an online Arduino learning platform and TaskScheduler playground.

Learn TaskScheduler by experimenting here: Traffic Light with TaskScheduler


Task Scheduler

Cooperative multitasking for Arduino microcontrollers

OVERVIEW:

A lightweight implementation of cooperative multitasking (task scheduling) supporting:

  1. Periodic task execution, with dynamic execution period in milliseconds (default) or microseconds (if explicitly enabled) – frequency of execution
  2. Number of iterations (limited or infinite number of iterations)
  3. Execution of tasks in predefined sequence
  4. Dynamic change of task execution parameters (frequency, number of iterations, callback methods)
  5. Power saving via entering IDLE sleep mode when tasks are not scheduled to run
  6. Support for event-driven task invocation via Status Request object
  7. Support for task IDs and Control Points for error handling and watchdog timer
  8. Support for Local Task Storage pointer (allowing use of same callback code for multiple tasks)
  9. Support for layered task prioritization
  10. Support for std::functions (ESP8266 only)
  11. Support for overall task timeouts
  12. Static and dynamic callback method binding
  13. CPU load / idle statistics for time critical applications

Scheduling overhead: between 15 and 18 microseconds per scheduling pass (Arduino UNO rev 3 @ 16MHz clock, single scheduler w/o prioritization)

Memory requirements: 46 bytes (plain vanilla), 57 bytes (IDLE sleep, WDT and LTS pointer support). Other options have similar memory footprints.

TaskScheduler was tested on the following platforms:

  • Arduino Uno R3
  • Arduino Nano
  • Arduino Micro
  • ATtiny85
  • ESP8266 (Node MCU v2.0)
  • Teensy (tested on Teensy 3.5)
  • STM32F1 (tested on Mini USB STM32F103RCBT6 ARM Cortex-M3 leaflabs Leaf maple mini module F)

TaskScheduler process diagram

Change log

Check the changes here

Table Of Content:

  1. Concept of Task and Cooperative Task Scheduling

  2. API documentation

  3. Implementation scenarios and ideas
    1. Event driven programming
    2. "Native" support for finite state machine
    3. Multiple possible callbacks for task
    4. Interrupt-driven execution support
    5. Using onEnable and onDisable methods
    6. Using status request objects
    7. Using local task storage pointer
    8. Enabling task prioritization

  4. Futher information
    Please refer to examples, provided with TaskScheduler package for further information and implementation options.

    Real time examples of TaskScheduler are available here:

    1. http://www.instructables.com/id/APIS-Automated-Plant-Irrigation-System/
    2. http://www.instructables.com/id/Wave-your-hand-to-control-OWI-Robotic-Arm-no-strin/
    3. http://www.instructables.com/id/Arduino-Nano-based-Hexbug-Scarab-Robotic-Spider
    4. http://www.instructables.com/id/Interactive-Predator-Costume-With-Head-Tracking-Pl/
    5. https://www.instructables.com/id/Portable-Party-Lights/