Relative Content

Tag Archive for plctwincatcodesys

How to organize Codesys programming

I come from a traditional ladder logic PLC environment like Allen-Bradley. I’m trying to understand OOP for PLCs and I’m trying to write a simple code for a conveyor, jam sensors, estops and control stations along de lane, as practice.
The issue I’m is how would you organize all of this code. Normally, using studio 5000 I would create a subroutine for Conveyors, jam sensors, estops etc. I would create global variables for my devices AOIs and share the tags/ data needed between routines.
Here in Codesys, I’m not sure if everything should be written and instantiated in the main PRG or if there is a way to have several PRGs and share data. (Similar to subroutines in AB). I’m trying to encapsulate and avoid using Global Variables but I guess my mind keeps defaulting to that “traditional” PLC code architecture. Maybe a couple conveyors and sensors would be OK but what happens when you have 100 devices. Would the Main PRG be the best way to have everything instantiated there?
If there is a video, documentation or guidance I could get on this I would greatly appreciate it.