Hello everybody!
It's been a while since my last post... (to long!)
But here is a problem I'm sure the members of PLCtalk can help out with (and even gain som info from):
I've been trying to come up with a good solution on how to monitor a movement (like a cylinder moving back and forth) for errors.
Let's say you have a movement like this:
With one output (Y1) making it move out (hitting sensor S1) and spring return making it move backwards (hitting sensor S2).
The normal approach to detect an error on this would be to use a timer that runs when you have output Y1 and not input S1 and vice versa. If this timer reached it's timervalue then you would have an error.
The problem with this solution is that it eats up a lot of the cpu power in the plc (scantime) since it has to run one timer pr. movement. And on a bigger machine this would be a LOT of timers...
My approach to this problem is the following:
The situation giving the error is static; meaning if the outputs and sensors stays on for a given time then that would indicate an error.
So based on this I came up with the idea that all I had to do was to check for the error every X second and for only one plc scan.
Principal:
Scan number - Action
1 - Save status of inputs and outputs
2 - Compare current inputs and outputs to saved status.
If same, perform alarm logic and trigg error if logic is true.
If different, no error (since were looking at an static situation)
Checkin the error logic every second scan would give us minimum x seconds of static situation before the error would be detected. If X was 5 seconds then it would be a minimum time before error is detected of 5 seconds and maximum 10 seconds.
And it would not affect the plc scantime since it's only being trigged one scan.
The problem however is that sometimes (when used on a machine, not when simulated) is that it triggers the alarm when there is no error. I suspect this to be due to the monitored movement happing at the "wrong" time. I thought I would not have this problem when I was doing it in the manner being described above but it's still happening. I can't see any error in the plc program either so I'm posting it here to have some new inputs from you guys...
I hope the above description makes sence if not I'll try to explain further...
My code is attached here:
Cheers
Borte
It's been a while since my last post... (to long!)
But here is a problem I'm sure the members of PLCtalk can help out with (and even gain som info from):
I've been trying to come up with a good solution on how to monitor a movement (like a cylinder moving back and forth) for errors.
Let's say you have a movement like this:
With one output (Y1) making it move out (hitting sensor S1) and spring return making it move backwards (hitting sensor S2).
Code:
S2 S1
|---------| | |
| |------------
|---------|
The problem with this solution is that it eats up a lot of the cpu power in the plc (scantime) since it has to run one timer pr. movement. And on a bigger machine this would be a LOT of timers...
My approach to this problem is the following:
The situation giving the error is static; meaning if the outputs and sensors stays on for a given time then that would indicate an error.
So based on this I came up with the idea that all I had to do was to check for the error every X second and for only one plc scan.
Principal:
Scan number - Action
1 - Save status of inputs and outputs
2 - Compare current inputs and outputs to saved status.
If same, perform alarm logic and trigg error if logic is true.
If different, no error (since were looking at an static situation)
Checkin the error logic every second scan would give us minimum x seconds of static situation before the error would be detected. If X was 5 seconds then it would be a minimum time before error is detected of 5 seconds and maximum 10 seconds.
And it would not affect the plc scantime since it's only being trigged one scan.
The problem however is that sometimes (when used on a machine, not when simulated) is that it triggers the alarm when there is no error. I suspect this to be due to the monitored movement happing at the "wrong" time. I thought I would not have this problem when I was doing it in the manner being described above but it's still happening. I can't see any error in the plc program either so I'm posting it here to have some new inputs from you guys...
I hope the above description makes sence if not I'll try to explain further...
My code is attached here:
Code:
FUNCTION "ALM_V2_SSY" : VOID
TITLE =
AUTHOR : Borte
FAMILY : ALM_V2
NAME : SSY
VERSION : 2.0
VAR_INPUT
S1 : BOOL ;
S2 : BOOL ;
Y1 : BOOL ;
END_VAR
VAR_IN_OUT
AlmState : BOOL ;
AlmState_S1 : BOOL ;
AlmState_S2 : BOOL ;
AlmState_Y1 : BOOL ;
ErrorDetected : BOOL ;
END_VAR
BEGIN
NETWORK
TITLE =
SET ;
A #AlmState;
JC M001;
// Save signal state
A #S1;
= #AlmState_S1;
A #S2;
= #AlmState_S2;
A #Y1;
= #AlmState_Y1;
SET ;
S #AlmState;
JU Chng;
M001: NOP 0;
SET ;
R #AlmState;
// Check for changes in state
A #S1;
X #AlmState_S1;
JC Chng;
SET ;
A #S2;
X #AlmState_S2;
JC Chng;
SET ;
A #Y1;
X #AlmState_Y1;
JC Chng;
// Alarm logic
SET ;
R #ErrorDetected;
AN #AlmState_Y1;
AN #AlmState_S2;
S #ErrorDetected;
SET ;
A #AlmState_Y1;
AN #AlmState_S1;
S #ErrorDetected;
SET ;
A #AlmState_S1;
A #AlmState_S2;
S #ErrorDetected;
JU End;
Chng: NOP 0;
// Change detected, No error
R #ErrorDetected;
End: SET ;
A #ErrorDetected;
SAVE ;
BEU ;
END_FUNCTION
Cheers
Borte