![](/media/cache/group/9e3cc099b3b04bca937a1cca1da81b19.jpg.50x50_q85.jpg)
Moet dit er bij
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 14:8aa57a7c5b30
- Parent:
- 13:41fc5b6262c0
- Child:
- 15:75070aedf4b7
--- a/main.cpp Tue Oct 29 21:33:42 2019 +0000 +++ b/main.cpp Wed Oct 30 12:52:26 2019 +0000 @@ -22,7 +22,7 @@ DigitalIn encB2(D13); QEI encoder1(D9,D8,NC,64,QEI::X4_ENCODING); //Encoding motor 1 QEI encoder2(D13,D12,NC,64,QEI::X4_ENCODING); //Encoding motor 2 -float Ts = 0.01; //Sample time +float Ts = 0.002; //Sample time float deg2rad=0.0174532; //Conversion factor degree to rad float rad2deg=57.29578; //Conversion factor rad to degree float motor1angle=(-140.0-10.0)*deg2rad*5.5; //Measured angle motor 1 @@ -105,7 +105,7 @@ Ticker scopeTicker; Ticker tickGlobal; //Global ticker -const float PWM_period = 1e-6; +const float PWM_period = 1/(18*10e3); volatile int counts1; // Encoder counts volatile int counts2; @@ -309,7 +309,8 @@ if ( motor_state_changed == true ) { motor_state_changed = false; // More functions - } + } + motor_RKI=true; // Do nothing until end condition is met @@ -330,8 +331,9 @@ // More functions } static float t=0; - Vx=6.0f*sin(1.0f*t); + Vx=10.0f*sin(1.0f*t); Vy=0.0f; + t+=Ts; if ( button2_pressed ) { @@ -397,6 +399,7 @@ pc.printf("counts2offset %i counts2af: %i counts2: %i\r\n",counts2offset,counts2af,counts2); pc.printf("state: %i motor1ref: %f motor1angle: %f\r\n",motor_curr_state,motor1ref,motor1angle); pc.printf("q1: %f q2: %f motor1error: %f \r\n",q1*rad2deg,q2*rad2deg, motor1error); + pc.printf("Xe: %f Ye: %f\r\n",xe,ye); wait(0.5); }