![](/media/cache/profiles/altb_JGUSAOG.jpg.50x50_q85.jpg)
Simple program for introduction of mirror actuator.
ControllerLoop.h@7:942fd77d5e19, 2021-04-15 (annotated)
- Committer:
- altb2
- Date:
- Thu Apr 15 05:36:55 2021 +0000
- Revision:
- 7:942fd77d5e19
- Parent:
- 6:9ebeffe446e4
- Child:
- 8:49ac75c42da0
intermediate
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
altb2 | 5:768e10f6d372 | 1 | #include "mbed.h" |
altb2 | 5:768e10f6d372 | 2 | #include "EncoderCounter.h" |
altb2 | 5:768e10f6d372 | 3 | #include "EncoderCounterIndex.h" |
altb2 | 5:768e10f6d372 | 4 | #include "DiffCounter.h" |
altb2 | 5:768e10f6d372 | 5 | #include "LinearCharacteristics.h" |
altb2 | 5:768e10f6d372 | 6 | #include "ThreadFlag.h" |
altb2 | 5:768e10f6d372 | 7 | #include "path_1d.h" |
altb2 | 6:9ebeffe446e4 | 8 | #include "PIDT2_Cntrl.h" |
altb2 | 5:768e10f6d372 | 9 | #include "Unwrapper_2pi.h" |
altb2 | 6:9ebeffe446e4 | 10 | #include "Mirror_Kinematic.h" |
altb2 | 6:9ebeffe446e4 | 11 | #include "data_structs.h" |
altb2 | 5:768e10f6d372 | 12 | |
altb2 | 5:768e10f6d372 | 13 | extern EncoderCounter counter1,counter2; |
altb2 | 5:768e10f6d372 | 14 | extern EncoderCounterIndex index1,index2; |
altb2 | 5:768e10f6d372 | 15 | extern DiffCounter diff1,diff2; |
altb2 | 5:768e10f6d372 | 16 | extern path_1d *current_path; |
altb2 | 6:9ebeffe446e4 | 17 | extern LinearCharacteristics i2u; |
altb2 | 7:942fd77d5e19 | 18 | extern AnalogOut i_des1, i_des2; |
altb2 | 5:768e10f6d372 | 19 | extern DigitalOut i_enable; |
altb2 | 5:768e10f6d372 | 20 | extern Timer glob_ti; |
altb2 | 7:942fd77d5e19 | 21 | extern Mirror_Kinematic mk; |
altb2 | 6:9ebeffe446e4 | 22 | extern DigitalOut laser_on; |
altb2 | 6:9ebeffe446e4 | 23 | extern DATA_Xchange data; |
altb2 | 5:768e10f6d372 | 24 | |
altb2 | 5:768e10f6d372 | 25 | // This is the loop class, it is not a controller at first hand, it guarantees a cyclic call |
altb2 | 5:768e10f6d372 | 26 | class ControllerLoop |
altb2 | 5:768e10f6d372 | 27 | { |
altb2 | 5:768e10f6d372 | 28 | public: |
altb2 | 5:768e10f6d372 | 29 | ControllerLoop(float Ts); |
altb2 | 5:768e10f6d372 | 30 | virtual ~ControllerLoop(); |
altb2 | 6:9ebeffe446e4 | 31 | void start_loop(void); |
altb2 | 6:9ebeffe446e4 | 32 | void init_controllers(void); |
altb2 | 6:9ebeffe446e4 | 33 | |
altb2 | 5:768e10f6d372 | 34 | |
altb2 | 5:768e10f6d372 | 35 | |
altb2 | 5:768e10f6d372 | 36 | private: |
altb2 | 5:768e10f6d372 | 37 | void loop(void); |
altb2 | 5:768e10f6d372 | 38 | Thread thread; |
altb2 | 5:768e10f6d372 | 39 | Ticker ticker; |
altb2 | 5:768e10f6d372 | 40 | ThreadFlag threadFlag; |
altb2 | 5:768e10f6d372 | 41 | Timer ti; |
altb2 | 5:768e10f6d372 | 42 | float Ts; |
altb2 | 5:768e10f6d372 | 43 | void sendSignal(); |
altb2 | 6:9ebeffe446e4 | 44 | bool is_initialized; |
altb2 | 6:9ebeffe446e4 | 45 | void find_index(void); |
altb2 | 6:9ebeffe446e4 | 46 | PIDT2_Cntrl v_cntrl[2]; |
altb2 | 6:9ebeffe446e4 | 47 | Unwrapper_2pi uw2pi1; |
altb2 | 6:9ebeffe446e4 | 48 | Unwrapper_2pi uw2pi2; |
altb2 | 7:942fd77d5e19 | 49 | float pos_cntrl(float); |
altb2 | 7:942fd77d5e19 | 50 | float Kv; |
altb2 | 7:942fd77d5e19 | 51 | DigitalOut dout1; |
altb2 | 5:768e10f6d372 | 52 | }; |