The variable database provided by Century Star is a real-time variable database. At runtime, the real-time data of all variables are stored in the database. The running system collects data from industrial site, processes the collected data, data input by users and data in database in real time, and then sends them back to industrial site, and updates the variable database at the same time. When defining variables in the variable database, users must define a data type for each variable so that users can use the variable. This system provides four types of variables: system variables, memory variables, IO variables and special variables.
1, system variable
System variables are preset by the system and can be directly used by users. System variables are divided into system discrete, system integer, system real number and system information. System variables have read-only and read-write properties. Read-only variables such as system time are automatically updated by the system, and users cannot change the values of these variables. For system variables with read-write properties, users can change the value of the variables.
2. Memory variables
Memory variables are variables defined by users within the system. These variables do not exchange data with the outside world, but mainly store the intermediate values of calculation and processing, and simulate IO variables in system simulation.
Memory variables are divided into four types: memory discrete variables, memory integer variables, memory real variables and memory information variables.
① Memory discrete variables
Variable of Boolean type.
Memory discrete variables can only have two values: 0 (off, false) and 1 (on, on, true), which are generally used to represent switching values.
② Memorize integer variables.
32-bit integer variable.
The range of memory integer variables is -2,147,483,648 ~ 2,147,483,647.
③ Memory real variable
Decimal floating-point variable.
The range of memory real numbers is -3.4E38 ~ 3.4E38.
④ Memory information variable
String variable.
Value range of memory information variable: the longest memory can store 13 1 characters.
3.IO variables
IO variables are variables that can exchange data with other applications. The IO variables of the system can exchange data with external applications through various data exchange protocols, such as Windows Dynamic Data Exchange (DDE) protocol, OPC, network, serial port, bus, board and other communication protocols.
When the data of IO variable with read-write property changes, the system immediately writes the value of IO variable into external application. The value of the IO variable can also be updated by an external application.
IO variables are divided into four types: IO discrete variables, IO integer variables, IO real variables and IO information variables, and their data types and value ranges are the same as those of memory variables.
4. Special variables
There are two special variables: alarm window variable and historical curve variable. Mainly used for system alarm display and historical trend curve display.
① Alarm window variable
The alarm window variable is mainly used to connect the alarm window drawn by the user with the database to display the alarm. Users can use command language to read or change some features of the alarm window, such as obtaining the number of alarms in the current alarm window.
② Historical curve variables
The historical curve variable connects the historical trend curve drawn by users with the database to display historical trend data. Users can use command language programming to set some characteristics of historical trend curve, such as changing the starting time of historical trend curve or the length of time displayed. The domain of a variable is to reflect the attribute of the variable. The alarm of real variables has the properties of "upper alarm limit" and "lower alarm limit", and the historical curve variables have the properties of curve start time and curve time length.
When defining a variable, you need to set the domain value of the variable.
Users can use command language programming to read or set the domain of variables, and the domain of variables can be read-only and read-write.
Representation of the domain of variables: variables. Domain. In the industrial field, the collected IO integer and IO real variables need to be converted in various ways according to the field process requirements. The IO variable data conversion methods provided by Century Star include linear conversion, root conversion, cumulative conversion and piecewise linear conversion.
1, linear conversion mode
The linear conversion method is to linearly interpolate the collected values (i.e. original values) of IO variables (including IO integers and IO real numbers) with the variable values used in the database.
Calculation formula of linear conversion mode:
Database variable value = min +(IO original value-min) * (max-min)/(max-min)
These include:
Database variable value: the value of the converted variable in the database.
IO original value: the set value of IO variables (including IO integer and IO real number).
Minimum value: the minimum value of variables in the database.
Maximum: the maximum value of a variable in the database.
Minimum value: the minimum original value of the I/O variable.
Maximum value: the maximum original value of the I/O variable.
2. Root transformation mode
The root transformation method is to transform the collected values (that is, the original values) of IO variables (including IO integer and IO real number) with the variable values used in the database through square root interpolation.
Calculation formula of root transformation mode:
Database variable value = min +(IO original value-min) * sqrt (max-min)/sqrt (max-min)
These include:
Database variable value: the value of the converted variable in the database.
IO original value: the set value of IO variables (including IO integer and IO real number).
Minimum value: the minimum value of variables in the database.
Maximum: the maximum value of a variable in the database.
Minimum value: the minimum original value of the I/O variable.
Maximum value: the maximum original value of the I/O variable.
3. Cumulative conversion mode
In the industrial field, it is often necessary to calculate the cumulative flow and electricity. There are two cumulative conversion methods: direct cumulative and variance cumulative.
① Direct accumulation: the collected values (i.e. original values) of IO variables (including IO integer and IO real number) are directly added with the variable values used in the database after linear conversion.
Direct cumulative calculation formula:
New value of variable = old value of variable+new value purchased.
These include:
New value of variable: directly accumulate the value of the variable in the database after conversion.
Old value of variables: directly accumulate the values of variables in the database before conversion.
Collect new values: the values of IO variables after linear conversion.
Note: When the value of the cumulative variable exceeds the maximum value in the database, the value of the variable will be restored to the minimum value in the database.
② Difference accumulation: accumulate one variable at a time, calculate the difference between the value actually collected by this variable and the value collected last time, and accumulate the difference. When the value collected this time is less than the value collected last time, that is, the difference is negative, the maximum and minimum values in the picture defined by variables will be converted.
Cumulative calculation formula of difference:
New value of variable = old value of variable+(collect new value-collect old value)
When the collected new value is less than the collected old value, the formula is:
New value of variable = old value of variable+(collect new value-collect old value)+(maximum value of variable-minimum value of variable)
These include:
New value of variable: directly accumulate the value of the variable in the database after conversion.
Old value of variables: directly accumulate the values of variables in the database before conversion.
Collect new values: the values of IO variables after linear conversion.
Set old value: IO variable value after linear conversion of the last set value.
Minimum value: the minimum value of variables in the database.
Maximum: the maximum value of a variable in the database.
Note: When the value of the cumulative variable exceeds the maximum value in the database, the value of the variable will be restored to the minimum value in the database.
4, piecewise linear conversion mode
In the industrial field, some data (such as thermal resistance, thermocouple, etc. ) are nonlinear signals. If it is calculated by linear conversion method, the error of engineering value will be great. Therefore, we use piecewise linear lookup tables to transform nonlinear data.
The piecewise linear transformation method is divided into two steps:
(1) linear transformation of variables, get an intermediate value (hereinafter referred to as the original value).
(2) Convert the original value according to the piecewise linear table to get the variable value in the database (hereinafter referred to as engineering value).
Look-up table calculation formula of piecewise linear table;
Engineering value = previous engineering value+(original value-previous original value) * (next engineering value-previous engineering value)/(next original value-previous original value)
Engineering value: the value of the variable in the database.
Original value: the variable gets an intermediate value through linear conversion.
Original Value: the original value of the original value corresponding to the original value item in the table.
Next Original Value: the next original value of the original value in the corresponding position of the original value item in the table.
Previous Engineering Value: the engineering value corresponding to "Previous Original Value" in the table.
Next Engineering Value: the engineering value corresponding to "Next Original Value" in the table.
Note: In the above table, when the original value =4.5, the previous original value =4, the next original value =5, the previous engineering value =25 and the next engineering value =36, the calculation formula is:
Engineering value =25+(4.5-4)*(36-25)/(5-4)=30.5 Select the system/variable database menu, or select the variable dictionary item in the browser to open the variable database management dialog box, as shown in Figure 4-2:
The variable database management dialog box is described as follows:
New: Enter the variable database dialog box to create a new variable.
Create: enter the dialog box of creating variables in groups to create variables in groups.
Modify: enter the variable database dialog box to modify the specified variable. Double-click the variable name with the left mouse button to modify the variable.
Delete: Deletes the specified variable. If the variable is a system variable or has been used (the variable count is greater than zero), then the variable has animation connection with a pixel or appears in the command language, which will prompt that it cannot be deleted.
Sorting: Make the dialog box have sorting function. When the number of variables exceeds 10000, if it has sorting function, the speed of displaying this dialog box may be slow, and the user can choose whether it has sorting function.
Exit: Exit the Variable Database dialog box.
Variable filtering: filter the variable database according to the conditions specified by the user and enter the variable filtering dialog box.
Number of variables after filtering: the number of variables in the variable database after filtering according to the conditions specified by the user; By default, it refers to the number of unfiltered variables in the variable database. When creating or modifying variables, the variable dictionary dialog box pops up, as shown in Figure 4-3:
The Variable Database dialog box contains the following parameters for variables:
1, variable definition
Variable name: the name of the variable in the variable database. Data variables cannot be renamed in the same application. Data variable names are case-sensitive and cannot exceed 32 characters. Click anywhere in the edit box with the mouse to enter the editing state. At this point, the user can enter the variable name, which can be Chinese or English name or $,@, #, _,? , but the first character cannot be a number, and the variable name cannot be a keyword or function name of the command language.
Type: Only one of the following basic types can be defined in the dialog box: memory discrete, memory integer, memory real number, memory information, IO discrete, IO integer, IO real number, IO information, historical curve and alarm window.
Description: Comment information of the variable.
Alarm Group Name: refers to the alarm group to which the variable belongs. Complete the definition of alarm group through the menu command "System/Alarm Group Definition".
Read-only, write-only, read-write attribute: indicates the read-write attribute of the variable.
2. Data Settings
Initial value: the initial value of the variable when the system starts running. The initial value is related to the defined variable type. When defining an integer or real number type variable, you can enter an integer or real number. When defining discrete type variables, you can choose on or off. When defining information type variables, you can enter a string.
Minimum value: the minimum value of variables in the database.
Maximum: the maximum value of a variable in the database.
Sensitivity of data change: this item is valid when the data type is integer or real. Only when the value variation range of the data variable exceeds the "data variation sensitivity" will the system update the connected pixels.
Minimum value: the minimum original value of the I/O variable.
Maximum value: the maximum original value of the I/O variable.
Saved Variable Value: the value of the variable saved when the system exits.
Web publishing: when selected, you can browse the variable remotely.
Data conversion mode: specifies the conversion mode from the original value corresponding to IO integer or IO real number to the value used in the database.
Linear conversion mode: the original numerical value corresponding to IO integer and IO real number and the database usage value are linearly interpolated and converted.
Square root conversion method: use the square root of the original value corresponding to IO integer and IO real number for conversion.
3. Device objects
Device object name: select the installed driving device and configure the parameters related to the defined variables.
Data Type: Select the data type collected from the device object.
Collection Frequency: Set the frequency of collecting data from device objects.
Register: Select the register for data acquisition in the device object.
4. Record parameters
Record: When the variable value changes, whether to save the variable value to the disk (that is, historical record) can record discrete, integer and real variables. Include no recording, recording according to sensitivity and timed recording.
Sensitivity of recording changes: Only when the variation range of the variable value is greater than this value will it be recorded on the disk. When the "Record" option is valid, the "Record Change Sensitivity" option is valid, and the default value is 1, which can be modified by users as required.
Example: There is an analog variable in the database. If this variable value is to be recorded on the hard disk, the recording sensitivity is designated as 3, and the recording process is as follows: if the first recorded value is 10, when the second variable value is 12, because10 = 2 < 3, that is, When the third variable value is 14, the temperature value is recorded on the disk because it is 14- 10 = 4 > 3, that is, the change range is greater than the set "recording change sensitivity".
Interval: the time interval of regular storage, ranging from 1 to 3 153600 seconds.
5. Alarm parameters
Alarm: whether the variable has alarm function. Select the following discrete alarms (for discrete type variables) or alarm parameters (for integer type and real type variables) to be valid.
Priority: Measure the importance of alarm events. The number 1 is the highest level and 999 is the lowest level. Assigning alarm priority to each variable to be monitored can manage different levels of alarm events.
Discrete value alarm: used to alarm or not alarm the discrete quantity.
Analog value alarm: effective for integer and real variables. There are seven kinds of alarms: low, low, high, high, small deviation, large deviation and rate of change.
Alarm limit: the upper and lower limits of variable alarm. There are four alarm options for integer and real variables: low, low, high and high. In the case of low alarm and low alarm, as long as the variable value is less than the lower alarm limit, an alarm will appear; In the case of high alarm and high alarm, as long as the variable value is greater than the alarm upper limit, an alarm will appear. The determination of normal area and alarm area should be based on four alarm settings: low, low, high and high. As shown in figure 4-4:
Help: Enter the help system.
Example:
Set the control temperature of the boiler to high alarm value = 150, high alarm value = 130, low alarm value =50, and low alarm value =30, then when the boiler temperature changes, the following control situations will occur:
Boiler temperature >; = 150 high alarm
130 = & lt; Boiler temperature
50< boiler temperature
30< boiler temperature
Boiler temperature
Deviation: It is defined by the percentage of fluctuation of analog quantity relative to the target value (reference value). There are two alarm conditions: small deviation and large deviation. The target value (reference value) is input by the edit box at the back. When the fluctuation percentage is less than a small deviation or greater than a large deviation, an alarm will appear respectively.
Deviation = ((current value-target value) ÷ (maximum value-minimum value)) × 100
Because the deviation is positive and negative, the minimum demarcation value of analog quantity fluctuating up and down relative to the target value (reference value) within the deviation range is called the minimum current value, and the maximum demarcation value of analog quantity fluctuating up and down relative to the target value (reference value) is called the maximum current value, including:
Minimum current value = target value-(deviation/100)× (maximum value-minimum value);
Maximum current value = target value+(deviation/100)× (maximum-minimum value);
For example, if the minimum value of the variable is-1000 and the maximum value is = 1000, set its small deviation = 10, large deviation = 15 and target value =500, then the conditions for small deviation alarm and large deviation alarm can be calculated as follows:
Small deviation alarm:
Minimum current value = 500-(10/100) × (1000-(-1000)) = 500-200 = 300.
Maximum current value = 500+(10/100) × (1000-(-1000)) = 500+200 = 700.
Then: analog variable value >; =700 or analog variable value
300 < analog variable value
Large deviation alarm:
The minimum current value = 500-(15/100) × (1000-(-1000)) = 500-300 = 200.
Maximum current value = 500+(15/100) × (1000-(-1000)) = 500+300 = 800.
Then: analog variable value >; =800 or analog variable value
200 < analog variable value
Change rate: select the change rate of analog quantity in a given time to give an alarm. Whenever the variable changes, calculate the change rate to decide whether to call the police. If the calculation result is greater than the alarm limit, an alarm will appear. The hour, minute and second buttons are used to select the time unit. The selection of units does not affect the time to check the rate of change, which is calculated every time the variable changes. The calculation formula of change rate is as follows:
Change rate = [(current value-last value)/(maximum value-minimum value)/(current time-last value change time) ]× 100%
6. Variable Filter Dialog Box
Click ">" in the variable database management dialog box. Button to enter the variable filter dialog box, as shown in figure 4-5:
Filter Name: You can enter a new filter name in this column or select an existing filter name.
Filter condition: here, any combination of five conditions, such as variable name, variable type, device object, alarm group and comment, is used as the filter condition.
You can also delete filter names that you think are unnecessary. Click the "Build" button in the variable database management dialog box to enter the group variable creation dialog box, as shown in Figure 4-6:
Creating a variable in a group is basically similar to creating a new variable, and the following points should be noted:
1. variable name: all created variables start with the variable name, followed by the number as the variable name.
2. Number of variables defined: the number of variables to be defined, ranging from 1 to 1000.
3. Starting number of group variables: the starting number of group definition variables. Range:1~ nine thousand nine hundred and ninety-nine.
Example: In "Create variables in a group", enter IO as the variable name, 10 as the number of defined variables, and 1 as the starting number of group variables. Click OK to define ten variables IO 1 ~ IO 10 in the variable database. Most of the work of database maintenance is done automatically by the system. What designers need to do is to "delete unused variables" in the final stage. Before deleting unused variables, it is necessary to update the variable count to determine whether the variables have animation connections or have been used in command languages. Only variables that have never been used can be deleted (variable count =0). Before updating the variable count, all screens need to be closed.
1, update variable count
Select Menu System/Update Variable Count, and when the update variable count is over, the user variable count dialog box will pop up, as shown in Figure 4-7:
2. Delete unused variables
After the inspection, select the menu "System/Delete Unused Variables". If there are no unused variables, the system prompt is as shown in Figure 4-8:
If there are unused variables, the dialog box for deleting unused variables will pop up, as shown in Figure 4-9:
Select an unused variable with the mouse, click Delete to delete the selected variable, and click Close to finish the operation.
3. Variable usage query
When developing their own applications with the development system, users often encounter the situation that variables have been used in a certain screen or a certain command language. When using "Update Variable Count" and "Delete Unused Variables", variables cannot be deleted, but if you want to change the attributes of variables or delete variables, you can use the "Variable Usage Query" function to find the specific location where a variable is used. Select the "system" menu to pop up the drop-down menu, as shown in figure 4- 10:
Select the "Variable Usage Query" menu to pop up a prompt dialog box, as shown in Figure 4- 1 1:
Click Cancel: variable usage query will not be performed; Click OK to open the variable usage query dialog box, as shown in Figure 4- 12:
Click the > button to open the variable selection dialog box, as shown in figure 4- 13:
Double-click or select a variable with the left mouse button, and then press OK. For example, select production line move 3 and variable usage query dialog box, as shown in Figure 4- 14:
Press ">" icon: reselect variables; Press "Cancel" button: abandon the operation of "Variable Usage Query"; Click OK: the system will start to query the usage of variables. After the query is completed, the variable usage query dialog box will pop up, as shown in Figure 4- 15:
Description of dialog box parameters:
Serial number: inquiry number.
Screen Name or Command Language Name: Use the screen name or command language name of the variable.
Animation connection or command language description: animation connection or command language description using variables.
Number of times: Statistical animation connection or variable usage in command language description.
Coordinate [(x 1, y 1)-(x2, y2)]: the coordinate of the pixel in the picture using the variable.