Skip to content

jibril04Afaa/smart_fan_controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distributed Smart Fan Controller

A multi-node, RTOS-driven embedded system designed to mirror modern automotive Electronic Control Unit (ECU) architectures.


Table of Contents


System Architecture

The system is distributed across two microcontrollers, separating high-level system logic from low-level hardware actuation:

Node 1: Main Controller (STM32)

  • Environment: FreeRTOS
  • Responsibilities:
    • Input Handling: Reads and software-debounces user push buttons.
    • State Management: Drives a 4-state Finite State Machine (FSM): OffLowHighAuto.
    • UI/Feedback: Updates status LEDs based on the current system state.
    • Bus Communication: Frames and transmits control commands over the UART bus.

Node 2: Motor Actuator (Raspberry Pi Pico)

  • Environment: Bare-metal C (RP2040 SDK)
  • Responsibilities:
    • Bus Listener: Parses incoming UART frames from the STM32.
    • Actuation: Maps commanded percentage (0-100%) to a hardware PWM duty cycle to drive a DC motor.

The Link: Physical Communication Bus

  • Hardware: UART
  • Protocol: Custom framed packets consisting of [Header | Payload | Checksum].
  • Performance: < 5ms round-trip latency.

Fault Tolerance & Hardening (Phase 4)

This project goes beyond simply spinning a motor by implementing production-grade edge case handling:

  • Communication Timeouts: The STM32 actively monitors the bus. If the physical wire is unplugged, the system safely transitions to an error state.
  • EMI / Noise Rejection: The bare-metal Pico parser validates a checksum on every incoming packet. If electrical noise from the DC motor corrupts a byte, the packet is safely discarded to prevent erratic motor behavior.

Hardware Setup

To establish the physical communication link between the two nodes, wire them as follows:

STM32 (Node 1) Raspberry Pi Pico (Node 2) Purpose
UART TX UART RX Transmit commands to Pico
UART RX UART TX Receive acknowledgments (optional)
GND GND Critical: Common ground reference

Repository Structure

smart-fan-controller/
├── shared/                 # Shared protocol header (Single Source of Truth)
│   └── comms_protocol.h
├── node1_stm32_main/       # STM32CubeIDE Project (FreeRTOS)
└── node2_pico_motor/       # CMake Project (Bare-metal RP2040)

Getting Started

Prerequisites

  • STM32CubeIDE (For Node 1)
  • Raspberry Pi Pico SDK & CMake (For Node 2)
  • ARM GNU Toolchain (arm-none-eabi-gcc)

Building Node 1 (STM32)

  1. Open STM32CubeIDE.
  2. Select FileOpen Projects from File System.
  3. Point the directory to /node1_stm32_main/.
  4. Build the project and flash using an ST-Link.

Building Node 2 (Pico)

Open your terminal and run the following commands:

cd node2_pico_motor
mkdir build && cd build
cmake ..
make

Flash the resulting .uf2 file to the Raspberry Pi Pico by holding the BOOTSEL button while plugging it in via USB, then drag and drop the file.


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages