Latest commit

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Final Project: Light Source & Object Proximity Detector System

DCS Course
A comprehensive embedded system and PC interface for detecting light sources and object proximity using an MSP430 MCU.


🛠 Hardware Architecture

  • Layering: BSP → HAL → API/APP → main (FSM, interrupt-driven)
  • I/O: UART 9600 bps
  • Display: LCD 16×2
  • Sensors: HC-SR04 (Ultrasonic) + two LDRs (Light Dependent Resistors)
  • Motor: SG90 servo motor

📍 Pin Out

PinFunctionDescription
P1.0Analog Input (A0)LDR1 Signal
P1.1UARTRXD
P1.2UARTTXD
P1.3Analog Input (A3)LDR2 Signal
P1.4Digital OutputLCD Data D4
P1.5Digital OutputLCD Data D5
P1.6Digital OutputLCD Data D6
P1.7Digital OutputLCD Data D7
P2.0Digital InputPB0 (LDR Calibration Button)
P2.1Digital OutputLCD Control Signal (E)
P2.2Timer A1 CCR1Ultrasonic Sensor Output (ECHO)
P2.3Digital OutputLCD Control Signal (RS)
P2.4Timer A1 CCR2PWM Out (Servo Motor Control)
P2.5Digital OutputLCD Control Signal (RW)
P2.6Timer A0 CCR1Ultrasonic Sensor Input (TRIG)
P2.7Digital InputPB1

📂 Source Index

MCU (C)

  • Headers:app.h, api.h, halGPIO.h, bsp_msp430x2xx.h
  • Sources:bsp.c, halGPIO.c, api.c, main.c

PC (Python)

  • Main Entry:main.py
  • Modules:comm/, gui/, processing/, visualization/

🧠 MCU Subsystem Details

1. Headers

  • app.h: Constants & memory map (Flash addresses, sizes), Enums (FSM states, ScanMode, FileType), FileEntry structure, extern shared states.
  • api.h: APP/API prototypes for detectors, measurements, file system operations, and calibration sequences.
  • halGPIO.h: HAL prototypes for LCD, UART, ADC, Timers, PWM, Ultrasonic, Flash, circular RX buffer, and LPM helpers.
  • bsp_msp430x2xx.h: BSP pin mapping, general macros, Timer/ADC/UART defines, and ISR vectors.

2. C Sources

bsp.c (Board Support Package)

Low-level board bring-up and system helpers:

  • GPIOconfig, Timers_Init, ADC_config, UART_init
  • LPM and global IRQ utilities (enterLPM, enable_interrupts)

halGPIO.c (Hardware Abstraction Layer)

Direct hardware layer and ISRs:

  • LCD: lcd_init, lcd_cmd, lcd_data, lcd_puts
  • UART: UART_send_char, UartBuffer_Init/Put/Get
  • Timers/Ultrasonic: Blocking delays, Ultrasonic_Start_Measurement
  • PWM/Servo: pwmOutServoConfig, Set_Angle_PWM
  • ADC: ADC_Enable, ADC_sample, channel configs
  • Flash: Timing, erase/write operations
  • ISRs: Buttons (PBs_handler), Timers (Timer_1_ISR, Timer0_A0_ISR_Handler), ADC (ADC_ISR)

api.c (APP/API Layer)

High-level logic, runtime FSMs, Flash filesystem, scripts, and scanning:

  • Scans & Sensing: servo_scan, object_detector, telemeter, light_detector, light_object_detector
  • LDR Calibration: run_calibration_sequence, write_all_calib_to_flash, send_calib_arr
  • Filesystem: FileSystem_Init, Handle_UploadFile_Start, Handle_Upload_Byte, script interpreters (parse_and_execute_line)

main.c (Entry Point)

Initialize layers, run RX loop, decode UART commands, and dispatch FSMs.


💻 PC Subsystem (Python)

The PC-side provides a PySimpleGUI desktop application to control all modes, run calibration, manage files, process sensor data, and plot polar maps.

Key Functionalities:

  • Serial Management: UART communication wrapped in serial_manager.py.
  • GUI Modules: Isolated event loops for Objects, Telemeter, Lights, Combined, and File modes.
  • Processing: Signal smoothing, valley/peak detection, filtering, and crosstalk cleaning (process_light_scan_data).
  • Data Visualization: Matplotlib polar plots for detected objects and light sources.
  • File Upload Protocol: Handles MCU handshake, checksum generation, and 64-byte chunked flashing.

Script Opcodes:

CommandHexCommandHex
inc_lcd0x01dec_lcd0x02
rra_lcd0x03set_delay0x04
clear_lcd0x05servo_deg0x06
servo_scan0x07sleep0x08

🔌 UART Protocol Quick Reference

Control Markers:

  • Start-of-Script = 0xCC
  • Telemetry Header = 0xFE
  • End/Sleep = 0x7F
  • End-of-Scan = FF FF FF

Handshakes & Commands:

  • Handshake:'P' → MCU replies 'A'
  • Objects:'S' → stream of (2B distance + 1B angle) per step; end marker FF FF FF
  • Lights:'K' → stream of (LDR1_lo, LDR1_hi, LDR2_lo, LDR2_hi, angle)
  • Combined:'X' → stream of (2B distance, 2B LDR1, 2B LDR2, 1B angle); end marker FF FF FF
  • Telemeter:'T' + angle byte → MCU returns (2B distance + 1B angle)
  • Files:
    • 'L' (List), 'U' (Upload), 'R' (Run script), 'V' (LCD view mode), 'D' (Delete FS)
  • Calibration:'J' (Guided LDR capture), 'Z' (Read back compressed array)

Note: Endianness is Little-Endian (first Low-Byte, second High-byte).


👥 Authors

  • Arkady Gerasimuk
  • Adi Shlomo

About

An embedded radar system using an MSP430 MCU to detect and map objects and light sources, featuring a custom flash file system and a Python desktop interface.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Final Project: Light Source & Object Proximity Detector System

DCS Course
A comprehensive embedded system and PC interface for detecting light sources and object proximity using an MSP430 MCU.


🛠 Hardware Architecture

  • Layering: BSP → HAL → API/APP → main (FSM, interrupt-driven)
  • I/O: UART 9600 bps
  • Display: LCD 16×2
  • Sensors: HC-SR04 (Ultrasonic) + two LDRs (Light Dependent Resistors)
  • Motor: SG90 servo motor

📍 Pin Out

PinFunctionDescription
P1.0Analog Input (A0)LDR1 Signal
P1.1UARTRXD
P1.2UARTTXD
P1.3Analog Input (A3)LDR2 Signal
P1.4Digital OutputLCD Data D4
P1.5Digital OutputLCD Data D5
P1.6Digital OutputLCD Data D6
P1.7Digital OutputLCD Data D7
P2.0Digital InputPB0 (LDR Calibration Button)
P2.1Digital OutputLCD Control Signal (E)
P2.2Timer A1 CCR1Ultrasonic Sensor Output (ECHO)
P2.3Digital OutputLCD Control Signal (RS)
P2.4Timer A1 CCR2PWM Out (Servo Motor Control)
P2.5Digital OutputLCD Control Signal (RW)
P2.6Timer A0 CCR1Ultrasonic Sensor Input (TRIG)
P2.7Digital InputPB1

📂 Source Index

MCU (C)

  • Headers:app.h, api.h, halGPIO.h, bsp_msp430x2xx.h
  • Sources:bsp.c, halGPIO.c, api.c, main.c

PC (Python)

  • Main Entry:main.py
  • Modules:comm/, gui/, processing/, visualization/

🧠 MCU Subsystem Details

1. Headers

  • app.h: Constants & memory map (Flash addresses, sizes), Enums (FSM states, ScanMode, FileType), FileEntry structure, extern shared states.
  • api.h: APP/API prototypes for detectors, measurements, file system operations, and calibration sequences.
  • halGPIO.h: HAL prototypes for LCD, UART, ADC, Timers, PWM, Ultrasonic, Flash, circular RX buffer, and LPM helpers.
  • bsp_msp430x2xx.h: BSP pin mapping, general macros, Timer/ADC/UART defines, and ISR vectors.

2. C Sources

bsp.c (Board Support Package)

Low-level board bring-up and system helpers:

  • GPIOconfig, Timers_Init, ADC_config, UART_init
  • LPM and global IRQ utilities (enterLPM, enable_interrupts)

halGPIO.c (Hardware Abstraction Layer)

Direct hardware layer and ISRs:

  • LCD: lcd_init, lcd_cmd, lcd_data, lcd_puts
  • UART: UART_send_char, UartBuffer_Init/Put/Get
  • Timers/Ultrasonic: Blocking delays, Ultrasonic_Start_Measurement
  • PWM/Servo: pwmOutServoConfig, Set_Angle_PWM
  • ADC: ADC_Enable, ADC_sample, channel configs
  • Flash: Timing, erase/write operations
  • ISRs: Buttons (PBs_handler), Timers (Timer_1_ISR, Timer0_A0_ISR_Handler), ADC (ADC_ISR)

api.c (APP/API Layer)

High-level logic, runtime FSMs, Flash filesystem, scripts, and scanning:

  • Scans & Sensing: servo_scan, object_detector, telemeter, light_detector, light_object_detector
  • LDR Calibration: run_calibration_sequence, write_all_calib_to_flash, send_calib_arr
  • Filesystem: FileSystem_Init, Handle_UploadFile_Start, Handle_Upload_Byte, script interpreters (parse_and_execute_line)

main.c (Entry Point)

Initialize layers, run RX loop, decode UART commands, and dispatch FSMs.


💻 PC Subsystem (Python)

The PC-side provides a PySimpleGUI desktop application to control all modes, run calibration, manage files, process sensor data, and plot polar maps.

Key Functionalities:

  • Serial Management: UART communication wrapped in serial_manager.py.
  • GUI Modules: Isolated event loops for Objects, Telemeter, Lights, Combined, and File modes.
  • Processing: Signal smoothing, valley/peak detection, filtering, and crosstalk cleaning (process_light_scan_data).
  • Data Visualization: Matplotlib polar plots for detected objects and light sources.
  • File Upload Protocol: Handles MCU handshake, checksum generation, and 64-byte chunked flashing.

Script Opcodes:

CommandHexCommandHex
inc_lcd0x01dec_lcd0x02
rra_lcd0x03set_delay0x04
clear_lcd0x05servo_deg0x06
servo_scan0x07sleep0x08

🔌 UART Protocol Quick Reference

Control Markers:

  • Start-of-Script = 0xCC
  • Telemetry Header = 0xFE
  • End/Sleep = 0x7F
  • End-of-Scan = FF FF FF

Handshakes & Commands:

  • Handshake:'P' → MCU replies 'A'
  • Objects:'S' → stream of (2B distance + 1B angle) per step; end marker FF FF FF
  • Lights:'K' → stream of (LDR1_lo, LDR1_hi, LDR2_lo, LDR2_hi, angle)
  • Combined:'X' → stream of (2B distance, 2B LDR1, 2B LDR2, 1B angle); end marker FF FF FF
  • Telemeter:'T' + angle byte → MCU returns (2B distance + 1B angle)
  • Files:
    • 'L' (List), 'U' (Upload), 'R' (Run script), 'V' (LCD view mode), 'D' (Delete FS)
  • Calibration:'J' (Guided LDR capture), 'Z' (Read back compressed array)

Note: Endianness is Little-Endian (first Low-Byte, second High-byte).


👥 Authors

  • Arkady Gerasimuk
  • Adi Shlomo

About

An embedded radar system using an MSP430 MCU to detect and map objects and light sources, featuring a custom flash file system and a Python desktop interface.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Final Project: Light Source & Object Proximity Detector System

DCS Course
A comprehensive embedded system and PC interface for detecting light sources and object proximity using an MSP430 MCU.


🛠 Hardware Architecture

  • Layering: BSP → HAL → API/APP → main (FSM, interrupt-driven)
  • I/O: UART 9600 bps
  • Display: LCD 16×2
  • Sensors: HC-SR04 (Ultrasonic) + two LDRs (Light Dependent Resistors)
  • Motor: SG90 servo motor

📍 Pin Out

PinFunctionDescription
P1.0Analog Input (A0)LDR1 Signal
P1.1UARTRXD
P1.2UARTTXD
P1.3Analog Input (A3)LDR2 Signal
P1.4Digital OutputLCD Data D4
P1.5Digital OutputLCD Data D5
P1.6Digital OutputLCD Data D6
P1.7Digital OutputLCD Data D7
P2.0Digital InputPB0 (LDR Calibration Button)
P2.1Digital OutputLCD Control Signal (E)
P2.2Timer A1 CCR1Ultrasonic Sensor Output (ECHO)
P2.3Digital OutputLCD Control Signal (RS)
P2.4Timer A1 CCR2PWM Out (Servo Motor Control)
P2.5Digital OutputLCD Control Signal (RW)
P2.6Timer A0 CCR1Ultrasonic Sensor Input (TRIG)
P2.7Digital InputPB1

📂 Source Index

MCU (C)

  • Headers:app.h, api.h, halGPIO.h, bsp_msp430x2xx.h
  • Sources:bsp.c, halGPIO.c, api.c, main.c

PC (Python)

  • Main Entry:main.py
  • Modules:comm/, gui/, processing/, visualization/

🧠 MCU Subsystem Details

1. Headers

  • app.h: Constants & memory map (Flash addresses, sizes), Enums (FSM states, ScanMode, FileType), FileEntry structure, extern shared states.
  • api.h: APP/API prototypes for detectors, measurements, file system operations, and calibration sequences.
  • halGPIO.h: HAL prototypes for LCD, UART, ADC, Timers, PWM, Ultrasonic, Flash, circular RX buffer, and LPM helpers.
  • bsp_msp430x2xx.h: BSP pin mapping, general macros, Timer/ADC/UART defines, and ISR vectors.

2. C Sources

bsp.c (Board Support Package)

Low-level board bring-up and system helpers:

  • GPIOconfig, Timers_Init, ADC_config, UART_init
  • LPM and global IRQ utilities (enterLPM, enable_interrupts)

halGPIO.c (Hardware Abstraction Layer)

Direct hardware layer and ISRs:

  • LCD: lcd_init, lcd_cmd, lcd_data, lcd_puts
  • UART: UART_send_char, UartBuffer_Init/Put/Get
  • Timers/Ultrasonic: Blocking delays, Ultrasonic_Start_Measurement
  • PWM/Servo: pwmOutServoConfig, Set_Angle_PWM
  • ADC: ADC_Enable, ADC_sample, channel configs
  • Flash: Timing, erase/write operations
  • ISRs: Buttons (PBs_handler), Timers (Timer_1_ISR, Timer0_A0_ISR_Handler), ADC (ADC_ISR)

api.c (APP/API Layer)

High-level logic, runtime FSMs, Flash filesystem, scripts, and scanning:

  • Scans & Sensing: servo_scan, object_detector, telemeter, light_detector, light_object_detector
  • LDR Calibration: run_calibration_sequence, write_all_calib_to_flash, send_calib_arr
  • Filesystem: FileSystem_Init, Handle_UploadFile_Start, Handle_Upload_Byte, script interpreters (parse_and_execute_line)

main.c (Entry Point)

Initialize layers, run RX loop, decode UART commands, and dispatch FSMs.


💻 PC Subsystem (Python)

The PC-side provides a PySimpleGUI desktop application to control all modes, run calibration, manage files, process sensor data, and plot polar maps.

Key Functionalities:

  • Serial Management: UART communication wrapped in serial_manager.py.
  • GUI Modules: Isolated event loops for Objects, Telemeter, Lights, Combined, and File modes.
  • Processing: Signal smoothing, valley/peak detection, filtering, and crosstalk cleaning (process_light_scan_data).
  • Data Visualization: Matplotlib polar plots for detected objects and light sources.
  • File Upload Protocol: Handles MCU handshake, checksum generation, and 64-byte chunked flashing.

Script Opcodes:

CommandHexCommandHex
inc_lcd0x01dec_lcd0x02
rra_lcd0x03set_delay0x04
clear_lcd0x05servo_deg0x06
servo_scan0x07sleep0x08

🔌 UART Protocol Quick Reference

Control Markers:

  • Start-of-Script = 0xCC
  • Telemetry Header = 0xFE
  • End/Sleep = 0x7F
  • End-of-Scan = FF FF FF

Handshakes & Commands:

  • Handshake:'P' → MCU replies 'A'
  • Objects:'S' → stream of (2B distance + 1B angle) per step; end marker FF FF FF
  • Lights:'K' → stream of (LDR1_lo, LDR1_hi, LDR2_lo, LDR2_hi, angle)
  • Combined:'X' → stream of (2B distance, 2B LDR1, 2B LDR2, 1B angle); end marker FF FF FF
  • Telemeter:'T' + angle byte → MCU returns (2B distance + 1B angle)
  • Files:
    • 'L' (List), 'U' (Upload), 'R' (Run script), 'V' (LCD view mode), 'D' (Delete FS)
  • Calibration:'J' (Guided LDR capture), 'Z' (Read back compressed array)

Note: Endianness is Little-Endian (first Low-Byte, second High-byte).


👥 Authors

  • Arkady Gerasimuk
  • Adi Shlomo

About

An embedded radar system using an MSP430 MCU to detect and map objects and light sources, featuring a custom flash file system and a Python desktop interface.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages