AutomationTechBrian
Lifetime Supporting Member
I'm trying to get beyond "do-done" programming and utilize higher functions to make my routines smaller and easier to write. I've just started working with SQO, and I'm making a sequence array for the machine's red, yellow, and green LED lights. The first couple of array values empty, then alternating the red, yellow, and green LED bits
----RYG
(0) 010
(1) 000 (no red or green)
(2) 010
(3) 101
(4) 010
(5) 101
(6) 010
(7) 101
(8) 010
(9) 101
(10) 010
(11) 101
etc...
Then I can mask to get:
Flashing Red
Flashing Yellow
Flashing Green
Alternating Red and Yellow
Alternating Green and Yellow
The machine doesn't have an HMI, so I'm using the LEDs to give feedback on what is going on. I use masks to control which color(s) output, and I vary the length of the SQO to vary the number of flashes before a pause (ie... pause, 4 red flashes, pause, 4 red flashes, pause, etc.). There is a homing routine, and a cycle routine, with sequence steps and a 5 or 15 minute timer for the main cycle. The idea I have this morning, is using green flashes to signal how many minutes are left in the cycle. Like this:
Timer.acc value: > 0ms & < 60,000ms, MOV 30 to .len
Timer.acc value: > 60,000ms & < 120,000ms, MOV 29 to .len
Timer.acc value: > 120,000ms & < 180,000ms, MOV 28 to .len
Timer.acc value: > 180,000ms & < 240,000ms, MOV 27 to .len
etc.
What would be the shortest way to create accomplish this? I'm not talking about a long, 30+ rung ladder. That's what I'm trying to get beyond. I want something much shorter, more elegant, maybe utilizing an array of the values that I'm comparing, as well as the MOV length. Structured text is OK, if that is really the best way. I have just started looking at ST this year, but I can't write it without prompts yet. I suspect there is another way.
There are so many opportunities to use this type of comparison. This would be useful to know, not only for me, but lots of other members. Any thoughts?
----RYG
(0) 010
(1) 000 (no red or green)
(2) 010
(3) 101
(4) 010
(5) 101
(6) 010
(7) 101
(8) 010
(9) 101
(10) 010
(11) 101
etc...
Then I can mask to get:
Flashing Red
Flashing Yellow
Flashing Green
Alternating Red and Yellow
Alternating Green and Yellow
The machine doesn't have an HMI, so I'm using the LEDs to give feedback on what is going on. I use masks to control which color(s) output, and I vary the length of the SQO to vary the number of flashes before a pause (ie... pause, 4 red flashes, pause, 4 red flashes, pause, etc.). There is a homing routine, and a cycle routine, with sequence steps and a 5 or 15 minute timer for the main cycle. The idea I have this morning, is using green flashes to signal how many minutes are left in the cycle. Like this:
Timer.acc value: > 0ms & < 60,000ms, MOV 30 to .len
Timer.acc value: > 60,000ms & < 120,000ms, MOV 29 to .len
Timer.acc value: > 120,000ms & < 180,000ms, MOV 28 to .len
Timer.acc value: > 180,000ms & < 240,000ms, MOV 27 to .len
etc.
What would be the shortest way to create accomplish this? I'm not talking about a long, 30+ rung ladder. That's what I'm trying to get beyond. I want something much shorter, more elegant, maybe utilizing an array of the values that I'm comparing, as well as the MOV length. Structured text is OK, if that is really the best way. I have just started looking at ST this year, but I can't write it without prompts yet. I suspect there is another way.
There are so many opportunities to use this type of comparison. This would be useful to know, not only for me, but lots of other members. Any thoughts?