![](/media/cache/profiles/altb_JGUSAOG.jpg.50x50_q85.jpg)
template for students for mirror actuator
Diff: ControllerLoop.cpp
- Revision:
- 1:a7fc1afe0575
- Parent:
- 0:d2e117716219
- Child:
- 2:c4c4cc1bff45
--- a/ControllerLoop.cpp Sun May 02 19:32:30 2021 +0000 +++ b/ControllerLoop.cpp Mon May 17 12:03:40 2021 +0000 @@ -21,6 +21,9 @@ void ControllerLoop::loop(void){ float w01=2*3.1415927 * 8; float xy[2]; + float exc = 0; + PID_Cntrl vel_cntrl1(0.0158,3.17,0,0,Ts,-.8,.8); + PID_Cntrl vel_cntrl2(0.0158,3.17,0,0,Ts,-.8,.8); while(1) { ThisThread::flags_wait_any(threadFlag); @@ -47,14 +50,16 @@ // calculate desired currents here, you can do "anything" here, // if you like to refer to values e.g. from the gui or from the trafo, // please use data.xxx values, they are calculated 30 lines below - - data.i_des[0] = data.i_des[1] =0.0; + float v_des1 = 10.0f*sinf(2.0f* 3.14159f*8.0f*ti.read()); + float v_des2 = 10.0f*cosf(2.0f* 3.14159f*8.0f*ti.read()); + data.i_des[0] = vel_cntrl1(v_des1 - data.sens_Vphi[0]); + data.i_des[1] = vel_cntrl2(v_des2 - data.sens_Vphi[1]); // ------------------------ write outputs i_des1.write(i2u(data.i_des[0])); i_des2.write(i2u(data.i_des[1])); // GPA: if you want to use the GPA, uncomment and improve following line: - // exc = myGPA(data.i_des[0],data.sens_Vphi[0]); + exc = myGPA(data.i_des[0],data.sens_Vphi[0]); // now do trafos etc