Studio 5000: Shortest comparison of chart of values and output value?

AutomationTechBrian

Lifetime Supporting Member
Join Date
Jul 2013
Location
St. Cloud, MN
Posts
669
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?
 
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?


With A-B syntax and limitations, and a simple-minded approach:

Code:
[MUL Timer.acc 0.07106667 an_INT]
[AND an_int 3ffh an_INT]
[DIV an_int 1024 an_INT]
[SUB 30 an_INT .len]
Caveats

  • Accuracy is some multiple (or fraction?) of ~60ms (better than 600ms; worse than 6ms)
  • Mean accuracy is perfect, or at least in the noise.
  • There may be, and probably are, better approaches
  • I may, and probably do, not understand your process
 
Last edited:

Similar Topics

Hi Everyone. Not posted on here for a long time, but I am hoping someone can help me. I am doing a differential pressure calculation in a L27ERM...
Replies
15
Views
267
Hi, how do I convert 2x Integer registers to a Real? The two integers are from Modbus registers that contain a floating point value, I need to...
Replies
2
Views
121
What is the best way to extract the hour and minute from the register that comes from Yaskawa VFD. In studio 5000 I have a register saved as INT...
Replies
3
Views
125
I have an Allen Bradley temperature switch that I am trying to use in studio 5000. I am getting the message "Unable to interpret the IODD file"...
Replies
0
Views
76
Hi all. I want to ask what may seem a stupid question, as I have a project to send live data to a Yeacode line printer which will print meterage...
Replies
10
Views
200
Back
Top Bottom