Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2026:vlad.radulescu2901:viorel_cosmin.cucu [2026/05/16 21:30]
viorel_cosmin.cucu [Key Design Choices & Electrical Schematic]
pm:prj2026:vlad.radulescu2901:viorel_cosmin.cucu [2026/05/24 19:15] (current)
viorel_cosmin.cucu [Components and Their Role]
Line 34: Line 34:
   * **Outputs:​** The ESC drives the main motor (speed), the L298N drives the steering motor (direction),​ the LCD shows status, the buzzer gives audio alerts, and the LEDs provide lighting.   * **Outputs:​** The ESC drives the main motor (speed), the L298N drives the steering motor (direction),​ the LCD shows status, the buzzer gives audio alerts, and the LEDs provide lighting.
 ==== Block Diagram ==== ==== Block Diagram ====
-{{:​pm:​prj2026:​vlad.radulescu2901:​block_diagram.jpg?500|}}+{{:​pm:​prj2026:​vlad.radulescu2901:​schema_bloc_cucu.jpg?500|}}
  
  
Line 42: Line 42:
 ^ Component ^ Model ^ Role in Project ^ ^ Component ^ Model ^ Role in Project ^
 | Microcontroller | ATmega328P Xplained Mini | Central brain. Reads all sensors, runs non-blocking logic, outputs PWM and I2C signals. | | Microcontroller | ATmega328P Xplained Mini | Central brain. Reads all sensors, runs non-blocking logic, outputs PWM and I2C signals. |
-| Bluetooth Module | HC-05 | Bidirectional telemetry with Android app — receives drive commands, sends sensor data. |+| Bluetooth Module | HC-05 | Bidirectional telemetry with Android app receives drive commands, sends sensor data. |
 | Front Ultrasonic Sensor | HC-SR04 | Measures distance to obstacles ahead. Triggers buzzer alerts and emergency stop at <15 cm. | | Front Ultrasonic Sensor | HC-SR04 | Measures distance to obstacles ahead. Triggers buzzer alerts and emergency stop at <15 cm. |
 | Rear Ultrasonic Sensor | HC-SR04 | Measures distance behind the rover. Powers the reverse parking assist display on the LCD. | | Rear Ultrasonic Sensor | HC-SR04 | Measures distance behind the rover. Powers the reverse parking assist display on the LCD. |
Line 49: Line 49:
 | Traction Motor | 390 DC Motor (7.4V) | Drives the rover forward and backward from Battery 2's dedicated high-current rail. | | Traction Motor | 390 DC Motor (7.4V) | Drives the rover forward and backward from Battery 2's dedicated high-current rail. |
 | Steering Motor | 3–6V DC Motor | Turns the front axle left or right under L298N control. | | Steering Motor | 3–6V DC Motor | Turns the front axle left or right under L298N control. |
-| Motor Driver | L298N H-Bridge | Accepts PWM (ENA) and two direction pins (IN1/IN2) to drive the steering DC motor. |+| Motor Driver | L298N H-Bridge | Two direction pins (IN1/IN2) to drive the steering DC motor. |
 | LCD Display | 1602 LCD + PCF8574 I2C | "Smart dashboard":​ shows expressive animated eyes in normal mode, parking assist in reverse. | | LCD Display | 1602 LCD + PCF8574 I2C | "Smart dashboard":​ shows expressive animated eyes in normal mode, parking assist in reverse. |
 | Active Buzzer | TMB12A05 5V | Proximity alert (beep rate increases near obstacles) and horn command from phone. | | Active Buzzer | TMB12A05 5V | Proximity alert (beep rate increases near obstacles) and horn command from phone. |
 | Headlights & Taillights | 5mm LEDs x4 + 220Ω x4 | Front lighting (D7) activates automatically via LDR. Rear taillights (A3) activate on brake/​reverse. Wired in parallel. | | Headlights & Taillights | 5mm LEDs x4 + 220Ω x4 | Front lighting (D7) activates automatically via LDR. Rear taillights (A3) activate on brake/​reverse. Wired in parallel. |
 | Voltage Regulator | LM2596 Step-Down | Converts Battery 1's 7.4V down to a stable 5V for all logic (MCU, sensors, LCD). | | Voltage Regulator | LM2596 Step-Down | Converts Battery 1's 7.4V down to a stable 5V for all logic (MCU, sensors, LCD). |
-| Battery 1 — Logic Rail | 2x Murata US18650VTC5C in series | 7.4V, 2600 mAh, 30A. Powers L298N and LM2596 (which feeds 5V logic). | +| Battery 1 Logic Rail | 2x Murata US18650VTC5C in series | 7.4V, 2600 mAh, 30A. Powers L298N and LM2596 (which feeds 5V logic). | 
-| Battery 2 — Traction Rail | 2x Samsung 25R 18650 in series | 7.4V, 2500 mAh, 8C. Dedicated high-current supply exclusively for the ESC. |+| Battery 2 Traction Rail | 2x Samsung 25R 18650 in series | 7.4V, 2500 mAh, 8C. Dedicated high-current supply exclusively for the ESC. |
 | Chassis | Land Buster 1/12 scale | Physical base of the rover. | | Chassis | Land Buster 1/12 scale | Physical base of the rover. |
  
Line 61: Line 61:
 ==== Pin Mapping and Justification ==== ==== Pin Mapping and Justification ====
 ^ Arduino Pin ^ AVR Register ^ Timer / Peripheral ^ Connected To ^ Why This Pin ^ ^ Arduino Pin ^ AVR Register ^ Timer / Peripheral ^ Connected To ^ Why This Pin ^
-| D0 (RX) | PD0 | USART0 RX | HC-05 TX | Hardware USART — zero-latency interrupt-driven reception (RXCIE0). No bit-banging needed. |+| D0 (RX) | PD0 | USART0 RX | HC-05 TX | Hardware USART zero-latency interrupt-driven reception (RXCIE0). No bit-banging needed. |
 | D1 (TX) | PD1 | USART0 TX | HC-05 RX via 1kΩ/2kΩ divider | Same USART peripheral. 5V output is divided to 3.3V to protect HC-05 RX logic level. | | D1 (TX) | PD1 | USART0 TX | HC-05 RX via 1kΩ/2kΩ divider | Same USART peripheral. 5V output is divided to 3.3V to protect HC-05 RX logic level. |
-| D2 | PD2 | GPIO Output | HC-SR04 Front — TRIG | Any GPIO works for the 10 µs trigger pulse. D2 keeps sensor pins grouped together. | +| D2 | PD2 | GPIO Output | HC-SR04 Front TRIG | Any GPIO works for the 10 µs trigger pulse. D2 keeps sensor pins grouped together. | 
-| D3 | PD3 | GPIO Input | HC-SR04 Front — ECHO | Paired with D2 for clean wiring. Reads echo pulse duration via pulseIn(). | +| D3 | PD3 | GPIO Input | HC-SR04 Front ECHO | Paired with D2 for clean wiring. Reads echo pulse duration via pulseIn(). | 
-| D4 | PD4 | GPIO Output | HC-SR04 Rear — TRIG | Same reason as D2; rear sensor pins grouped on D4/D5. | +| D4 | PD4 | GPIO Output | HC-SR04 Rear TRIG | Same reason as D2; rear sensor pins grouped on D4/D5. | 
-| D5 | PD5 | GPIO Input | HC-SR04 Rear — ECHO | Paired with D4. Mirrors front sensor logic for parking assist. | +| D5 | PD5 | GPIO Input | HC-SR04 Rear ECHO | Paired with D4. Mirrors front sensor logic for parking assist. |
-| D6 | PD6 | Timer 0, OC0A (Fast PWM) | L298N ENA | Only OC0A or OC0B can output Timer 0 PWM. D6 = OC0A — sets steering motor duty cycle (0–255). |+
 | D7 | PD7 | GPIO Output | Headlight LEDs + 220Ω | Simple digital ON/OFF for the LED array. D7 is free from any timer to avoid conflicts. | | D7 | PD7 | GPIO Output | Headlight LEDs + 220Ω | Simple digital ON/OFF for the LED array. D7 is free from any timer to avoid conflicts. |
-| D8 | PB0 | GPIO Output | L298N IN1 | Direction bit for steering H-bridge. No special hardware needed ​— plain digital output. |+| D8 | PB0 | GPIO Output | L298N IN1 | Direction bit for steering H-bridge. No special hardware needed ​plain digital output. |
 | D9 | PB1 | GPIO Output | L298N IN2 | Direction bit for steering H-bridge (opposite of IN1 to select left/​right). | | D9 | PB1 | GPIO Output | L298N IN2 | Direction bit for steering H-bridge (opposite of IN1 to select left/​right). |
-| D10 | PB2 | Timer 1, OC1B (Phase-correct PWM) | ESC Signal | Timer 1 is 16-bit ​— essential for generating the precise 50 Hz (20 ms period) servo-style PWM the ESC requires. ICR1=39999, OCR1B range 2600–3400 for speed control. |+| D10 | PB2 | Timer 1, OC1B (Phase-correct PWM) | ESC Signal | Timer 1 is 16-bit ​essential for generating the precise 50 Hz (20 ms period) servo-style PWM the ESC requires. ICR1=39999, OCR1B range 2600–3400 for speed control. |
 | A0 | PC0 | ADC0 | LDR Voltage Divider | First ADC channel; no mux change needed for single-channel reads. Direct analog measurement of light level. | | A0 | PC0 | ADC0 | LDR Voltage Divider | First ADC channel; no mux change needed for single-channel reads. Direct analog measurement of light level. |
 | A1 | PC1 | GPIO Input | HC-05 STATE | Reads hardware connection status (HIGH = connected, LOW = disconnected/​searching). | | A1 | PC1 | GPIO Input | HC-05 STATE | Reads hardware connection status (HIGH = connected, LOW = disconnected/​searching). |
 | A2 | PC2 | GPIO Output | Active Buzzer | Moved here from SPI pins to keep PB3/PB4/PB5 free for the Xplained Mini's programming interface (EDBG). | | A2 | PC2 | GPIO Output | Active Buzzer | Moved here from SPI pins to keep PB3/PB4/PB5 free for the Xplained Mini's programming interface (EDBG). |
 | A3 | PC3 | GPIO Output | Rear LED Taillights | Dedicated pin for red rear taillights. Activates independently during AEB, reverse, or stop. | | A3 | PC3 | GPIO Output | Rear LED Taillights | Dedicated pin for red rear taillights. Activates independently during AEB, reverse, or stop. |
-| A4 | PC4 | TWI SDA (Hardware I2C) | LCD PCF8574 SDA | Hardware I2C peripheral ​— only PC4/PC5 support hardware TWI on ATmega328P. |+| A4 | PC4 | TWI SDA (Hardware I2C) | LCD PCF8574 SDA | Hardware I2C peripheral ​only PC4/PC5 support hardware TWI on ATmega328P. |
 | A5 | PC5 | TWI SCL (Hardware I2C) | LCD PCF8574 SCL | Paired with A4. Hardware TWI runs at 100 kHz without CPU intervention. | | A5 | PC5 | TWI SCL (Hardware I2C) | LCD PCF8574 SCL | Paired with A4. Hardware TWI runs at 100 kHz without CPU intervention. |
  
  
 ==== Key Design Choices & Electrical Schematic ==== ==== Key Design Choices & Electrical Schematic ====
-{{:​pm:​prj2026:​vlad.radulescu2901:​cica_schema_cucu.png?600|}}+{{:​pm:​prj2026:​vlad.radulescu2901:​schema_cucu_elec.png?650|}}
  
  
-{{:​pm:​prj2026:​vlad.radulescu2901:​kicad_cucu.pdf|}}+{{:​pm:​prj2026:​vlad.radulescu2901:​kicad_cucu2.pdf|}}
  
 The electrical schematic above illustrates the complete wiring of the Land Buster rover. The hardware architecture is built upon the following core engineering rules: The electrical schematic above illustrates the complete wiring of the Land Buster rover. The hardware architecture is built upon the following core engineering rules:
Line 96: Line 95:
 ==== Proof of Functionality & Assembly ==== ==== Proof of Functionality & Assembly ====
  
-**Photo 1: Power Drop Test**\\\\+**Photo 1: Power Drop Test**
  
 {{:​pm:​prj2026:​vlad.radulescu2901:​poza1_cucu.jpg?​400|}} {{:​pm:​prj2026:​vlad.radulescu2901:​poza1_cucu.jpg?​400|}}
Line 102: Line 101:
 This early prototype test was conducted with only the steering system and ESC connected. While running the main traction motor at a low RPM, the output of the LM2596 regulator dropped dangerously to 4.7V. This critical observation proved that a single battery configuration was insufficient to handle the high current spikes, directly justifying the upgrade to the current dual-battery (4-cell) isolated power system. This early prototype test was conducted with only the steering system and ESC connected. While running the main traction motor at a low RPM, the output of the LM2596 regulator dropped dangerously to 4.7V. This critical observation proved that a single battery configuration was insufficient to handle the high current spikes, directly justifying the upgrade to the current dual-battery (4-cell) isolated power system.
  
-**Photo 2: Full System Test**\\\\+**Photo 2: Full System Test**
  
 +{{:​pm:​prj2026:​vlad.radulescu2901:​poza2_cuculet.jpg?​400|}}
  
  
-All electronic componentsincluding the ultrasonic sensors, I2C LCD, HC-05 Bluetooth module, and motor driversare integrated and tested together. This phase successfully verified the software integration,​ ensuring that the non-blocking logic, telemetry, and autonomous emergency braking (AEB) functioned simultaneously without interference,​ proving the system'​s core functionality.+All electronic components-including the ultrasonic sensors, I2C LCD, HC-05 Bluetooth module, and motor drivers-are integrated and tested together. This phase successfully verified the software integration,​ ensuring that the non-blocking logic, telemetry, and autonomous emergency braking (AEB) functioned simultaneously without interference,​ proving the system'​s core functionality.
  
  
-**Photo 3: Clean Build**\\\\+**Photo 3: Clean Build**
  
 {{:​pm:​prj2026:​vlad.radulescu2901:​poza3_cucu.jpg?​400|}} {{:​pm:​prj2026:​vlad.radulescu2901:​poza3_cucu.jpg?​400|}}
  
-The final hardware assembly mounted on the Land Buster chassis. This image highlights the strict cable management and the use of modular JST connectorsThis robust wiring approach prevents connections from vibrating loose during physical operationensuring high reliability on the move.+The final hardware assembly mounted on the Land Buster chassis. This image highlights the strict cable management and the custom mechanical modifications made to the chassis to accommodate all the new componentsTo ensure maximum stability, the electronics and wiring were permanently secured using high-strength adhesives (epoxy resin and cyanoacrylate).
  
  
  
-**Photo 4: Final Assembly**\\\\+**Photo 4: Final Assembly**
  
 {{:​pm:​prj2026:​vlad.radulescu2901:​poza4_cucu.jpg?​400|}} {{:​pm:​prj2026:​vlad.radulescu2901:​poza4_cucu.jpg?​400|}}
  
-The completed autonomous rover with the original outer car shell successfully mounted. The clean cable management allows the shell to fit perfectly without putting pressure on the sensitive electronics or jumper wires, resulting in a polished and professional final build.+The completed autonomous rover with the original outer car shell successfully mounted.
  
 ===== Software Design ===== ===== Software Design =====
  
-==== Development Environment ====+==== Development Environment ​& Libraries Motivation ​====
   * **IDE:** PlatformIO (VS Code)   * **IDE:** PlatformIO (VS Code)
-  * **Language:​** ​Pure AVR +  * **Language:​** C++ (Arduino framework) 
-  * **Compiler:** avr-gcc +  * **AI Assistance:** I used Claude Opus AI to assist with writing the code, structuring the non-blocking logic, and debugging hardware timer issues. 
-  * **Target:** ATmega328P ​Xplained Mini+  * **Libraries Motivation:** 
 +    * ''<​Arduino.h>'':​ The core framework library. I used it for essential built-in functions like ''​millis()''​ (crucial for my non-blocking state machines), ''​pulseIn()''​ (to safely read ultrasonic sensors with a strict timeout), and basic GPIO control (''​pinMode'',​ ''​digitalWrite'',​ ''​analogRead''​). 
 +    * ''<​Wire.h>'':​ The standard I2C library. Used to abstract the low-level TWI (Two-Wire Interface) hardware registers of the ATmega328P, providing robust communication with I2C devices. 
 +    * ''<​LiquidCrystal_I2C.h>'':​ An external library that relies on ''<​Wire.h>''​. It handles the complex data formatting required by the PCF8574 I2C expander attached to the 1602 LCD. I chose to use this library because writing a custom I2C LCD driver from scratch would be redundant and reinventing the wheel, allowing me to easily display custom animated characters. Everything else (like PWM and Timers) was implemented using direct register manipulation.
  
-==== Source Files ==== +==== Justification of Laboratory Functionalities ​==== 
-<​code>​ +The project actively uses 5 core concepts from the PM laboratory: 
-src/ +  * **USARTDebugging ​(Laboratorul ​1):** Essential for wireless communicationThe HC-05 module receives driving commands from the Android phone via the hardware USART peripheral at 9600 baud. 
-├── main.c ​         # Main loop, ISR, command dispatcher +  * **Întreruperi,​ Timere ​(Laboratorul ​2):** Critical for the non-blocking architectureThe project heavily relies on ''​millis()''​ (which operates via Timer 0 overflow interrupts) to manage sensor timing, signal debouncing, and connection failsafe timeouts without halting the CPU. 
-├── usart.c / .h    # USART driver + printf via stdout ​(Lab 1) +  * **Timere, Pulse Width Modulation - PWM (Laboratorul 3):** Used to control ​the speed of the main traction motor via the ESC. Timer 1 (16-bitis manually configured via hardware registers (''​TCCR1A'',​ ''​TCCR1B'',​ ''​ICR1''​) in Fast PWM mode to generate a highly precise 50Hz signalThe ''​OCR1B''​ register is varied between 3500 and 4000 to achieve 4 different speed gears. 
-├── ultrasonic.c    # HC-SR04 distance measurement ​(Lab 2) +  * **Analog Digital Convertor - ADC (Laboratorul ​4):** Used to read the analog voltage from the photoresistor (LDR)The ADC converts the light intensity into a digital value, which is compared against a threshold ​to automatically toggle the headlights. 
-├── motor.c         # ​PWM steering ​control via L298N (Lab 3) +  * **I2C (Laboratorul 6):** Used to communicate with the PCF8574 expander on the back of the 1602 LCD, saving valuable GPIO pins.
-├── adc.c / .h      # ADC driver for photoresistor ​(Lab 4) +
-└── task1.c         # ​ADC read + threshold ​logic (tested standalone) +
-</​code>​+
  
-==== Lab 1 - USART: Bluetooth Control ​==== +==== Project Skeleton, Interaction,​ and Validation ​==== 
-The HC-05 sends bytes from the phone app at 9600 baud. The **RX Complete Interrupt ​(RXCIE0)** fires automatically when byte arrives.+The software is structured around a single, highly optimized, non-blocking ''​loop()'':​ 
 +  ​* **Interaction:​** The loop continuously checks for incoming Bluetooth commands. It then alternates reading the front and rear ultrasonic sensors. Based on the distances, it evaluates the Autonomous Emergency Braking ​(AEBlogic. Finally, it sets the motor outputs and updates the LCD animations without using any delays. 
 +  ​* **Validation:​** I validated the system by building ​custom Android application that receives live telemetry from the car (sensor distances, light levels, active gear). I tested edge cases by driving at full speed towards walls to ensure the AEB triggers correctly and stops the car before impact.
  
-<code c> +==== Sensor Calibration ==== 
-// usart.c +  * **Photoresistor ​(LDR):** It is connected in a voltage divider with a 10kΩ resistor. I calibrated the software by reading the ADC values in different lighting conditions. I set the threshold to ''​400''​ so the headlights turn on automatically only when the room gets dark. 
-void USART0_init(unsigned int ubrr) { +  * **Ultrasonic Sensors ​(HC-SR04):** Distance is calculated using ''​duration ​58''​. To calibrate them for real-time useI reduced the timeout from the default 1,​000,​000µs to just ''​15000µs''​. This limits the max read distance to ~2.5 meters, which is perfectly calibrated for indoor use and prevents the code from freezing when no echo is received.
-    UBRR0H ​(unsigned char)(ubrr >> 8); +
-    UBRR0L ​(unsigned char)ubrr; +
-    ​UCSR0B = (1 << RXEN0| (1 << TXEN0) | (1 << RXCIE0); +
-    ​UCSR0C = (1 << USBS0) | (3 << UCSZ00)// 8-bit, 2 stop bits +
-+
-</code>+
  
-<code c> +==== Optimizations and Bug Fixes ==== 
-// main.c - ISR +How, why, and where I optimized the code: 
-volatile char comanda_bt = 0;+  * **Alternating Sensor Reads:** Initially, reading both ultrasonic sensors blocked the CPU for up to 40ms per loop. I optimized this by reading only *one* sensor per frame (front, then back). This cut the blocking time in half, making the steering perfectly responsive. 
 +  * **Removed Delays:** I eliminated all ''​delay()''​ calls from the main loop, replacing them with ''​millis()''​ state machines to keep the CPU free
 +  * **The Stuttering Bug (Critical Fix):** During development,​ the car had a major bug where the motor would stutter constantly. I originally used Timer for the steering PWM and changed its prescaler from ''/​64''​ to ''/​1''​ to get more torque. **Why it broke:** Timer 0 is used internally by the framework for ''​millis()''​. Changing the prescaler made ''​millis()''​ run 64x faster than normal. This caused my 800ms safety failsafe to trigger every 12.5 real milliseconds,​ violently turning the motor on and off. **How I fixed it:** I removed the Timer 0 manipulation entirely, used simple ''​digitalWrite()''​ for steering (giving full power), and the stuttering disappeared instantly.
  
-ISR(USART_RX_vect) { +==== Novelty ==== 
-    char c UDR0; +The main element of novelty is the **Autonomous Emergency Braking (AEB)** layered on top of manual RC control. Unlike a normal RC car that crashes if you make a mistakethis car intelligently intercepts your Bluetooth commands. If you command it to drive forward into a wallthe software debounces the sensor readings and overrides your commandapplying a neutral brake to stop the car automatically. It implements a "​directional block":​ it stops you from hitting the wall in frontbut still allows you to reverse safely.
-    if (c !'​\r'​ && c !'​\n'​) comanda_bt ​c; +
-+
-</​code>​ +
-Commands: ''​F''​ Forward''​B''​ Backward''​L''​ Left''​R''​ Right, ''​S''​ Stop, ''​H''​ Horn''​1''/''​2''/''​3''​ Speed mode.+
  
-==== Lab 2 - Timers: Ultrasonic Distance ​==== +===== Custom Android Application ===== 
-**Timer 1** measures ​the HC-SR04 echo pulseAt 16MHz prescaler 8one tick = 0.5µs → ''​distance_cm = ticks / 116''​.+To control ​the rover, I developed a custom Android application from scratchInstead of relying on generic Bluetooth terminal appsthis dedicated app provides a custom user interface tailored for drivingIt features: 
 +  * A responsive joystick and button layout for steering and acceleration. 
 +  * 4 selectable speed gears (including a Turbo mode). 
 +  * Real-time telemetry: the app receives data back from the car (like sensor distances) and provides haptic feedback (vibration) when the Autonomous Emergency Braking (AEB) system is triggered.
  
-<code c> 
-// ultrasonic.c 
-uint16_t get_distance() { 
-    PORTD &= ~(1 << PD2); _delay_us(2);​ 
-    PORTD |=  (1 << PD2); _delay_us(10);​ 
-    PORTD &= ~(1 << PD2); 
- 
-    uint32_t counter = 0; 
-    while (!(PIND & (1 << PD4))) { 
-        if (++counter > 100000) return 0; 
-    } 
- 
-    TCNT1 = 0; 
-    TCCR1B = (1 << CS11); 
-    while (PIND & (1 << PD4)) { 
-        if (TCNT1 > 40000) break; 
-    } 
-    TCCR1B = 0; 
-    return TCNT1 / 116; 
-} 
-</​code>​ 
- 
-==== Lab 3 - PWM: Steering Control ==== 
-**Timer 0** in Fast PWM mode on OC0A (PD6). ''​OCR0A''​ sets duty cycle (0-255). ''​PB0''/''​PB1''​ select direction. 
- 
-<code c> 
-// motor.c 
-void motor_steering_init() { 
-    DDRD |= (1 << PD6); 
-    DDRB |= (1 << PB0) | (1 << PB1); 
-    TCCR0A = (1 << COM0A1) | (1 << WGM01) | (1 << WGM00); 
-    TCCR0B = (1 << CS01) | (1 << CS00); // prescaler 64 
-    OCR0A = 0; 
-} 
- 
-void motor_steer(int direction, uint8_t power) { 
-    OCR0A = power; 
-    if (direction == 1)       { PORTB |=  (1<<​PB0);​ PORTB &= ~(1<<​PB1);​ } 
-    else if (direction == -1) { PORTB &= ~(1<<​PB0);​ PORTB |=  (1<<​PB1);​ } 
-    else                      { PORTB &= ~(1<<​PB0);​ PORTB &= ~(1<<​PB1);​ } 
-} 
-</​code>​ 
- 
-==== Lab 4 - ADC: Automatic Headlights ==== 
-Photoresistor on **PC0 (ADC0)** in voltage divider. When dark → LEDs turn on automatically. 
- 
-<code c> 
-// adc.c 
-void adc_init() { 
-    ADCSRA = (1 << ADEN) | (7 << ADPS0); // prescaler 128 
-    ADMUX  = (1 << REFS0); ​              // AVcc reference 
-} 
- 
-uint16_t myAnalogRead(uint8_t channel) { 
-    ADMUX &= 0b11100000; 
-    ADMUX |= (channel & 0b00000111);​ 
-    ADCSRA |= (1 << ADSC); 
-    while (ADCSRA & (1 << ADSC)); 
-    return ADC; 
-} 
-</​code>​ 
- 
-==== Lab 6 - I2C: LCD Telemetry ==== 
-🔄 **In progress.** TWI hardware used at 100kHz. Registers: ''​TWBR'',​ ''​TWSR'',​ ''​TWCR'',​ ''​TWDR''​. LCD will show speed mode and distance. 
- 
- 
-==== Metrics & Targets ==== 
-^ What ^ Target ^ How ^ 
-| Command response time | < 100 ms | Oscilloscope:​ BT RX → PWM change | 
-| Distance accuracy | ±1 cm | Compare to ruler | 
-| Emergency brake | 100% at ≤ 15 cm | 20 test runs | 
-| LCD update rate | ≥ 5 Hz | Count I2C calls/​second | 
-| Headlight response | < 200 ms | Cover/​uncover sensor, time LED toggle | 
- 
-==== Key Features ==== 
-  - **Collision prevention:​** Progressive buzzer + automatic emergency brake at 15cm. 
-  - **Adaptive lighting:** Headlights react to environment automatically. 
- 
-**Planned extra:** Rear HC-SR04 for reverse parking assist. 
- 
- 
-===== Obtained Results ===== 
- 
-^ Feature ^ Status ^ 
-| Bluetooth command reception | Tested | 
-| ADC light reading | Tested | 
-| Ultrasonic distance | Tested | 
-| PWM steering (L298N) | In progress | 
-| Speed modes via ESC | In progress | 
-| Progressive buzzer | In progress | 
-| Emergency brake at 15cm | In progress | 
-| I2C LCD telemetry | In progress | 
-| Automatic headlights | In progress | 
  
  
Line 278: Line 182:
 [[https://​github.com/​cuculetz11/​PROIECT_PM_MASINUTA|PROIECT_PM_MASINUTA GitHub]] [[https://​github.com/​cuculetz11/​PROIECT_PM_MASINUTA|PROIECT_PM_MASINUTA GitHub]]
  
- 
-===== Milestone Log ===== 
-<​code>​ 
-Task                              W1  W2  W3  W4  W5  W6  W7  W8  W9 
-────────────────────────────────────────────────────────────────────── 
-Planning & chassis setup          xxx xxx 
-Validate USART, ADC, Ultrasonic ​          xxx xxx 
-PWM speed & steering control ​                     xxx xxx 
-I2C LCD + emergency brake logic                           xxx xxx 
-Final assembly & testing ​                                         xxx 
-</​code>​ 
- 
-^ Phase ^ Weeks ^ Goal ^ 
-| Planning & chassis setup | W1-W2 | Component list, schematic, chassis | 
-| Validate peripherals | W3-W4 | USART, ADC, Ultrasonic confirmed working | 
-| PWM control | W5-W6 | 3 speed modes, steering working | 
-| I2C & safety logic | W7-W8 | LCD + emergency brake at 15cm | 
-| Final assembly | W9 | Clean wiring, all metrics measured | 
  
  
Line 311: Line 197:
 ==== Tools ==== ==== Tools ====
   * **PlatformIO + VS Code**: Writing and uploading firmware   * **PlatformIO + VS Code**: Writing and uploading firmware
-  * **avr-gcc + avr-size**: Compiling and checking memory 
   * **Serial Bluetooth Terminal (Android)**:​ Sending commands from phone   * **Serial Bluetooth Terminal (Android)**:​ Sending commands from phone
  
 <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​ <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​
pm/prj2026/vlad.radulescu2901/viorel_cosmin.cucu.1778956204.txt.gz · Last modified: 2026/05/16 21:30 by viorel_cosmin.cucu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0