We are not here to tell you the rules about everyday texting: while driving (never!), during meetings (with caution) or sending photos (with extreme caution!). On the contrary, we want to talk about Structured Text, which is a favorite IEC61131 programming language. If you are someone who started off with BASIC and Pascal, then moved to Visual Basic before sampling a variety of Basic-like motion languages, Structured Text (ST) may be in your comfort zone.
ST includes many familiar commands like WHILE loops, IF-THEN-ELSE blocks, FOR loops and the very useful CASE statement. In most IEC61131 platforms like the ACR9600 series, you will also find a full set of built-in functions for math operations (SIN, SQRT), string manipulation (LEN, LEFT) and data type conversions. When it comes to writing code with complex evaluations, ST is easier and more efficient than the graphical languages like ladder.
But now for the important thing to remember: ST acts like a PLC! You need to consider that the code will scan and run over and over, without stopping and without the need for looping. A common practice in many motion text languages is to dwell or wait for an event to happen before moving to the next line of code. You won't find the dwell or wait statements in ST and please do not try to create them! A PLC program should be designed so that it completes in a finite and fairly short and consistent time.
That said, resist the urge to create a WHILE loop that spins in place until a condition is met, such as an input being pressed by an operator. That could take seconds or even minutes. If the ST code is "waiting" for that input, the task will not complete. In many cases, other tasks will not run and background services required for communications will be stalled. Instead of waiting for that event, let the task run freely and evaluate that input condition each scan with, say, an IF statement. Once the condition evaluates true, the code can take the next step in the machine operation.
Remember to keep both your text messages and PLC programs short and clean. You don't want the machine to slow down.
Article contributed by Jim Wiley, Applications Engineer, and Mario Mitchell, Product Manager, Electronic Business Unit, Electromechanical Automation North America, Parker Hannifin. This was originally posted on the Parker Motion blog August 3, 2011.
Related posts on motion control solutions.