Include tag calculation results in the log

<< Click to Display Table of Contents >>

Manual > Monitoring system construction guide > Establishing major functions > Logging/trend graph > Using logger actions > Collection of logger action samples >

Include tag calculation results in the log

overview

This section explains how to calculate tag values read from a PLC during logging and include the calculation results in the log.

 

This example uses a pre-action script to calculate the average value of multiple tags.

 

 

hint

More information about pre-execution scripts is provided in "Settings on the Action's Advanced Settings Tab".

 

 

Download the sample

The creation examples shown on this page are provided with samples.

 

The sample can be downloaded from below.

 

 

 

Setup Procedure

Tag settings

 

1.Set the virtual device tags "U01.F01.SD0000" to "U01.F01.SD0009" for data collection.
 
c_action_logger_0061
 

2.Set virtual device tags "U02.F01.D0000" to "U02.F01.D0004" to store the calculation results.
 
c_action_logger_0062

 

 


Action Settings

 

1.Add logger action "A01".
 
Set the time field and the tag fields "U02.F01.D0000" to "U02.F01.D0004" (drag and drop the tags into A01).
 
c_action_logger_0063
 

 

2.From the Text Settings tab of A01, set the file name and destination of the log file (below is an example setting).

 

p_logger_0001

 

3.Check "Advanced Settings" and "Execute script - before starting processing" in A01, and set the following script in the script editor.

 
c_action_0376

 
(Script Editor)
c_action_0377
 

(Script description)

U02.F01.D0000 = (U01.F01.SD0000 + U01.F01.SD0001) / 2

U02.F01.D0001 = (U01.F01.SD0002 + U01.F01.SD0003) / 2

U02.F01.D0002 = (U01.F01.SD0004 + U01.F01.SD0005) / 2

U02.F01.D0003 = (U01.F01.SD0006 + U01.F01.SD0007) / 2

U02.F01.D0004 = (U01.F01.SD0008 + U01.F01.SD0009) / 2

 

 


Event Settings

 

1.Add Periodic event"E01".
 
The cycle is set to 1 second, and the execution action is set to "A01".
 
c_action_logger_0064
 
c_action_logger_0065

 

 

Commentary

The key point in this process is that a virtual device tag for storing the calculation results is prepared in advance, and the pre-execution script calculates the average value just before logging and assigns it to the tag for storing the value. The logger action logs the value of the tag in which the calculation result is stored.

 
In this example, the tags for data collection are "U01.F01.SD0000" to "U01.F01.SD0009", and the logging tags for storing calculation results are "U02.F01.D0000" to "U02.F01.D0005".

 

c_action_logger_0066

 

 

The following script calculates the average value for each of the two devices and assigns it to a tag for logging.
 

U02.F01.D0000 = (U01.F01.SD0000 + U01.F01.SD0001) / 2

U02.F01.D0001 = (U01.F01.SD0002 + U01.F01.SD0003) / 2

U02.F01.D0002 = (U01.F01.SD0004 + U01.F01.SD0005) / 2

U02.F01.D0003 = (U01.F01.SD0006 + U01.F01.SD0007) / 2

U02.F01.D0004 = (U01.F01.SD0008 + U01.F01.SD0009) / 2