]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.tutorial/scl/Tutorial/3.03 (Exercise) Controller tuning.md
Import org.simantics.scl.tutorial from incubator SVN repo
[simantics/platform.git] / bundles / org.simantics.scl.tutorial / scl / Tutorial / 3.03 (Exercise) Controller tuning.md
diff --git a/bundles/org.simantics.scl.tutorial/scl/Tutorial/3.03 (Exercise) Controller tuning.md b/bundles/org.simantics.scl.tutorial/scl/Tutorial/3.03 (Exercise) Controller tuning.md
new file mode 100644 (file)
index 0000000..abdfa8a
--- /dev/null
@@ -0,0 +1,46 @@
+## Controller tuning exercise\r
+\r
+### Step 1\r
+\r
+Load the model [ControllerTuning.apros](http://www.simantics.org/~niemisto/SCL20150513/ControllerTuning.apros).\r
+\r
+Run a sequence from SCL console that first sets the value of the set point (`SP01#SP_VALUE`) to 110,\r
+then waits 10 seconds and stops.\r
+\r
+::value[Apros/Sequences/runSequence,Simantics/Sequences/execute,Simantics/Sequences/setVar,Simantics/Sequences/wait,Simantics/Sequences/stop]\r
+\r
+Open the chart and examine the results.\r
+\r
+### Step 2\r
+\r
+Put your sequence inside a function that takes the controller parameters\r
+`PIC01#PI_GAIN` and `PIC01#PI_INTEGRATION_TIME` as a parameter and sets\r
+them at the same time with the set point. It should also load the IC\r
+before simulation with command\r
+\r
+    loadInitialCondition (syncRead $ \_ -> fromResource $ relativeResource currentModel "/Initial%20Condition")\r
+\r
+### Step 3\r
+\r
+Create a separate simulation thread that computes the last time the flow speed\r
+`XA01#ANALOG_VALUE` is within 1 from the set point value 110. Your function\r
+should return that value. The following functions are useful for that:   \r
+\r
+::value[Simantics/Sequences/getVar]\r
+::value[Simantics/Sequences/fork]\r
+::value[Prelude/repeatForever]\r
+\r
+### Step 4\r
+\r
+Try the optimization routine\r
+\r
+::value[Simantics/Newuoa/bobyqa]\r
+\r
+with function\r
+\r
+    f [x,y] = let dx=x-1 ; dy=y-2 in dx*dx + dy*dy\r
+\r
+### Step 5\r
+\r
+Optimize the controller parameters using the objective function you created in step 3.\r
+\r