The Alpha Geek – Geeking Out

Project #24 – RTOS – FreeRTOS – Mk01

——

#DonLucElectronics #DonLuc #ESP32 #RTOS #FreeRTOS #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

FreeRTOS

——

FreeRTOS

——

FreeRTOS

——

Real-Time Operating System

A real-time operating system (RTOS) is an operating system for real-time applications that processes data and events that have critically defined time constraints. A RTOS is distinct from a time-sharing operating system, such as Unix, which manages the sharing of system resources with a scheduler, data buffers, or fixed task prioritization in a multitasking or multiprogramming environment. Processing time requirements need to be fully understood and bound rather than just kept as a minimum. All processing must occur within the defined constraints. Real-time operating systems are event-driven and preemptive, meaning the OS is capable of monitoring the relevant priority of competing tasks, and make changes to the task priority. Event-driven systems switch between tasks based on their priorities, while time-sharing systems switch the task based on clock interrupts.

FreeRTOS

FreeRTOS is a real-time operating system kernel for embedded devices that has been ported to 35 microcontroller platforms. It is distributed under the MIT License. FreeRTOS is designed to be small and simple. It is mostly written in the C programming language to make it easy to port and maintain. It also comprises a few assembly language functions where needed, mostly in architecture-specific scheduler routines.

FreeRTOS is ideally suited to deeply embedded real-time applications that use microcontrollers or small microprocessors. This type of application normally includes a mix of both hard and soft real-time requirements. Soft real-time requirements are those that state a time deadline, but breaching the deadline would not render the system useless. For example, responding to keystrokes too slowly might make a system seem annoyingly unresponsive without actually making it unusable.

DL2210Mk02

1 x Adafruit HUZZAH32 – ESP32 Feather
1 x 100K Potentiometer
1 x Knob
1 x SparkFun Cerberus USB Cable

ESP32 Feather

PO0 – Analog A0
LED – Digital 13
VIN – +3.3V
GND – GND

DL2210Mk02p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #24 - RTOS - FreeRTOS - Mk01
24-01
DL2210Mk02p.ino
1 x Adafruit HUZZAH32 – ESP32 Feather
1 x 100K Potentiometer
1 x Knob
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// FreeRTOS ESP32
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif

// Led Built In
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif

// Define two tasks for Blink & AnalogRead
void isTaskBlink( void *pvParameters );
void isTaskAnalogReadA0( void *pvParameters );

// Software Version Information
String sver = "24-01";

void loop() {

  // Empty
  // Things are done in Tasks
  
}

getTasks.ino

// Tasks
// This is a Task Blink
void isTaskBlink(void *pvParameters)
{
  
  (void) pvParameters;

  // Blink
  // Turns on an LED on for 2 second, then off for 2 second, repeatedly

  // Initialize digital LED_BUILTIN on pin 13 as an output.
  pinMode(LED_BUILTIN, OUTPUT);

  // A Task shall never return or exit
  for (;;) 
  {
    
    // Turn the LED on (HIGH is the voltage level)
    digitalWrite(LED_BUILTIN, HIGH);
    // One tick delay in between reads
    vTaskDelay(2000);
    // Turn the LED off by making the voltage LOW
    digitalWrite(LED_BUILTIN, LOW);
    // One tick delay in between reads
    vTaskDelay(2000);
    
  }
  
}
// This is a Task Analog Read Serial
void isTaskAnalogReadA0(void *pvParameters)
{
  
  (void) pvParameters;
  
  // Analog Read Serial
  // Reads an analog input on pin A0, prints the result to the serial monitor

  for (;;)
  {
    
    // Read the input on analog pin A0
    int sensorValueA0 = analogRead(A0);
    // Print out the value you read
    Serial.print( "Pot A0: " );
    Serial.println(sensorValueA0);
    // One tick delay (15ms) in between reads for stability
    vTaskDelay(100);
    
  }
  
}

setup.ino

// Setup
void setup() {

  // Initialize serial communication
  // at 115200 bits per second
  Serial.begin(115200);
  
  // Now set up two tasks to run independently
  // TaskBlink
  xTaskCreatePinnedToCore(
    isTaskBlink
    ,  "TaskBlink"   // A name just for humans
    ,  1024  // This stack size can be checked & adjusted by reading.
    ,  NULL
    ,  2  // Priority, with 2 being the highest, and 0 being the lowest.
    ,  NULL 
    ,  ARDUINO_RUNNING_CORE);
  
  // AnalogReadA0
  xTaskCreatePinnedToCore(
    isTaskAnalogReadA0
    ,  "AnalogReadA0"
    ,  1024  // Stack size
    ,  NULL
    ,  1  // Priority
    ,  NULL 
    ,  ARDUINO_RUNNING_CORE);

  // Now the task scheduler, which takes over control of scheduling individual tasks,
  // is automatically started.
  
}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

J. Luc Paquin – Curriculum Vitae – 2022 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories
Archives