Biblioteca PTC3471 - Algoritmo de Trava - V1.0
Dependents: Template_PTC3471_Geral LQR_With_Integrator_Implicito LQR_No_Integrator_Implicito Template_PTC3471_Geral_2020_V2 ... more
Fork of PTC3471 by
Diff: PTC3471.cpp
- Revision:
- 2:01fdfdb7b853
- Parent:
- 1:00b8f71cfe7e
- Child:
- 3:1352c868f1fd
diff -r 00b8f71cfe7e -r 01fdfdb7b853 PTC3471.cpp --- a/PTC3471.cpp Mon Aug 07 22:32:23 2017 +0000 +++ b/PTC3471.cpp Thu Aug 10 12:19:56 2017 +0000 @@ -18,6 +18,7 @@ double Ctrl_Phi = 0; double Ctrl_Phi1 = 0; double Ctrl_dPhi = 0; +double LimitAngle = 0; void Ctrl_LerAngulos(void){ Ctrl_Phi1 = Ctrl_Phi; @@ -53,7 +54,7 @@ void Ctrl_ChecarTrava(void){ Ctrl_LerAngulos(); - if(Ctrl_Phi>pi || Ctrl_Phi<-pi){ + if(Ctrl_Phi>LimitAngle || Ctrl_Phi<-LimitAngle){ Ctrl_StatusOk.detach(); Ctrl_Trava.detach(); Controler_Interrupt->detach(); @@ -65,12 +66,17 @@ Ctrl_Status = !Ctrl_Status; } -void Protecao_Init(QEI* Encoder_Motor, Ticker* Control_Interrupt){ +void Protecao_Init(QEI* Encoder_Motor, Ticker* Control_Interrupt, double angle){ + Ctrl_Encoder_Motor = Encoder_Motor; Controler_Interrupt = Control_Interrupt; + LimitAngle = angle; + Ctrl_Status = 1; Ctrl_StatusOk.attach(&Ctrl_BlinkOk, 1); - Ctrl_Trava.attach(&Ctrl_ChecarTrava, Ctrl_Ts); + + if(LimitAngle>0) + Ctrl_Trava.attach(&Ctrl_ChecarTrava, Ctrl_Ts); Ctrl_Motor = 0.0; Ctrl_Direita = 0;