02-10-2022 10:54 AM - last edited on 02-11-2022 04:40 PM by SteffenR-
In our aplication there is a valve for oil dispensing controlled by BasMoveStandard object. In manual mode I would like to avoid to leave valve opened after pressing of WrkPos button. Reason for this is the oil starts leaking out uncontrollably.
My request is (see image):
I solved this by overwriting manMoveWrkPos method of Extension but I am not sure if it is right way how to do that.
Please let me know about your ideas how to solve this correctly.
My code:
METHOD ManMoveWrkPos : DINT
VAR_INPUT
END_VAR
ManMoveWrkPos := RUNNING;
// set timer
_timer.PT := T#2S; {warning 'use station data here'}
_timer();
// Sequence for the manual function
CASE _step OF
0: // Start command
_manStartTime := TIME();
BinIo._FakeOutput := TRUE;
_timer.IN := TRUE;
_step := _step + 1;
1: // Wait until finished
ExecTimeMoveWrkPos := TIME() - _manStartTime;
IF ( _timer.Q ) AND
( ExecMoveWrkPos = FALSE )
THEN
_timer.IN := FALSE;
BinIo._FakeOutput := FALSE;
_step := 0;
ManMoveWrkPos := OK;
END_IF
END_CASE
Solved! Go to Solution.
02-11-2022 04:39 PM
I see three solutions for your use case:
Regarding your source code of the manual function:
02-14-2022 07:39 AM
Hello Steffen,
thanks for the hints! I think the method overriding is easiest way in this simple case. But points 1 and 2 are also useful.
I only change output control to SetOutput method I didn't know about event though I was checking inner methods of object 😊.
I was also trying _manStartTime, but my mistake was setting it in step 0 to T#0s instead of TIME() 🙄.
02-14-2022 07:51 AM
Here is the final code using SetOutputs method and ExecTime.
ManMoveWrkPos := RUNNING;
// Sequence for the manual function
CASE _step OF
0: // Start command
_manStartTime := TIME();
_rUnit.SetOutputs(Mode := BasMoveSetOutputMode.WRK_PATTERN);
_step := _step + 1;
1: // Wait until finished
ExecTimeMoveWrkPos := TIME() - _manStartTime;
IF ( ExecTimeMoveWrkPos > T#2S ) AND {warning 'use station data here'}
( ExecMoveWrkPos = FALSE )
THEN
_rUnit.SetOutputs(Mode := BasMoveSetOutputMode.ALL_FALSE);
_step := 0;
ManMoveWrkPos := OK;
END_IF
END_CASE