I am a trained Computer Scientist from a University to preface what I am about to say. On a recent project involving, the use of Human Machine Interface (HMI), bar_code Scanner, and Sequencing lights with various human involvement and parsing data and such, I ran into a problem's with the traditional practice of PLC programming of putting everything into the main rung. It was getting so irritating to wade through the main rung as it grow closer to 40 lines. Logic that I did not want to run on a certain screen I had to block off with a equivalent screen check every time. In general I believe that the traditional pattern was giving me errors and was incredibly hard to debug for my application. I know that people have down bigger programs but I saw no reason to wade through a program that would probably reach close to 50-70 rungs, worse maybe even more than that.
Then I realized that each screen was a state, It had private functionality that only that certain screen needed to do, and therefore I restructured my code to reflect that each screen only has functions that it needs to run. It was beautiful, the bugs I had disappeared, adding functionality that wouldn't affect other functionality was a breeze without having to worry so much about what affected what. Looking back I see how my logic might be able to be applied to the traditional pattern; however I argue that in the case of my program this pattern is no brainier keeping the size of the main rung down while having the peace of mind that functionality is being limited by the current screen.
Debugging in this way has also been extremely efficient when I have a problem on a screen I will be scrolling through a average ladder size of 10 with a max of 15 and can easily pin point problems spots. Checking Global Variables is fast and efficient because I can change the state of them to what I need to if a screen change has to occur before I make the jump into a new screen.
Am I young engineer that is full of it and should stick to the traditional practices or is this a innovation that is useful to the industry? Are people doing this now?
Thanks For Your Input Chris Johnson
Aucun commentaire:
Enregistrer un commentaire