Skip to content

Repository files navigation

2026-Controls_Nacelle

Nacelle specific code fore 2026 Controls .

Actions Status

Dependabot Updates

Generate Documentation

PlatformIO CI

Releases & Demos

For releases and prepared demos, please see the Releases section.

How the code "works" & FreeRTOS

A number of function prototypes are defined include\NacelleTasks.hpp. These correspond to FreeRTOS tasks, which are comparable to threads.

Fun fact: Espressif had reimplemented the C++ std::thread library on top of FreeRTOS tasks.

For example, here is the function prototype for the task that updates the finite state machine:

/**
 * @brief Task to control run the FSM
 */
[[noreturn]] void vTaskUpdateFSM([[maybe_unused]] void *pvParameters);

Here is the full list of tasks:

  • The finite state machine, as seen in the FSM diagram: Finite State Machine
  • Poll sensors, such as the encoder in the nacelle
  • Adjust the pitch (actuator)
  • Process received data. Since we don't have a lot of control over the internal WiFi task, we didn't want to slow down the rx callback. Instead it just copies the data to a FreeRTOS queue. This tasks then treats the data like a struct and processes it, copying the data into the appropriate variables (stored in NacelleContainer.hpp)
  • Send data
  • We never finished writing the configure tasks, but the idea would be for it to recall any setup code for broken sensors and the like.
  • LED - flash the LED so that we know it's still working without using too much power
  • LOG - write data to terminal
  • We never added Telnet support, but this task would have ran the Telnet server's main loop
  • We never added over the air support, but this task would have ran the OTA sever's main loop

The data type TaskInfo and a number of function prototypes are defined in include\NacelleTasks.hpp. TaskInfo is used to keep track of one task over the operation of the turbine. An etl::array of these in NacelleContainer.hpp keeps track of all of them, which can be indexed into using the MAIN_TASK_IDS enum found in the same header. This makes it "easy" to get the FreeRTOS handle in order to suspend or resume the task, as well as to create them in the first place. In fact xTaskCreate is only found once in the code: in the Arduino setup() function in main.cpp. Since TaskInfo contains everything needed to create a new task, the setup() "simply" loops through the previously mentioned array of TaskInfo structs, calling xTaskCreate on each.

Folder/ Directory Structure

  • .devcontainer - Microsoft Devcontainer config
  • .github - GitHub config
  • .idea - CLion config
  • .pio - Platformio stuff
    • build - Platformio build directory
    • libdeps - Platformio libraries
  • .PVS-Studio - PVS Studio stuff
  • .vscode - VSCode config
  • boards - Custom board definitions
  • demos - Nacelle specific demos, Arduino compatible for ease of use
    • ActuatorDemo - Manually control the actuator
    • CommunicationDemos - Comms demo and MAC Address getter
    • EncoderDemo
    • NacelleDemo - Manually control the actuator
  • docs - documentation
    • config - Doxygen config
    • cpp - Notes on C++
    • doxygen-out - Autogenerated Doxygen API dos
    • Miscellaneous Windows Scripts/ batch files (.bat)
  • include - Miscellaneous header files
    • Encoder.hpp
    • NacelleConfig.hpp - Nacelle specific configuration
    • NacelleContainer.hpp - Hold shared variables
    • NacelleFSM - Finite state machine implementation for the nacelle
    • NacelleTasks.hpp - FreeRTOS task function declarations and related datatypes
  • lib - Private libraries
  • logs - Log files from the serial console / monitor
  • src - Miscellaneous source files
  • test - Where tests would go if he had them
  • platformio.ini - Platformio config
  • MISRA - Rules for automotive code quality

Related Repositories