Ruprecht Altenburger
/
RT2_P3_students_G4
Template for group 4
Fork of RT2_P3_students by
Diff: main.cpp
- Revision:
- 7:01a7363583b2
- Parent:
- 6:8ed679044a72
- Child:
- 8:72f260c467ad
diff -r 8ed679044a72 -r 01a7363583b2 main.cpp --- a/main.cpp Tue Apr 17 11:47:35 2018 +0000 +++ b/main.cpp Sun Apr 22 19:54:59 2018 +0000 @@ -45,13 +45,14 @@ AnalogOut out(PA_5); // Analog OUT on PA_5 1.6 V -> 0A 3.2A -> 2A (see ESCON) float out_value = 1.6f; // set voltage on 1.6 V (0 A current) float w_soll = 10.0f; // desired velocity -float Ts = 0.2f; // sample time of main loops +float Ts = 0.002f; // sample time of main loops int k = 0; //------------------------------------------ // ... here define variables like gains etc. //------------------------------------------ -LinearCharacteristics i2u(0.8f,-2.0f); +//LinearCharacteristics i2u(0.8f,-2.0f); +LinearCharacteristics i2u(-2.0f,2.0f,0.0f,3.2f); //------------------------------------------ Ticker ControllerLoopTimer; // interrupt for control loop @@ -61,8 +62,7 @@ // ... here define instantiate classes //------------------------------------------ PI_Cntrl vel_cntrl(0.5f,.05f,Ts,0.4f); -GPA gpa1(1.0f, 200.0f, 150, 4, 400, Ts, 10.0f, 0.3f); -float excWobble = 0.0f; +//GPA gpa1(1.0f, 200.0f, 150, 4, 400, Ts, 10.0f, 0.3f); // GPA(t fMin, t fMax, NfexcDes, NperMin, NmeasMin, Ts, Aexc0, Aexc1) // ... define some linear characteristics ----------------------------------------- @@ -89,19 +89,17 @@ void updateControllers(void){ short counts = counter1; // get counts from Encoder float vel = diff(counts); // motor velocity - /* desTorque = pi_w(omega_desired - omega + excWobble); - outWobble = omega; - excWobble = Wobble(excWobble, outWobble); */ + - float torq_des = vel_cntrl(excWobble + w_soll - vel); + /*float torq_des = vel_cntrl(excWobble + w_soll - vel); excWobble = gpa1(torq_des,vel); out.write(i2u(torq_des/0.217f)); // the controller! convert torque to Amps km = 0.217 Nm/A - + */ - // if(++k >= 249){ - // k = 0; - //pc.printf("Des. velocity: %3.3f, Velocity: %3.3f\r\n",w_soll,vel); - //} + if(++k >= 249){ + k = 0; + pc.printf("Some Output %3.3f\r\n",1.11111); + } } //****************************************************************************** //********** User functions like buttens handle etc. **************