Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parinaz-SmartCar

Smart Car Central Control Unit (CCU) - Phase 1, 2 & 3

This repository contains the firmware for the Smart Car Central Control Unit (CCU) developed on the STM32F401VETx microcontroller.

🚀 Features

  • Non-Blocking Architecture: Elimination of HAL_Delay() to ensure high-frequency responsiveness for button sampling and critical operations.
  • Dual-Channel ADC Multiplexing: Dynamic runtime reconfiguration of ADC channels to sample an LDR (Light Dependent Resistor) and an LM35 temperature sensor sequentially without hardware blocking.
  • Smart Tunnel Mode (Auto Light): Automatic activation of lights via high-resolution PWM when sudden darkness is detected.
  • Hysteresis Cooling Control: Automated cabin ventilation/cooling trigger with built-in thermal hysteresis ($37^\circ\text{C}$ to $40^\circ\text{C}$) to prevent relay/LED chattering.
  • Interrupt-Driven Telemetry (Phase 3): Real-time system monitoring over UART. Transmits core temperature, warning LED status, and PWM light levels using non-blocking interrupt routines (HAL_UART_Transmit_IT) at 9600 baud.

📌 Hardware Pinout Configuration

Based on the STM32CubeMX layout, the peripherals are mapped as follows:

Peripheral / Signal MCU Pin Mode / Configuration Description
TIM2_CH1 PA0 PWM Generation Automatic/Manual Light Intensity Control
ADC1_IN1 PA1 Analog Input (Rank 1) LDR Sensor for Ambient Light Intensity
ADC1_IN2 PA2 Analog Input (Rank 2) LM35 Sensor for Core Temperature Tracking
RED_LED PA3 GPIO Output Temperature Warning Status Indicator
USART1_TX PA9 Asynchronous Serial Telemetry Data Output (9600 Baud)
USART1_RX PA10 Asynchronous Serial Receive (Reserved)
BTN_UP PB0 GPIO Input (Pull-up) Manual PWM Increment Button
BTN_DOWN PB1 GPIO Input (Pull-up) Manual PWM Decrement Button
RCC PH0 / PH1 Crystal/Ceramic Resonator Main System Clock Source
SYS PA13 / PA14 Serial Wire Debug (SWD) Debugging and Flashing Interface

🛠️ Software Logic Workflow

  1. Environmental Sampling (Every 500ms):
    • Writes ADC_ChannelConfTypeDef at runtime to sample ADC_CHANNEL_1 (LM35) then ADC_CHANNEL_2 (LDR).
    • Processes the raw ADC value to extract temperature values using the standard analog voltage transfer function.
  2. Telemetry Broadcast (Every 500ms):
    • Packages system state (Temperature, Warn LED ON/OFF, PWM value) into a formatted string buffer.
    • Dispatches data to the Virtual Terminal via UART interrupts, ensuring the main loop continues execution without stalling.
  3. Driver Input Polling (Every 200ms):
    • Scans PB0 and PB1 for manual override commands.
    • Adjusts PWM Compare Register values dynamically in steps of 50 units (Max: 1000).

💻 Developed With

  • STM32CubeMX (Clock configuration & Peripheral initialization)
  • Keil uVision 5 / STM32CubeIDE (Embedded C Firmware)
  • Proteus 8.17 (Hardware circuit simulation)

📁 Repository Structure

The project is organized into the following directories:

  • firmware/: Contains the full STM32CubeMX configuration (.ioc file), generated HAL drivers, and the Keil MDK-ARM project source code.
  • simulation/: Contains the Proteus ISIS circuit schematic and real-time simulation file (.pdsprj).
  • docs/: Contains project documentation, phase reports (in Persian), timing diagrams, and sensor datasheets.

👨‍💻 Author

About

The environmental monitoring and adaptive lighting control module developed for the Smart Car organization project.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages