This shows you the differences between two versions of the page.
pm:prj2024:ddosaru:robert.fluture [2024/05/15 23:35] robert.fluture [Introducere] |
pm:prj2024:ddosaru:robert.fluture [2024/05/27 10:56] (current) robert.fluture [Download] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Heart Rate Monitoring Device ====== | + | ====== Fluture Robert - Heart Rate Monitoring Device ====== |
===== Introducere ===== | ===== Introducere ===== | ||
Line 10: | Line 10: | ||
===== Descriere generală ===== | ===== Descriere generală ===== | ||
- | <note tip> | + | {{:pm:prj2024:ddosaru:schemahm.png?550|}} |
- | O schemă bloc cu toate modulele proiectului vostru, atât software cât şi hardware însoţită de o descriere a acestora precum şi a modului în care interacţionează. | + | |
- | + | ||
- | Exemplu de schemă bloc: http://www.robs-projects.com/mp3proj/newplayer.html | + | |
- | </note> | + | |
===== Hardware Design ===== | ===== Hardware Design ===== | ||
<note tip> | <note tip> | ||
- | Aici puneţi tot ce ţine de hardware design: | + | Lista Componente: |
- | * listă de piese | + | * Arduino |
- | * scheme electrice (se pot lua şi de pe Internet şi din datasheet-uri, e.g. http://www.captain.at/electronic-atmega16-mmc-schematic.png) | + | * Microcontroller to read sensor data and control LEDs. |
- | * diagrame de semnal | + | * Heart Rate Sensor (HW-827) |
- | * rezultatele simulării | + | * Sensor to measure the heart rate. |
+ | * 8 LEDs | ||
+ | * LEDs to display heart rate intensity in a loading bar format. | ||
+ | * 220-ohm Resistors (8) | ||
+ | * To limit current through the LEDs. | ||
+ | * Breadboard | ||
+ | * To make the circuit connections. | ||
+ | * Jumper Wires | ||
+ | * To connect components on the breadboard and to the Arduino. | ||
+ | * Power Source | ||
+ | * USB cable for Arduino power or a battery pack. | ||
</note> | </note> | ||
+ | |||
+ | {{:pm:prj2024:ddosaru:brilliant_amur-bombul.png?800|}} | ||
+ | {{:pm:prj2024:ddosaru:20240517_170227.jpg?800|}} | ||
===== Software Design ===== | ===== Software Design ===== | ||
- | <note tip> | + | <file cpp main.cpp> |
- | Descrierea codului aplicaţiei (firmware): | + | |
- | * mediu de dezvoltare (if any) (e.g. AVR Studio, CodeVisionAVR) | + | #include "I2Cdev.h" |
- | * librării şi surse 3rd-party (e.g. Procyon AVRlib) | + | #include <LiquidCrystal_I2C.h> |
- | * algoritmi şi structuri pe care plănuiţi să le implementaţi | + | |
- | * (etapa 3) surse şi funcţii implementate | + | MPU6050 mpu; |
- | </note> | + | |
+ | const int heartRatePin = A0; | ||
+ | const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9}; | ||
+ | volatile int heartRate = 0; | ||
+ | int intensity = 0; | ||
+ | unsigned long previousMillis = 0; | ||
+ | const long interval = 500; // Interval for updating the LED display | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(9600); | ||
+ | for (int i = 0; i < 8; i++) { | ||
+ | pinMode(ledPins[i], OUTPUT); | ||
+ | } | ||
+ | |||
+ | // Configure timer interrupt | ||
+ | Timer1.initialize(1000000); // Set timer to 1 second | ||
+ | Timer1.attachInterrupt(timerISR); // Attach timer interrupt service routine | ||
+ | |||
+ | // Enable ADC interrupt | ||
+ | ADCSRA |= (1 << ADIE); | ||
+ | sei(); // Enable global interrupts | ||
+ | } | ||
+ | |||
+ | ISR(ADC_vect) { | ||
+ | heartRate = ADC; // Read the ADC value | ||
+ | intensity = map(heartRate, 0, 1023, 0, 255); // Map heart rate to LED intensity | ||
+ | } | ||
+ | |||
+ | void timerISR() { | ||
+ | // Trigger ADC conversion | ||
+ | ADCSRA |= (1 << ADSC); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | unsigned long currentMillis = millis(); | ||
+ | if (currentMillis - previousMillis >= interval) { | ||
+ | previousMillis = currentMillis; | ||
+ | |||
+ | // Update LED display | ||
+ | int numLeds = map(heartRate, 0, 1023, 0, 8); | ||
+ | for (int i = 0; i < 8; i++) { | ||
+ | if (i < numLeds) { | ||
+ | analogWrite(ledPins[i], intensity); | ||
+ | } else { | ||
+ | digitalWrite(ledPins[i], LOW); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </file> | ||
+ | |||
+ | Întreruperea ADC: întreruperea ADC (Convertor analog-digital) este activată pentru a gestiona citirile ritmului cardiac. | ||
+ | Timer Interrupt: Timer1 este configurat să declanșeze o întrerupere la fiecare secundă, pornind o conversie ADC. | ||
+ | Manipularea intensității: | ||
+ | |||
+ | Intensitatea LED-urilor este mapată din citirile senzorului de ritm cardiac folosind funcția map(). Aceasta controlează luminozitatea LED-urilor folosind PWM. | ||
+ | Temporizator de actualizare LED: | ||
+ | |||
+ | Funcția millis() este utilizată pentru a actualiza periodic afișajul LED la fiecare 500 de milisecunde. | ||
===== Rezultate Obţinute ===== | ===== Rezultate Obţinute ===== | ||
Line 47: | Line 115: | ||
===== Download ===== | ===== Download ===== | ||
- | <note warning> | + | {{:pm:prj2024:ddosaru:heartrate.zip|}} |
- | 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ă ;-). | + | |
- | + | ||
- | 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**. | + | |
- | </note> | + | |
===== Jurnal ===== | ===== Jurnal ===== |