Codigo comentado da IronCup 01/03/2020
Dependencies: mbed
Diff: main.cpp
- Revision:
- 11:4f3dcdd4d8ce
- Parent:
- 10:d546eec37792
- Child:
- 12:00ba3be0d995
--- a/main.cpp Thu Feb 27 00:01:42 2020 +0000 +++ b/main.cpp Fri Feb 28 16:53:10 2020 +0000 @@ -44,9 +44,9 @@ //============== VARIAVEIS MAIS IMPORTANTES ================// //Separadas do resto para facilitar a alteração -float ParametroCorrecao = 1.2; //1.1 // 4.63 // 2 ----> 1.2 -float Kp_Sensor = 0.55; //0.14; //0.2 //0.4 // 0.2 // 0.35--->0.55 -float Kd_Sensor = 7.2; //1.75; //1.15 //0.6 // 2.7 // 4.3 --->7.2 +float ParametroCorrecao = 1.02; //1.1 // 4.63 // 2 ----> 1.15 +float Kp_Sensor = 0.64; //0.14; //0.2 //0.4 // 0.2 // 0.35--->0.55--0.7 +float Kd_Sensor = 8.8; //1.75; //1.15 //0.6 // 2.7 // 4.3 --->7.2--8.4 float BaseSpeed = 0.18; //0.12 // 0.15 // 0.18--->0.18 //==========================================================// @@ -146,12 +146,25 @@ } void Leitura_Sensores (void){ //Faz a leitura dos sensores e retorna a posição - int leitura[8]={0,0,0,0,1,0,0,0}; // leitura representa os sensores lidos,onde 1 é branco e 0 é preto + int leitura[8]={0,0,0,0,1,0,1,0}; // leitura representa os sensores lidos,onde 1 é branco e 0 é preto for (int i=0;i<8;i++){leitura[i] = sensorCheck(i);} // leitura dos sensores //analizando a leitura e setando a posição - if (leitura[3]== 1 && leitura[4] == 1) {Position = 45;} //Se ler os dois do meio, está no SetPoint - else if (leitura[2]== 1 && leitura[5] == 1) {Position = 45;} + //if (leitura[3]== 1 && leitura[4] == 1) {Position = 45;} //Se ler os dois do meio, está no SetPoint + if (leitura[2]== 1 && leitura[5] == 1) {Position = 45;} else if (leitura[1]== 1 && leitura[6] == 1) {Position = 45;} + else if (leitura[2]== 1 && leitura[3] == 1) {Position = 45;} + else if (leitura[2]== 1 && leitura[6] == 1) {Position = 45;} + else if (leitura[3]== 1 && leitura[5] == 1) {Position = 45;} + else if (leitura[1]== 1 && leitura[5] == 1) {Position = 45;} + else if (leitura[1]==1) {Position = 20;} + else if (leitura[6]==1) {Position = 70;} + else if (leitura[0]==1) {Position = 10;} + else if (leitura[7]==1) {Position = 80;} + else if (leitura[2]==1) {Position = 30;} + else if (leitura[5]==1) {Position = 60;} + else if (leitura[3]==1) {Position = 40;} + else if (leitura[4]==1) {Position = 50;} + /* else if (leitura[3]==1) {Position = 40;} else if (leitura[2]==1) {Position = 30;} else if (leitura[5]==1) {Position = 60;} @@ -160,6 +173,8 @@ else if (leitura[0]==1) {Position = 10;} else if (leitura[7]==1) {Position = 80;} else if (leitura[4]==1) {Position = 50;} + */ + //else {Final_Stop();} //pc.printf("\n\rPosicao: %d", Position); //Print de teste }