![](/media/cache/profiles/altb_JGUSAOG.jpg.50x50_q85.jpg)
Simple program for introduction of mirror actuator.
ControllerLoop.cpp@13:1bf960928a93, 2021-05-01 (annotated)
- Committer:
- altb2
- Date:
- Sat May 01 20:08:24 2021 +0000
- Revision:
- 13:1bf960928a93
- Parent:
- 11:d43f8b421d6d
- Child:
- 14:1be03d1c45c7
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
altb2 | 5:768e10f6d372 | 1 | #include "ControllerLoop.h" |
altb2 | 5:768e10f6d372 | 2 | using namespace std; |
altb2 | 5:768e10f6d372 | 3 | |
altb2 | 10:bfacffec199a | 4 | // contructor for controller loop |
altb2 | 13:1bf960928a93 | 5 | ControllerLoop::ControllerLoop(float Ts) : thread(osPriorityHigh,4096) |
altb2 | 5:768e10f6d372 | 6 | { |
altb2 | 13:1bf960928a93 | 7 | this->Ts = Ts; |
altb2 | 13:1bf960928a93 | 8 | } |
altb2 | 5:768e10f6d372 | 9 | |
altb2 | 10:bfacffec199a | 10 | // decontructor for controller loop |
altb2 | 5:768e10f6d372 | 11 | ControllerLoop::~ControllerLoop() {} |
altb2 | 5:768e10f6d372 | 12 | |
altb2 | 10:bfacffec199a | 13 | // ---------------------------------------------------------------------------- |
altb2 | 10:bfacffec199a | 14 | // this is the main loop called every Ts with high priority |
altb2 | 5:768e10f6d372 | 15 | void ControllerLoop::loop(void){ |
altb2 | 5:768e10f6d372 | 16 | while(1) |
altb2 | 5:768e10f6d372 | 17 | { |
altb2 | 5:768e10f6d372 | 18 | ThisThread::flags_wait_any(threadFlag); |
altb2 | 5:768e10f6d372 | 19 | // THE LOOP ------------------------------------------------------------ |
altb2 | 13:1bf960928a93 | 20 | //printf("I am called!\r\n"); |
altb2 | 11:d43f8b421d6d | 21 | }// endof the main loop |
altb2 | 5:768e10f6d372 | 22 | } |
altb2 | 5:768e10f6d372 | 23 | |
altb2 | 5:768e10f6d372 | 24 | void ControllerLoop::sendSignal() { |
altb2 | 5:768e10f6d372 | 25 | thread.flags_set(threadFlag); |
altb2 | 5:768e10f6d372 | 26 | } |
altb2 | 6:9ebeffe446e4 | 27 | void ControllerLoop::start_loop(void) |
altb2 | 6:9ebeffe446e4 | 28 | { |
altb2 | 6:9ebeffe446e4 | 29 | thread.start(callback(this, &ControllerLoop::loop)); |
altb2 | 6:9ebeffe446e4 | 30 | ticker.attach(callback(this, &ControllerLoop::sendSignal), Ts); |
altb2 | 6:9ebeffe446e4 | 31 | } |
altb2 | 7:942fd77d5e19 | 32 | |
altb2 | 6:9ebeffe446e4 | 33 | void ControllerLoop::init_controllers(void) |
altb2 | 6:9ebeffe446e4 | 34 | { |
altb2 | 11:d43f8b421d6d | 35 | // set values for your velocity and position controller here! |
altb2 | 6:9ebeffe446e4 | 36 | } |