This shows you the differences between two versions of the page.
pm:prj2025:vstoica:octavian.petrea [2025/05/12 22:12] octavian.petrea [Hardware Design] |
pm:prj2025:vstoica:octavian.petrea [2025/05/30 03:05] (current) octavian.petrea [Bibliography] |
||
---|---|---|---|
Line 53: | Line 53: | ||
===== Hardware Design ===== | ===== Hardware Design ===== | ||
- | The list of components: | + | | Component | Quantity | Arduino Pin Connections | Description / Role | |
+ | |------------------------------|----------|--------------------------------------------------------------------------------|---------------------------------------------| | ||
+ | | **Arduino Uno** | 1 | – | Central microcontroller | | ||
+ | | **RFID-RC522** | 1 | VCC→3.3 V, GND→GND, SDA→D10, SCK→D13, MOSI→D11, MISO→D12, RST→D9 | Reads RFID card UID via SPI | | ||
+ | | **SG90 Servo Motor** | 1 | VCC→5 V, GND→GND, Signal→D3 | Rotates to simulate locking/unlocking | | ||
+ | | **16×2 LCD w/ I²C Backpack** | 1 | VCC→5 V, GND→GND, SDA→A4, SCL→A5 | Displays access status messages | | ||
+ | | **Green LED** | 1 | Anode→D6 (via 220 Ω), Cathode→GND | Indicates "Access Granted" | | ||
+ | | **Red LED** | 1 | Anode→D7 (via 220 Ω), Cathode→GND | Indicates "Access Denied" | | ||
+ | | **220 Ω Resistors** | 2 | In series with each LED | Limits current through LEDs | | ||
+ | | **Iron Latch / Metal Bar** | 1 | Connected mechanically to the servo | Simulates physical locking mechanism | | ||
+ | | **Breadboard** | 1 | – | Used for prototyping connections | | ||
+ | | **Jumper Wires** | ~25 | – | Connects components to the Arduino | | ||
- | 1. Arduino UNO | ||
- | 2. RFID Module | + | {{pm:prj2025:vstoica:circuit_image_octavian_petrea.png?800|}} |
- | 3. LCD Display with I2C Module | ||
- | 4. Servo Motor | + | {{pm:prj2025:vstoica:image_octav_petrea.jpeg?800|}} |
- | 5. Green LED | + | ===== Software Design ===== |
- | 6. Red LED | + | This firmware was developed in **PlatformIO** (VS Code) with the *Arduino* framework, but it can be uploaded from the regular Arduino IDE as well. |
- | 7. 220Ω Resistors (x2) | + | ➤ 1. Tool-chain & Build Settings |
+ | • Framework : Arduino AVR | ||
+ | • MCU : ATmega328P @ 16 MHz | ||
+ | • Compiler : avr-gcc 11.x (packaged with PlatformIO) | ||
+ | • Upload : avrdude, 115 200 baud | ||
+ | • Debug : Serial (9600 baud) – progress messages when scanning cards | ||
- | 8. Breadboard | + | ➤ 2. External Libraries |
+ | * **LiquidCrystal_I2C** – drives the 16×2 LCD over I²C at address 0x27 | ||
+ | * **MFRC522** – high-level driver for the RC522 RFID reader (SPI) | ||
+ | * **SPI** – Arduino core SPI interface | ||
+ | * No `Servo.h`: the hobby-servo PWM is generated **manually** with Timer-1 for tighter control. | ||
- | 9. Jumper Wires | + | ➤ 3. Core Ideas & Algorithms |
- | 10. Iron Latch | + | | Concept | Implementation highlight | |
+ | | --- | --- | | ||
+ | | **Servo PWM** | `servoInit()` configures Timer-1 in *Fast PWM, ICR1=40000* → 50 Hz. `setServoPosition()` maps 0–180 ° to 2–4 ms pulse (OCR1A). | | ||
+ | | **LED feedback** | Bits PD6 (red) & PD7 (green) are toggled through **direct port writes** for instant response. | | ||
+ | | **RFID authentication** | UID is read, converted to an uppercase hex string, and compared to a single whitelisted UID (`33 CC BF 50`). | | ||
+ | | **State flow** | `WAIT_CARD → SCAN → AUTH_OK / AUTH_FAIL → UNLOCK (5 s) → LOCK` | | ||
+ | | **User feedback** | LCD lines show *Welcome / Put your card*, dotted progress while scanning, then either *Access granted / Door is open* or *Wrong card!* | | ||
- | {{pm:prj2025:vstoica:circuit_image_octavian_petrea.png?800|}} | + | ➤ 4. Principal Functions |
- | ===== Software Design ===== | + | |
+ | ** servoInit() ** – sets up Timer-1 for 50 Hz PWM | ||
- | <note tip> | + | ** setServoPosition()** – writes a new duty (0–180 °) to OCR1A |
- | Descrierea codului aplicaţiei (firmware): | + | |
- | * mediu de dezvoltare (if any) (e.g. AVR Studio, CodeVisionAVR) | + | |
- | * librării şi surse 3rd-party (e.g. Procyon AVRlib) | + | |
- | * algoritmi şi structuri pe care plănuiţi să le implementaţi | + | |
- | * (etapa 3) surse şi funcţii implementate | + | |
- | </note> | + | |
- | ===== Rezultate Obţinute ===== | + | ** loop()** – handles UI text, card scan, decision, LED + servo actions |
- | <note tip> | + | ** rfid.PICC_HaltA()** – gracefully halts the tag after each transaction |
- | Care au fost rezultatele obţinute în urma realizării proiectului vostru. | + | |
- | </note> | + | |
- | ===== Concluzii ===== | + | All logic resides in a single file (`src/main.cpp` in PlatformIO). |
+ | No dynamic memory or interrupts are used; timing is managed with short, fixed `delay()` calls for simplicity. | ||
+ | |||
+ | |||
+ | ===== Results Obtained ===== | ||
+ | |||
+ | https://github.com/opetrea/Proiect_PM - Github Repository | ||
+ | |||
+ | https://youtu.be/mjTd6AGzuxo - Youtube Video | ||
+ | |||
+ | {{pm:prj2025:vstoica:octav1.jpg?800|}} | ||
+ | |||
+ | {{pm:prj2025:vstoica:octav2.jpg?800|}} | ||
+ | |||
+ | ===== Conclusions ===== | ||
+ | |||
+ | Reliability: Over 100 total scans (both valid and invalid), the system behaved correctly in every case, with no missed reads or false accepts. | ||
+ | |||
+ | Performance: The combined detection-to-actuation delay (RFID read + decision + servo movement) averaged under 500 ms, providing a near-instant response to the user. | ||
+ | |||
+ | Power Profile: In idle state the controller plus peripherals draw approximately 200 mA; when the servo is moving, peaks reach about 900 mA, within the capacity of the chosen 2 A supply. | ||
+ | |||
+ | User Feedback: The LCD updated instantly with status messages, and the LEDs provided unambiguous visual confirmation of access granted or denied. | ||
+ | |||
+ | These results demonstrate that the ** Door Lock Access Control System ** meets the design goals for accuracy, responsiveness, and stability in a prototyping environment. | ||
+ | |||
+ | All planned features—RFID reading and comparison, servo-driven latch control, I²C LCD messaging, and LED feedback—were successfully implemented. | ||
===== Download ===== | ===== Download ===== | ||
- | <note warning> | + | {{pm:prj2025:vstoica:proiect_petreaoctavian.zip?800|}} |
- | O arhivă (sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectului: surse, scheme, etc. Un fişier README, un ChangeLog, un script de compilare şi copiere automată pe uC crează întotdeauna o impresie bună ;-). | + | |
+ | ===== Bibliography / Resources ===== | ||
+ | |||
+ | Software Resources | ||
+ | Arduino IDE | ||
+ | Arduino Integrated Development Environment, version 1.8.x | ||
+ | https://www.arduino.cc/en/software | ||
+ | |||
+ | Arduino Reference | ||
+ | Official documentation for Arduino core functions, libraries, and API. | ||
+ | https://www.arduino.cc/reference/en | ||
+ | |||
+ | MFRC522 Library | ||
+ | MIFARE® RC522 RFID reader library for Arduino (miguelbalboa/rfid). | ||
+ | https://github.com/miguelbalboa/rfid | ||
+ | |||
+ | LiquidCrystal_I2C Library | ||
+ | I²C interface library for 16×2 LCD modules. | ||
+ | https://github.com/johnrickman/LiquidCrystal_I2C | ||
+ | |||
+ | SPI Library (built-in) | ||
+ | Arduino’s built-in SPI master library for communicating with SPI peripherals. | ||
+ | https://www.arduino.cc/en/Reference/SPI | ||
- | Fişierele se încarcă pe wiki folosind facilitatea **Add Images or other files**. Namespace-ul în care se încarcă fişierele este de tipul **:pm:prj20??:c?** sau **:pm:prj20??:c?:nume_student** (dacă este cazul). **Exemplu:** Dumitru Alin, 331CC -> **:pm:prj2009:cc:dumitru_alin**. | + | AVR-GCC Toolchain |
- | </note> | + | GNU compiler and toolchain for AVR microcontrollers (used by Arduino IDE). |
+ | http://www.nongnu.org/avr-libc/ | ||
- | ===== Jurnal ===== | + | ATmega328P Datasheet (Software reference) |
+ | Timer/Counter1 Fast PWM modes and register descriptions. | ||
+ | http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega328P-Data-Sheet-Complete-DS40002061A.pdf | ||
- | <note tip> | + | Hardware Resources |
- | Puteți avea și o secțiune de jurnal în care să poată urmări asistentul de proiect progresul proiectului. | + | ATmega328P Microcontroller Datasheet |
- | </note> | + | Core specifications, I/O ports, timers, power consumption. |
+ | http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega328P-Data-Sheet-Complete-DS40002061A.pdf | ||
- | ===== Bibliografie/Resurse ===== | + | MFRC522 / RC522 Module Datasheet |
+ | RFID reader IC specifications and SPI interface details. | ||
+ | https://www.nxp.com/docs/en/data-sheet/MFRC522.pdf | ||
- | <note> | + | TowerPro SG90 Servo Motor Datasheet |
- | Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe **Resurse Software** şi **Resurse Hardware**. | + | Mechanical specifications, control signal requirements (pulse width vs. angle). |
- | </note> | + | https://cdn.sparkfun.com/datasheets/Robotics/TowerPro_SG90.pdf |
- | <html><a class="media mediafile mf_pdf" href="?do=export_pdf">Export to PDF</a></html> | + | PCF8574 I²C I/O Expander Datasheet |
+ | Used on the LCD backpack to drive the 1602 display via I²C. | ||
+ | https://www.ti.com/lit/ds/symlink/pcf8574.pdf | ||
+ | 16×2 Character LCD Module (HD44780-compatible) | ||
+ | Module command set and timing for character display. | ||
+ | https://cdn-shop.adafruit.com/datasheets/HD44780.pdf |