How to use structure text to write a simple indexing rotary table plc program
What is a indexing rotary table machine
Brief definition:
At least one material input station and one finished product output station
At least one indexing rotary table
The indexing rotary table has a different number of divisions (or workstations) according to the manufacturing process
Each division can place one or more workpieces
Materials can input by man or feeder.
Found on the Internet:
Program Layout
Generally, I’ll layout the plc program as :
“Init” : Initialization code
“Always” : The normal execution code, including the Instance of Function Block
“Auto” : Automatic mode control
“Manual” : Manual mode control
“Error” : Error status control code
“St1”
“Stx” : Cycle control code of each station
State Machine
I’d like to centralization the mode control in one state machine, as shown in the figure:
If it is a simpler system, it will be simplified to only manual/automatic switching, or execute according to individual needs.
Of course, the actions of each station are also processed by their own state machine. In automatic mode, the role of the main state machine is only to evoke the status of whether each station needs to perform an action and check completion.
Timing diagram
a: The first automatic action is to turn the indexing rotary table, then let each station act
b: After the indexing rotary table is arrived, St2Cycle can work
c: The indexing rotary table will be rotated again after the St1 and St2 (all stations) operations are completed
The indexing table basically has only two states:
Rotating
Stopped in place
And each station basically has two types,
Can only act after the indexing rotary table is in place
You can do act first, and then continue to act after the indexing rotary table is in place
As shown in the figure above, St1 can pre-act while rotating, while St2 can only be acted after it is in place.
In fact, sometimes its more intuitive to use the ladder style, but the advantage of ST is that it is convenient to write automatic code generator, It can shorten a lot of time during development.
Pay attention to when writing ST:
":=" equivalent “out” command
The “if” instruction will take up more steps
If there is only one line of instructions, it is recommended to switch to a single command. Although it is less readable, it saves more steps…
Enable label in simple project for better program layout
In general, we use “Ctrl + L” or “Ctrl + G” to track our ladder program, which is great, but it would be better if we use the label feature in simple project.
ps: Label feature will slightly slow down compilation speed.