TagDirectWriteBit - Write a bit directly to a Data Source

Help Contents


The TagDirectWriteBit function block writes a single bit to any address in a data source associated with a tag.

The function block writes the data bit by sending a DirectWriteBit tag command to the tag. The function block provides status information to:


The TagDirectWriteBit function block has these parameters:

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

Once the DirectWriteBit 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 acknowledging alarms on another tag.
  3. Example logic to check the status of the function block.
Program MAIN
        (* The function block declaration *)
        WriteBitFB : TagDirectWriteBit;

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

    (* Call the TagDirectWriteBit function block 
       Note: Using Allen bradley PLC addressing to write bit 0 of outputs at slot 1 *)
        TAGNAME:="Allen Bradley PLC Tag",
        VALUE:=TRUE );

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

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


Further Information

DirectWriteBit Tag Command

To learn about the DirectWriteBit 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.


For the meaning of terms used in Fernhill SCADA.