TagWriteValue - Write a Value to a Tag

Help Contents

Introduction

The TagWriteValue function block writes a value to a tag.

The function block writes the value by sending a WriteValue tag command to the tag. The function block provides status information to:

The TagWriteValue function block is intended for use with:

Parameters

The TagWriteValue function block has these parameters:

Parameter Type Direction Description
REQ BOOL R_EDGE Input A rising edge starts the WriteValue tag command.
TAGNAME STRING Input The name of the tag to send the WriteValue tag command to.
VALUE ANY Input The value to write to the tag.
BUSY BOOL Output Set to TRUE while the WriteValue tag command is in progress.
DONE BOOL Output Set to TRUE for 1 execution after the WriteValue tag command has completed.
ERROR BOOL Output Set to TRUE if the WriteValue tag command failed.
ERRORMSG WSTRING Output If ERROR is TRUE, the reason why the WriteValue tag command failed.

Remarks

Once the WriteValue tag command begins, additional requests from the input signal REQ are ignored until the tag command completes.

These timing diagrams show the relationship of the REQ, BUSY, DONE, and ERROR signals processing two requests. The first request completes with an error, the second request completes normally:

        +--------+     +-+ +------+
  REQ   |        |     | | |      |
      --+        +-----+ +-+      +------

        +------+       +------+
 BUSY   |      |       |      |
      --+      +-------+      +----------

               ++             ++
 DONE          ||             ||
      ---------++-------------++---------

               +-------+
ERROR          |       |
      ---------+       +-----------------

The BUSY signal is TRUE while the tag command is in progress. The DONE signal is TRUE for 1 execution after the completion of the tag command.

Example Program

The following IEC 61131-3 Program shows:

  1. A FALSE to TRUE transition of a digital data point tag used to trigger a function block.
  2. The function block writing a value to another tag.
  3. Example logic to check the status of the function block.
Program MAIN
    VAR 
        (* The function block declaration *)
        WriteFB : TagWriteValue;

        (* The tag used to trigger the tag write
           Note: Uses a relative tag reference to 'Digital Trigger Tag' 
                 located in the same folder as this program *)
        TriggerTag AT %".Digital Trigger Tag" : BOOL;
    END_VAR

    (* Call the TagWriteValue function block *)
    WriteFB( 
        REQ:=TriggerTag,
        TAGNAME:="Tag to write the value to",
        VALUE:=37.5 );

    (* The DONE output is active for one cycle when the function block completes *)
    IF WriteFB.DONE THEN

        (* Was there an error ? *)
        IF WriteFB.ERROR THEN
            (* Handle any error *)
        ELSE
            (* Any additional work on successful completion *)
        END_IF;
    END_IF;

END_PROGRAM

Further Information

WriteValue Tag Command

To learn about the WriteValue tag command.

Tag Command Function Blocks

To learn about other tag command function blocks.

Elementary Data Types

To learn about the different types supported by Fernhill SCADA.

Common Elements

To learn about other IEC 61131-3 Common Elements.

Glossary

For the meaning of terms used in Fernhill SCADA.