...
The entirety of the Response VI code is contained within a while loop, in which each iteration lasts 1 second and which can only be stopped by either an error in either VI (while they are running simultaneously) or if the VI is stopped with the use of the stop bool in the developer box.
File IO
The File IO in the Response VI appears very similar to that of the Measuring VI. It begins with opening the desired text file containing the Measuring VI data, which is defined by the user, and uses the last 3 characters for that iteration while the VI is running. The last three characters represent the level of the system. This information is then converted from a string to a numeric, and the text file is closed. The level data then goes to the level ___________ which creates the graph representing the level with respect to time.
...
Enabling Advanced Controls
Advanced Controls should only be enabled by someone who understands the mathematics behind the PID Response - otherwise, the default values should be left alone. Because of this, the code is set up to display a warning to the user, and presents them with two options: Enable or OK. If Enable is selected, the user will be able to access advanced controls, and if OK is selected, they cannot access them. This occurs in the first sequence of the sequence structure, which means that the controls are changed before the PID response is calculated for that iteration. Additionally, if Advanced Controls are enabled, then the box containing the PID gains appears in the interface.
...
If Advanced Controls are not enabled, then they are disabled and grayed out in the first while loop.
Connecting to Machinery
In order to connect to machinery, .....
Creating the Proportional-Integral-Derivative (PID) Response
...
The PID response operates by calculating an error from the designated target level and corrects that by using proportional, integral and derivative terms.
The above picture shows the code which creates the PID response.
The image above (from top to bottom) shows how the current level is subtracted from the target level for each iteration, and this data is then used to produce the error graph, which plots the current error with respect to time.
Below this is the event structure that is designed to activate when the "Enable Advanced Controls" bool is selected. Once the condition is activated, the ____ indicating the "PID gains", "Recalibrate", "Save PID gains", "Load PID gains" and "Current Position" become visible. The event structure runs for 125 milliseconds, and has two cases: (0) Timeout, and (1)____.
...
Running the VIs
- Ensure that all controls in both VIs are accounted for. In the response VI this includes...
- text file paths are indicated, preferably in the computer's hard drive
- min and max valve position
- target level
- the COMPort is correctly configured
...and in the Measuring VI...
- the text filepath is indicated, in the same folder as the response filepath on the computer's hard drive
- the standard deviation, which shouldn't be any greater than 1 - In the response VI:
- the Run VI icon at the top left should be green
- the "Motor Connected" bool icon will be red when the VI is not running, but if it does not turn green after about a second of the VI running then the motor is not connected
- if you want the VI to automatically change the valve position for a trial, then you should select automatic. This should be done after the connection between the VI and the motor are tested (see Step 3).
- the Log Data icon should be green
- the Motor Enabled icon should be green, but grayed out
- Before running the VIs, you should do a test of the Response VI to make sure everything is working properly. This is done by enabling manual mode and changing the set number of turns open icon to any number between 0 and 3. Once it is determined that this does in fact change the run valve position connected to the motor, then the VI is connected correctly. Once you are done testing, automatic mode should be reselected in order to run a trial.
- When the above steps are completed, and the Response VI test has run successfully, the two VIs are ready to be run. Simply run click the run button of both VIs. If this is the first time using one of the text files, you may need to run the VI with the respective new text file first.
...