BlackBamba
Member
Hi all,
A question about preffered ways to arrange/divide sub-programs on a production line with quite a few stations.
This line has products moving on a conveyor and going through 30 stations.
Each station has a separate code "block" (this is on RX3i. In general programming terms I would call that a sub-program).
A typical station code consists of:
- Calculations, converstions etc.
- State machine management (state changes, states history, jumps etc)
- Actual state machine (states)
- Outputs section
- Status monitoring + reporting
Including the comment rungs, this spans 100+ rungs for a simple station, and sometimes 400+ rungs for the complicated ones.
On average a station has 2-3 outputs.
At the minimum, a station has 6 states.
Which means the outputs section is just small percentage of the code.
Now, if I had a dedicated PLC for every station, I think I would have separated the code to sub-programs: state machine (maybe in ST rather than LD), outputs, status monitoring. This just FEELS like a better practice.
But doing so on a single PLC means breaking stations' encapsulation while creating a huge list of global variables that will be a nightmare to browse through.
What's more... I'm not actually sure there's real benefit in such code separation? since most often (when troubleshooting) one looks at the outputs and then goes to check the state machine - where the inputs are processed.
I hope I managed to present my dilemma clearly.
Would love to learn from what others are doing.
A question about preffered ways to arrange/divide sub-programs on a production line with quite a few stations.
This line has products moving on a conveyor and going through 30 stations.
Each station has a separate code "block" (this is on RX3i. In general programming terms I would call that a sub-program).
A typical station code consists of:
- Calculations, converstions etc.
- State machine management (state changes, states history, jumps etc)
- Actual state machine (states)
- Outputs section
- Status monitoring + reporting
Including the comment rungs, this spans 100+ rungs for a simple station, and sometimes 400+ rungs for the complicated ones.
On average a station has 2-3 outputs.
At the minimum, a station has 6 states.
Which means the outputs section is just small percentage of the code.
Now, if I had a dedicated PLC for every station, I think I would have separated the code to sub-programs: state machine (maybe in ST rather than LD), outputs, status monitoring. This just FEELS like a better practice.
But doing so on a single PLC means breaking stations' encapsulation while creating a huge list of global variables that will be a nightmare to browse through.
What's more... I'm not actually sure there's real benefit in such code separation? since most often (when troubleshooting) one looks at the outputs and then goes to check the state machine - where the inputs are processed.
I hope I managed to present my dilemma clearly.
Would love to learn from what others are doing.