Equipment - Actuators (unmanaged)
Generally speaking actuators are every parts in an automation projects which are moving something. In Zeugwerk Framework, when we speak of actuators we usually mean penumatically or hydraulic cylinders/axes which are moving from one end stop to another. There can be a lot of different stages of extensions for example:
- limit switch on plus side
- limit switch on minus side
- limit switch on both sides
- no limit switch at all
- mono stable valve
- bistable valve
For all of this stages there is a proper object in Zeugwerk Framework ZEquipment library which can be used and has all the nice features like all the other objecs:
- automatic logging (if configured)
- error handling
- observing movement (timeouts)
- simulation build in
In this tutorial we will learn how to use those actuators in a legacy or better said non Zeugwerk template application. So lets get started...
Creating a Test application
First of all, for this tutorial no hardware (except your notebook with a working twincat installation) is needed. Zeugwerk Framework actuators can be fully simulated and we run our examples in Twincat Usermode Runtime which is a great way to test code in a non realtime environment.
Lets assume we have the maximum featured actuation system in our production line and want to test this. Its a simple pneumatical cylinder with two bistable valves and two limit switches. Copy the following example code in your prepared solution:
PROGRAM MAIN
VAR
DateTime : ZAux.DateTimeUM;
Logger : ZAux.LoggerFile7FFUM(datetime:=DateTime, filePath:='C:\temp\logfile.log', target:='');
Step : ZCore.Step(0, 100);
Actuator : ZEquipment.ActuatorDigitalBiLsPlusMinusUM;
ManualPlus : BOOL;
ManualMinus : BOOL;
END_VAR
----------------------------------------
DateTime.Cyclic();
Logger.Cyclic();
Actuator.Cyclic();
CASE Step.Index OF
0:
IF Logger.Operational
THEN
Logger.Info('Appliation started');
Step.SetNext(10);
END_IF
10:
Actuator.SetLogger(Logger);
Actuator.SetName(name:='Horizontal Actuator',
movePlusName:='MoveLeft', moveMinusName:='MoveRight',
plusName:='Left', minusName:='Right');
Actuator.SetDelay(plusStartDuration:=0.0, plusEndDuration:=0.0,
minusStartDuration:=0.0, minusEndDuration:=0.0,
stop:=0.0);
Actuator.SetMovementDuration(plusDuration:=3.0, minusDuration:=3.0);
Actuator.SetSimulation(ActuatorDigitalSimulation.Automatic);
Actuator.SetSimulationUncertainty(10.0);
Actuator.SetSwitchDuration(plusDuration:=0.3, minusDuration:=0.3);
Actuator.SetTimeout(plusDuration:=3.5, minusDuration:=3.5);
Step.SetNext(20);
20:
IF ManualPlus OR ManualMinus THEN
Step.SetNext(30);
END_IF
30:
IF Step.OnEntry() THEN
IF ManualPlus THEN Actuator.MovePlusAsync(0); END_IF
IF ManualMinus THEN Actuator.MoveMinusAsync(0); END_IF
ManualPlus := ManualMinus := FALSE;
END_IF
IF Actuator.Error THEN
Logger.Error(Actuator.ErrorMessage());
Step.SetNext(20);
ELSIF NOT Actuator.Busy THEN
Logger.Info('Actuator movement finished!');
Step.SetNext(20);
END_IF
END_CASE
First we have to wait until the Zeugwerk Framework logging object is initialized and after that we initialize the actuator object. The following settings are set:
- Logger: logging object to log each step the actuator takes in a text written logfile
- Name: name for the actuator to be able to distinguish between other objects and this one.
- Delay: Delay duration for starting a plus or a minus movement and also stop. These durations are waited for eacht step of the movement (before start, after end of movement and after a stop)
- MovementDuration: This durations are set for simulation purposes or if there are no limit switches on one of each sides, the object stays busy until this duration is over
- Simulation: sets this object in simulation mode for automatic or digital twin mode (the latter is used to be able to set the limit switch from an external software)
- SimulationUncertainty: sets a specific randomized duration over the parametrized plus and minus duration times
- SwitchDuration: for bistable valves this is the time how long the valve gets activated
- Timeout: Duration which the object waits until the actuator reaches its end stop
In the next step we wait until one of those start flags (ManualPlus or ManualMinus) gets triggerd in online mode of Twincat.
Lets Trigger Manual Plus and see whats happening. The actuator will set its output in the way its parametrtized and it will get Busy (Busy=TRUE). After the parametrized PlusDuration the actuator is no (in simulation) on the Left and is Busy=FALSE, so finished.