1 ## Controller tuning exercise
\r
5 Load the model [ControllerTuning.apros](http://www.simantics.org/~niemisto/SCL20150513/ControllerTuning.apros).
\r
7 Run a sequence from SCL console that first sets the value of the set point (`SP01#SP_VALUE`) to 110,
\r
8 then waits 10 seconds and stops.
\r
10 ::value[Apros/Sequences/runSequence,Simantics/Sequences/execute,Simantics/Sequences/setVar,Simantics/Sequences/wait,Simantics/Sequences/stop]
\r
12 Open the chart and examine the results.
\r
16 Put your sequence inside a function that takes the controller parameters
\r
17 `PIC01#PI_GAIN` and `PIC01#PI_INTEGRATION_TIME` as a parameter and sets
\r
18 them at the same time with the set point. It should also load the IC
\r
19 before simulation with command
\r
21 loadInitialCondition (syncRead $ \_ -> fromResource $ relativeResource currentModel "/Initial%20Condition")
\r
25 Create a separate simulation thread that computes the last time the flow speed
\r
26 `XA01#ANALOG_VALUE` is within 1 from the set point value 110. Your function
\r
27 should return that value. The following functions are useful for that:
\r
29 ::value[Simantics/Sequences/getVar]
\r
30 ::value[Simantics/Sequences/fork]
\r
31 ::value[Prelude/repeatForever]
\r
35 Try the optimization routine
\r
37 ::value[Simantics/Newuoa/bobyqa]
\r
41 f [x,y] = let dx=x-1 ; dy=y-2 in dx*dx + dy*dy
\r
45 Optimize the controller parameters using the objective function you created in step 3.
\r