DigitalOutput
- Namespace
- ZEquipment
- Extends
- Inherited Properties
- Inherited Methods
- Implements
FUNCTION_BLOCK DigitalOutput EXTENDS ZEquipment.Digital IMPLEMENTS ZEquipment.IDigital, ZCore.ITrigger
This function block represents a single digital output. It includes a boolean located variable, which my be linked to a terminal. The instance can be used as is, but it is benefical to specify the following traits
- logic (defaults to Normal, which can either be Normal (value in the PLC is the same as on the terminal) or Inverted (value in the PLC is the negation of the value on the terminal).
- trigger logic (defaults to Normal)
- logging (not necessary but can be useful sometimes)
- the name of this digital output
- simulation mode (defaults to
TRUE). If simulation is enabled this function block controls an internal held state variable, which is manipulated instead of the located variable on a fieldbus terminal.
Note
By default instances are simulated. In order to make use of a physical terminal, the method SetSimulation(on:=FALSE) has to be called.
PROGRAM MAIN
VAR
DOutput : ZEquipment.DigitalOutput;
DateTime : ZAux.DateTimeUM;
Logger : ZAux.LoggerFile7FFUM(datetime:=DateTime, filePath:='C:\temp\logfile.log', target:='');
Step : Step(begin:=0, end:=100);
Timer : ZAux.Timer;
END_VAR
---------------------------------
DateTime.Cyclic();
Logger.Cyclic();
CASE Step.Index OF
0:
DOutput.SetName('PumpOn');
DOutput.SetLogic(DigitalLogic.Normal);
DOutput.SetTriggerLogic(DigitalLogic.Normal);
DOutput.SetLogger(Logger);
DOutput.SetSimulation(TRUE);
Step.SetNext(10);
10: // Waiting 1sec
IF Step.OnEntry() THEN
Timer.WaitAsync(1.0);
END_IF
IF Timer.Done THEN
Step.SetNext(20);
END_IF
20: // Switch on output for 1sec
IF Step.OnEntry() THEN
DOutput.Enable(TRUE);
Timer.WaitAsync(1.0);
END_IF
IF Timer.Done THEN
Step.SetNext(30);
END_IF
30: // Switch off output
DOutput.Enable(FALSE);
Step.SetNext(40);
40: // Idling
;
END_CASE
Properties
Simulation
PROPERTY Simulation : BOOL
By default all digital interfaces that extend from this function block are simulated, to disable simulation mode this can be done by changing this property. Usually, the decision if simulation is used, takes places during initialization phase. However, some applications require to switch between these modes on-the-fly. In the latter case simply call this method at any time.
Property Value
- BOOL