BobCully
Industrial
- Feb 23, 2002
- 6
On a standard(ish) processing machine that we produce, I have several (maybe 20) sequence programs running simultaneously. To step through each sequence I arrange a group of flags into a shift register- 8,12 or 16 bits long.
The first flag in the group (the lowest) is forced on when the sequence begins, and that flag controls that `Step' in the sequence. When that step finishes I give a SFL K1 instruction (shift left 1 position), which turns that step flag off and the next one on. It works fine.
Sometimes however things don't go as planned, and a switch (or something else) doesn't make and the sequence stalls. What I need is and indicator to tell me which step of the sequences is on at any time, and what I'm looking for is an elegant way to return a number corresponding to the position in the sequence of the `on' flag - just as a (step) number. For example, `M251 K2' defines a set of (K)2x4 flags starting at M251, M251 being the first bit and M258 being the 8th. I want a function that will hold in say register D250 the value 1 to 8 depending on which flag is set. I eventually want to have a page on the MMI to report the status of all these Sequences. I haven't been able to figure a way out of how to do it `in the back-ground' while the sequence is running. All I've been able to come up with is to include a line in each step of the sequence to say `INC D250', and then zero it at the end of the sequence, but its a bit messy.
Has anybody any thoughts?, do other PLC's have a neat command for doing this (and how does it work)? (but I'm not going to change!).
Regards
The first flag in the group (the lowest) is forced on when the sequence begins, and that flag controls that `Step' in the sequence. When that step finishes I give a SFL K1 instruction (shift left 1 position), which turns that step flag off and the next one on. It works fine.
Sometimes however things don't go as planned, and a switch (or something else) doesn't make and the sequence stalls. What I need is and indicator to tell me which step of the sequences is on at any time, and what I'm looking for is an elegant way to return a number corresponding to the position in the sequence of the `on' flag - just as a (step) number. For example, `M251 K2' defines a set of (K)2x4 flags starting at M251, M251 being the first bit and M258 being the 8th. I want a function that will hold in say register D250 the value 1 to 8 depending on which flag is set. I eventually want to have a page on the MMI to report the status of all these Sequences. I haven't been able to figure a way out of how to do it `in the back-ground' while the sequence is running. All I've been able to come up with is to include a line in each step of the sequence to say `INC D250', and then zero it at the end of the sequence, but its a bit messy.
Has anybody any thoughts?, do other PLC's have a neat command for doing this (and how does it work)? (but I'm not going to change!).
Regards