Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Lastly, in the bottom left hand corner of the VI is the option to enable advanced controls for the PID loop. If this icon is selected, the PID gains table will appear to its right. The pid loop uses a PID controller and equation constants to run and maintain the level. Unless you have a deep understanding of these coeffecients and need to make edits to them to increase the VI's efficiency, do not try to change these values. If advanced controls are enabled, and the VI is in manual mode, the option is given to recalibrate the current position of the valve..............   At  If it is in automatic mode, then the option to change the equation constants is enabled as well.  At the bottom there is the developer table which contains the stop bool and ................, which _______.

 

 

Code

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. 

...

On the right side of the above image, there is a case structure that is activated when the user selects the bool "Log Data?". Selecting this icon in the VI interface sets the case as true, which activates the assembly of a text file which contains data for the Date/Time Stamp in unix, the current level and finally the valve position, which will be read into the Measuring VI (see LINK). All this data is taken into a string concatenator and written into the text file path supplied by the user. Then the text file is closed in the case structure. If the case was set to false, then no text file would have been written or even opened.

 

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 the box is disabled and grayed out in the first while loop.

 


VISA Motors and Sub VIs

 

Image Added

In order to connect to machinery, ..... something about that box.

 

As you can see there are also several smaller sub VIs that are instrumental to the response VI as a whole. These VIs are used to initialize the valve position and setting a constant velocity at which it turns.

 

***When you initialize the valve position, it is important that the valve be completely closed, and that zero is set as the initial position. If this is not done successfully then there is a risk of the valve overturning and breaking. Likewise, the constant velocity should not be too fast in order to prevent the valve from slipping while the program is running.***

 

init.vi 

init.vi, short for initialize.vi, initializes the motor (here it is PM2) by writing that motor to the VISA.

 

microstep_revolution.vi

 

 

setvelocity.vi

 

 

...

getposition.vi

 

Image Removed In order to connect to machinery, .....

to_turns.vi 

 

 

 

 

Manual Mode

 

 

 

Automatic Mode

 

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.

...