This shows you the differences between two versions of the page.
pm:prj2023:vstoica:andradacojocaru [2023/05/27 20:36] andrada.cojocaru [Download] |
pm:prj2023:vstoica:andradacojocaru [2023/05/30 08:22] (current) andrada.cojocaru [Software Design] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Solar tracker - Andrada Cojocaru ====== | + | ====== Solar tracker - Andrada Cojocaru ☀️====== |
===== Proiect PM - 2023 ===== | ===== Proiect PM - 2023 ===== | ||
Student: Andrada-Ioana Cojocaru\\ | Student: Andrada-Ioana Cojocaru\\ | ||
Line 69: | Line 69: | ||
Descrierea codului aplicaţiei (firmware): | Descrierea codului aplicaţiei (firmware): | ||
* **mediu de dezvoltare**: Arduino IDE 2.1.0 | * **mediu de dezvoltare**: Arduino IDE 2.1.0 | ||
- | * **librării**: Wire.h, LiquidCrystal_I2C.h, servo.h (initial, dupa am facut propriile functii) | + | * **biblioteci**: Wire.h, LiquidCrystal_I2C.h, servo.h (initial, dupa am facut propriile functii) |
</note> | </note> | ||
- | Declararea librariilor | + | Declararea bibliotecilor |
<code c> | <code c> | ||
#include <Wire.h> | #include <Wire.h> | ||
Line 104: | Line 104: | ||
Declararea variabilelor globale pentru miscarea servo-motoarelor - de aici pornesc | Declararea variabilelor globale pentru miscarea servo-motoarelor - de aici pornesc | ||
<code c> | <code c> | ||
- | int servoRightLeftPos = 45; | + | int servoRightLeftPos = 35; |
- | int servoUpDownPos = 90; | + | int servoUpDownPos = 76; |
</code> | </code> | ||
Line 146: | Line 146: | ||
// set where the servo start | // set where the servo start | ||
- | servoRightLeftPos = 45; | + | servoRightLeftPos = 35; |
- | servoUpDownPos = 90; | + | servoUpDownPos = 76; |
setServoAngle(SERVO_RIGHT_LEFT_PIN, servoRightLeftPos); | setServoAngle(SERVO_RIGHT_LEFT_PIN, servoRightLeftPos); | ||
setServoAngle(SERVO_UP_DOWN_PIN, servoUpDownPos); | setServoAngle(SERVO_UP_DOWN_PIN, servoUpDownPos); | ||
Line 157: | Line 157: | ||
**Loop** - citim ldr-urile si in functie de valorile obtinute calculam media celor de sus, de jos, dreapta, stanga si apoi diferenta dreapta-stanga, sus-jos si observam daca valoarea e mai mare decat toleranta, caz in care trebuie sa mutam pozitia ansamblului.\\ | **Loop** - citim ldr-urile si in functie de valorile obtinute calculam media celor de sus, de jos, dreapta, stanga si apoi diferenta dreapta-stanga, sus-jos si observam daca valoarea e mai mare decat toleranta, caz in care trebuie sa mutam pozitia ansamblului.\\ | ||
Am determinat experimental valorile intre care trebuie servo-motoarele mutate: | Am determinat experimental valorile intre care trebuie servo-motoarele mutate: | ||
- | * pt cel dreapta-stanga 0 - 90 | + | * pt cel dreapta-stanga -10 - 60 |
- | * pt cel sus-jos 60 - 110 | + | * pt cel sus-jos 76 - 96 |
In functie de pozitia soarelui sau absenta lui am afisat mesaje relevante pe lcd: | In functie de pozitia soarelui sau absenta lui am afisat mesaje relevante pe lcd: | ||
* Est jos -> dimineata | * Est jos -> dimineata | ||
Line 186: | Line 186: | ||
if (abs(diffrightleft) >= TOLERANCE) { | if (abs(diffrightleft) >= TOLERANCE) { | ||
if (diffrightleft < 0) { | if (diffrightleft < 0) { | ||
- | if (servoRightLeftPos < 90) { | + | if (servoRightLeftPos <= 60) { |
servoRightLeftPos++; | servoRightLeftPos++; | ||
setServoAngle(SERVO_RIGHT_LEFT_PIN, servoRightLeftPos); | setServoAngle(SERVO_RIGHT_LEFT_PIN, servoRightLeftPos); | ||
} | } | ||
} else if (diffrightleft > 0) { | } else if (diffrightleft > 0) { | ||
- | if (servoRightLeftPos > 0) { | + | if (servoRightLeftPos >= -10) { |
servoRightLeftPos--; | servoRightLeftPos--; | ||
setServoAngle(SERVO_RIGHT_LEFT_PIN, servoRightLeftPos); | setServoAngle(SERVO_RIGHT_LEFT_PIN, servoRightLeftPos); | ||
Line 201: | Line 201: | ||
if (abs(difftopbottom) >= TOLERANCE) { | if (abs(difftopbottom) >= TOLERANCE) { | ||
if (difftopbottom < 0) { | if (difftopbottom < 0) { | ||
- | if (servoUpDownPos < 110) { | + | if (servoUpDownPos <= 96) { |
servoUpDownPos+=5; | servoUpDownPos+=5; | ||
setServoAngle(SERVO_UP_DOWN_PIN, servoUpDownPos); | setServoAngle(SERVO_UP_DOWN_PIN, servoUpDownPos); | ||
} | } | ||
} else if (difftopbottom > 0) { | } else if (difftopbottom > 0) { | ||
- | if (servoUpDownPos > 60) { | + | if (servoUpDownPos >= 76) { |
servoUpDownPos-=5; | servoUpDownPos-=5; | ||
setServoAngle(SERVO_UP_DOWN_PIN, servoUpDownPos); | setServoAngle(SERVO_UP_DOWN_PIN, servoUpDownPos); |