Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI PTC3471 USBDevice
Revision 10:6e0e1309cdf8, committed 2020-11-20
- Comitter:
- lcaepusp
- Date:
- Fri Nov 20 16:47:22 2020 +0000
- Parent:
- 7:661ef6a3c052
- Commit message:
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 22 16:48:09 2020 +0000
+++ b/main.cpp Fri Nov 20 16:47:22 2020 +0000
@@ -4,7 +4,7 @@
#include "PTC3471.h"
#define Ts 0.01 //periodo de amostragem
-#define pi 3.14159
+#define Pi 3.14159265
/******************************************************************************/
/**************** Definição de Variaveis, Objetos e Funções ******************/
@@ -174,17 +174,17 @@
th1_a=th1;
/** Leituras cruas dos ângulos do encoder **/
- phi0 = pi*Encoder_Motor.getPulses()/600.0; // (eventos_lidos/eventos_por_volta)*2*pi = angulo_em_radianos
- phi1 = pi*Encoder_Pendulo.getPulses()/1200.0; // (eventos_lidos/eventos_por_volta)*360 = angulo_em_graus
+ phi0 = Pi*Encoder_Motor.getPulses()/600.0; // (eventos_lidos/eventos_por_volta)*2*pi = angulo_em_radianos
+ phi1 = Pi*Encoder_Pendulo.getPulses()/1200.0; // (eventos_lidos/eventos_por_volta)*360 = angulo_em_graus
th0 = phi0;
/** Tratamento do ângulo lido para ser zero na vertical para cima **/
// Como o encoder é incremental quando inicializamos o programa com o pêndulo na posição
if(phi1>0) // vertical para baixo esta passa a ser lida como 0º. Porém, para o algoritmo de controle
- th1 = phi1-pi; // funcionar corretamente 0º deve ser o pêndulo na posição vertical para cima. Para
+ th1 = phi1-Pi; // funcionar corretamente 0º deve ser o pêndulo na posição vertical para cima. Para
// garantir que isso aconteça subido o pêndulo no sentido horário ou anti-horário fazemos
else if(phi1<=0) // th1 = th1-sgn(th1)*pi, onde sgn(x) é o sinal de x.
- th1 = phi1+pi; // Para ficar mais claro o funcionamento destes "if else" plote o sinal de th1 no tera term
+ th1 = phi1+Pi; // Para ficar mais claro o funcionamento destes "if else" plote o sinal de th1 no tera term
// Filtro (1/tau*s +1) nos angulos
th0_f = (tau/(Ts+tau))*th0_f + (Ts/(Ts+tau))*th0;