Skip to content

mariamashraf731/Traffic-light-system-8051

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

🚦 8051 Assembly Traffic Control System

Language Platform Architecture

📌 Project Overview

This project implements a configurable Traffic Light Controller using the Silicon Labs C8051F020 microcontroller. Written entirely in Assembly, the system simulates a traffic cycle where the duration of the green light is user-programmable via a 7-segment display interface before the cycle begins.

The system demonstrates proficiency in Low-Level Logic Design, controlling GPIOs for LEDs, multiplexing displays, and managing timing constraints manually without an OS.

⚙️ Key Features

  • Configurable Timer (HMI): Users can set the "Green Light Duration" (Max Count) using increment/decrement buttons before starting the cycle.
  • Dual Operation Modes:
    1. Configuration Mode: Setup the countdown timer value.
    2. Run Mode: Executes the traffic logic (Green ON -> Countdown -> Red ON -> Reload).
  • Variable Frequency Control: Adjustable counting speed (Frequency) via input switches to simulate different time scales.
  • Visual Feedback: * 7-Segment Display: Shows the remaining time for the active signal.
    • Status LEDs: Indicators for Red and Green traffic states.

🛠️ Technical Implementation

Hardware Mapping

Based on the C8051F020 architecture:

Component Port/Pin Function
Red LED P0.5 Stop Signal Output
Green LED P0.6 Go Signal Output
7-Segment Data P1, P2 Multiplexed Digit Output
Control Inputs P5 Start, Increment, Decrement Buttons
Freq. Control P0.2 - P0.4 Speed Selection Switches

Finite State Machine (FSM)

The assembly code implements a robust state machine:

  1. INIT: Initialize Registers, disable Watchdog, and poll for User Input (Set Max Count).
  2. START: Load user-defined values into RAM (0x50, 0x60) and enter the main loop.
  3. MAIN LOOP: * Drive Green LED.
    • Decrement Counter on 7-Segment.
    • Check for Zero -> Switch to Red LED -> Reload Counter -> Repeat.

🚀 How to Run

  1. Clone the repository:
    git clone [https://github.com/mariamashraf731/Traffic-light-system-8051.git](https://github.com/mariamashraf731/Traffic-light-system-8051.git)
  2. Hardware Setup:
    • Connect Common Anode 7-Segment displays to Ports P1 & P2.
    • Connect LEDs to P0.5 (Red) and P0.6 (Green).
    • Connect Push Buttons to Port 5 (with Pull-up configuration).
  3. Build & Flash:
    • Open src/main.asm in Keil µVision.
    • Build target and flash to C8051F020.

📄 Documentation

For detailed schematics and flowcharts, please refer to the System Design Report.

👨‍💻 Skills Demonstrated

  • Register-Level Programming: Direct manipulation of WDTCN (Watchdog), XBR2 (Crossbar), and OSCICN.
  • Timing Analysis: creating precise delay loops (DELAY1) for real-time simulation.
  • Memory Management: Utilizing internal RAM for preserving state variables during context switching.

About

An Assembly-based Traffic Light Controller on C8051F020 with configurable timing logic and variable frequency modes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors