Dependencies: mbed
Diff: JOG_EIXO_Z.cpp
- Revision:
- 17:f3a45eeb1a7e
- Parent:
- 16:8c6cbd446ae8
- Child:
- 18:1374daf4e6a3
--- a/JOG_EIXO_Z.cpp Tue May 18 16:19:53 2021 +0000 +++ b/JOG_EIXO_Z.cpp Wed May 19 17:00:31 2021 +0000 @@ -3,9 +3,9 @@ Serial pc (USBTX, USBRX); -AnalogIn eixo_Z(A0); +AnalogIn eixo_Z(PC_2); InterruptIn posicao_salva(PA_15); -InterruptIn botao_emergencia(PB_10); +InterruptIn botao_emergencia(PC_4); BusOut motor_z(PB_1, PB_15, PB_14, PB_13); @@ -24,6 +24,7 @@ void rotina_emergencia(void); void rotida_velocidade_eixo_Z(void); void rotida_deslocamento_eixo_Z (void); +void rotida_aciona_motor (void); @@ -43,35 +44,7 @@ pc.printf("Z=%4d, PegaZ=%4d, Posicao_salva_estado=%d, Botao_emergencia_estado=%d, Tempo1=%4f, Tempo2=%4f, Pulsos=%d, Deslocamento_Z=%f, Velocidade_Z=%f\r\n", J_Z, pegaZ, posicao_salva_estado, botao_emergencia_estado, tempo_horario, tempo_anti_horario, pulsos_anti_horario, deslocamento_total_Z, velocidade_Z); - if(31000 <= J_Z & J_Z <= 35000) { - - motor_z = 0x00; - - } else { - if (J_Z > 31000) { - for(i = 0; i < 4; i++) { - motor_z = 1 << i; - rotida_velocidade_eixo_Z(); - rotida_deslocamento_eixo_Z(); - wait(tempo_horario); - pulsos_horario+=1; - velocidade_Z = deslocamento_horario_Z/tempo_horario; - - } - } - - if(J_Z < 35000) { - for(i = 3; i > -1; i--) { - motor_z = 1 << i; - rotida_velocidade_eixo_Z(); - rotida_deslocamento_eixo_Z(); - wait(tempo_anti_horario); - pulsos_anti_horario+=1; - velocidade_Z = deslocamento_horario_Z/tempo_horario; - - } - } - } + rotida_aciona_motor(); } } @@ -99,4 +72,39 @@ deslocamento_horario_Z = (passo_fuso*pulsos_horario*passo_motor)/360; deslocamento_anti_horario_Z = (passo_fuso*pulsos_anti_horario*passo_motor)/360; deslocamento_total_Z = deslocamento_anti_horario_Z - deslocamento_horario_Z; +} + + +void rotida_aciona_motor() +{ + + if(31000 <= J_Z & J_Z <= 35000) { + + motor_z = 0x00; + + } else { + if (J_Z > 31000) { + for(i = 0; i < 4; i++) { + motor_z = 1 << i; + rotida_velocidade_eixo_Z(); + rotida_deslocamento_eixo_Z(); + wait(tempo_horario); + pulsos_horario+=1; + velocidade_Z = deslocamento_horario_Z/tempo_horario; + + } + } + + if(J_Z < 35000) { + for(i = 3; i > -1; i--) { + motor_z = 1 << i; + rotida_velocidade_eixo_Z(); + rotida_deslocamento_eixo_Z(); + wait(tempo_anti_horario); + pulsos_anti_horario+=1; + velocidade_Z = deslocamento_horario_Z/tempo_horario; + + } + } + } } \ No newline at end of file