This shows you the differences between two versions of the page.
pm:prj2023:apredescu:pulsoximetru [2023/05/07 20:04] ioan.stan1809 [Hardware Design] |
pm:prj2023:apredescu:pulsoximetru [2023/05/28 23:59] (current) ioan.stan1809 [Concluzii] |
||
---|---|---|---|
Line 2: | Line 2: | ||
===== Introducere ===== | ===== Introducere ===== | ||
- | Proiectul acesta va masura turbiditatea din apa si va afisa pe un ecran lcd cat de pura este apa. De asemenea, se va aprinde un led RGB cu culoarea verde, galben sau rosu si va suna un buzzer. Este util deoarece poate detecta daca apa de la robinetul de acasa este buna de baut sau poate detecta cat de pura este apa unui lac. | + | This project will measure the turbidity in the water and display on an LCD screen how pure the water is. Also, a green, yellow or red RGB LED will light up and a buzzer will sound. It is useful because it can detect if the water from the tap at home is safe to drink or it can detect how pure the water in a lake is. |
- | <note tip> | + | |
- | Prezentarea pe scurt a proiectului vostru: | + | |
- | * ce face | + | |
- | * care este scopul lui | + | |
- | * care a fost ideea de la care aţi pornit | + | |
- | * de ce credeţi că este util pentru alţii şi pentru voi | + | |
- | </note> | + | |
- | ===== Descriere generală ===== | + | |
- | Voi conecta la Arduino turbidimetrul si ii voi lua valorile care vor fi procesate si transformate intr-un procentaj de la 0 la 100. Pe baza acestui procentaj se va aprinde led-ul RGB, buzzerul si va arata acest procentaj pe LCD. | + | ===== General Description ===== |
- | <note tip> | + | |
- | 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 | + | I will connect the turbidimeter to the Arduino and take the values that will be processed and transformed into a percentage from 0 to 100. Based on this percentage, the RGB led, the buzzer will light up and this percentage will be shown on the LCD. |
- | </note> | + | |
+ | |||
+ | {{ :pm:prj2023:apredescu:stan_soponaru_block_sketch.png?700 |}} | ||
+ | |||
+ | Also, here are some pictures with the completed project: | ||
+ | |||
+ | {{ :pm:prj2023:apredescu:stan_soponaru_project_poza_1.jpeg?700 |}} | ||
+ | {{ :pm:prj2023:apredescu:stan_soponaru_project_poza_2.jpeg?700 |}} | ||
+ | {{ :pm:prj2023:apredescu:stan_soponaru_project_poza_3.jpeg?700 |}} | ||
+ | {{ :pm:prj2023:apredescu:stan_soponaru_project_poza_4.jpeg?700 |}} | ||
===== Hardware Design ===== | ===== Hardware Design ===== | ||
Line 45: | Line 44: | ||
- Button \\ | - Button \\ | ||
- | <note tip> | + | {{ :pm:prj2023:apredescu:stan_soponaru_schema_electrica.png?700 |}} |
- | Aici puneţi tot ce ţine de hardware design: | + | |
- | * listă de piese | + | |
- | * scheme electrice (se pot lua şi de pe Internet şi din datasheet-uri, e.g. http://www.captain.at/electronic-atmega16-mmc-schematic.png) | + | |
- | * diagrame de semnal | + | |
- | * rezultatele simulării | + | |
- | </note> | + | |
===== Software Design ===== | ===== Software Design ===== | ||
+ | I made this project in Arduino IDE. \\ | ||
+ | Extra libraries: LiquidCrystal. \\ | ||
+ | Sources 3-rd party: I also used Tinkercad to develop the project and to test various software/hardware segments. \\ | ||
- | <note tip> | + | Several variables are also used. A debugging mode that is normally commented out is also included. The debugging mode will transform the values of the turbidity module to values that steadily increase. This should normally only be used for developing or testing the project. \\ |
- | Descrierea codului aplicaţiei (firmware): | + | |
- | * mediu de dezvoltare (if any) (e.g. AVR Studio, CodeVisionAVR) | + | I start off the software by defining all the variables, including the library and setting up the components. In the loop section of the code i have the Buzzer playing a melody for the first loop and showing a short welcome on the LCD. At the very start of the loop we can also see the Arduino reading the turbidity module's values and transforming them to values from 0 to 100. Afterwards, we test the turbidity. If the turbidity is 20 or lower, the RGB led turns red and the buzzer sings 3 lower tones. If the turbidity is 50 or lower, the RGB led turns yellow and the buzzer sings another 3 tones. If the turbidity is higher than 50, the RGB led turns green and the buzzer sings 3 other corresponding tones. During this, the LCD also shows the procentage of turbidity and a short message saying wheter |
- | * librării şi surse 3rd-party (e.g. Procyon AVRlib) | + | it's dirty, cloudy or clean. The loop will reset every 3 seconds. I have set a variable to stop repeating the same buzzing if the value is in the same category as the last loop as it can get annoying fast. |
- | * algoritmi şi structuri pe care plănuiţi să le implementaţi | + | <code> |
- | * (etapa 3) surse şi funcţii implementate | + | void loop() { |
- | </note> | + | int sensorValue = analogRead(A0); |
+ | int turbidity = map(sensorValue, 0,640, 100, 0); | ||
+ | if(turbidity < 0) turbidity = 0; | ||
+ | //for debugging only: | ||
+ | //if(i == 0) turbidity = 30; | ||
+ | //if(i != 0) {turbidity = debug_int*10; debug_int++;} | ||
+ | //if(i != 0 && debug_int>=10){turbidity = 0; debug_int=0;} | ||
+ | //end of debugging section | ||
+ | |||
+ | if(i==0){ | ||
+ | |||
+ | lcd.clear(); | ||
+ | lcd.setCursor(0, 0); | ||
+ | lcd.print("Stan Alex's"); | ||
+ | tone(13, 261, 200); //Middle C | ||
+ | setColor(luminozitate_led, luminozitate_led, luminozitate_led); | ||
+ | delay(200); | ||
+ | tone(13, 277, 200); //C# | ||
+ | delay(200); | ||
+ | tone(13, 294, 200); //D | ||
+ | delay(200); | ||
+ | tone(13, 311, 200); //D# | ||
+ | delay(200); | ||
+ | setColor(luminozitate_led, luminozitate_led, 0); | ||
+ | tone(13, 370, 200); //F# | ||
+ | delay(400); | ||
+ | setColor(0, luminozitate_led, luminozitate_led); | ||
+ | tone(13, 370, 200); //F# | ||
+ | delay(400); | ||
+ | |||
+ | lcd.clear(); | ||
+ | lcd.setCursor(0, 1); | ||
+ | lcd.print("Turbidity Meter"); | ||
+ | setColor(0, luminozitate_led, 0); | ||
+ | tone(13, 349, 200); //F | ||
+ | delay(200); | ||
+ | tone(13, 311, 200); //D# | ||
+ | delay(200); | ||
+ | tone(13, 294, 200); //D | ||
+ | delay(200); | ||
+ | setColor(0, 0, luminozitate_led); | ||
+ | tone(13, 370, 200); //F# | ||
+ | delay(400); | ||
+ | setColor(luminozitate_led, 0, 0); | ||
+ | tone(13, 370, 200); //F# | ||
+ | delay(400); | ||
+ | setColor(0, 0, 0); | ||
+ | i=1; | ||
+ | } | ||
+ | delay(3000); | ||
+ | |||
+ | if(turbidity < 21){ | ||
+ | setColor(luminozitate_led, 0, 0); | ||
+ | lcd.clear(); | ||
+ | lcd.setCursor(0, 0); | ||
+ | lcd.print("It's dirty"); | ||
+ | lcd.setCursor(0, 1); | ||
+ | lcd.print("Procent: "); lcd.print(turbidity);lcd.print(" %"); | ||
+ | |||
+ | //red | ||
+ | if(buzz==1 && stop_repetition != 40){ | ||
+ | tone(13, 330, 200); //E | ||
+ | delay(200); | ||
+ | tone(13, 294, 200); //D | ||
+ | delay(200); | ||
+ | tone(13, 261, 200); //Middle C | ||
+ | delay(200); | ||
+ | stop_repetition = 40; | ||
+ | } | ||
+ | |||
+ | } else if(turbidity < 51){ | ||
+ | setColor(luminozitate_led, luminozitate_led, 0); | ||
+ | lcd.clear(); | ||
+ | lcd.setCursor(0, 0); | ||
+ | lcd.print("It's cloudy"); | ||
+ | lcd.setCursor(0, 1); | ||
+ | lcd.print("Procent: "); lcd.print(turbidity);lcd.print(" %"); | ||
+ | |||
+ | //yellow: | ||
+ | if(buzz==1 && stop_repetition != 20){ | ||
+ | setColor(luminozitate_led, luminozitate_led, 0); | ||
+ | tone(13, 349, 200); //F | ||
+ | delay(200); | ||
+ | tone(13, 311, 200); //D# | ||
+ | delay(250); | ||
+ | tone(13, 311, 200); //D# | ||
+ | delay(150); | ||
+ | |||
+ | stop_repetition = 20; | ||
+ | } | ||
+ | setColor(luminozitate_led, luminozitate_led, 0); | ||
+ | } else{ | ||
+ | setColor(0, luminozitate_led, 0); | ||
+ | lcd.clear(); | ||
+ | lcd.setCursor(0, 0); | ||
+ | lcd.print("It's clean"); | ||
+ | lcd.setCursor(0, 1); | ||
+ | lcd.print("Procent: "); lcd.print(turbidity);lcd.print(" %"); | ||
+ | setColor(0, luminozitate_led, 0); | ||
+ | //green: | ||
+ | if(buzz==1 && stop_repetition != 30){ | ||
+ | setColor(0, luminozitate_led, 0); | ||
+ | tone(13, 392, 200); //G | ||
+ | delay(200); | ||
+ | tone(13, 370, 200); //F# | ||
+ | delay(200); | ||
+ | tone(13, 392, 200); //G | ||
+ | delay(200); | ||
+ | |||
+ | stop_repetition = 30; | ||
+ | } | ||
+ | setColor(0, luminozitate_led, 0); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | </code> | ||
+ | |||
+ | We will now talk about the functions used: \\ | ||
+ | I used a function to set the color of the RGB led to whatever is received through 3 parameters, the Red Value, the Green Value and the Blue Value. This function then sets the intensity of each pin accordingly. | ||
+ | |||
+ | <code> | ||
+ | void setColor(int redValue, int greenValue, int blueValue) { | ||
+ | analogWrite(led_Rosu, 255-redValue); | ||
+ | analogWrite(led_Verde, 255-greenValue); | ||
+ | analogWrite(led_Albastru, 255-blueValue); | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | I used another function to interrupt the normal ongoing processes of the loop and set a variable used to activate/deactivate the buzzer when the button is pressed. | ||
+ | |||
+ | <code> | ||
+ | void ISR_button(){ | ||
+ | if(buzz == 1){ | ||
+ | buzz =0; | ||
+ | } | ||
+ | else{buzz = 1;} | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Obtained Results ===== | ||
+ | |||
+ | After completing this project, i managed to create a functional turbidity meter with a bunch of add-ons. I have also understood a lot better how all the components in my project can work together to achieve something great. I have managed to create an algorithm that will take all these separate components and make them work perfectly together. | ||
- | ===== Rezultate Obţinute ===== | ||
- | <note tip> | ||
- | Care au fost rezultatele obţinute în urma realizării proiectului vostru. | ||
- | </note> | ||
===== Concluzii ===== | ===== Concluzii ===== | ||
+ | |||
+ | We can measure the purity of water with a nice interface and a friendly environment =) | ||
===== Download ===== | ===== Download ===== | ||
- | <note warning> | ||
- | 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> | ||
+ | {{ pm:prj2023:apredescu:turbidity_meter_v2.zip }} | ||
===== Jurnal ===== | ===== Jurnal ===== | ||