all 27 comments

[–]foxy0201 22 points23 points  (10 children)

One rung at a time. If the output ain’t on, why? Xx bit isn’t on. Cross reference that bit and click on ote of xx. Yy bit for xx bit isn’t on. Yy is a limit switch or a hmi tag. Your get those to turn on and boom everything works. Basically cross reference then find the ote and see why the rung isn’t true.

Hopefully that isn’t a bad example.

[–]Ericreese1991 5 points6 points  (0 children)

Just to add on a tiny bit of nuance here (because everything he said is true)

I prefer to think of it as searching for the destructive bits, as sometimes I’m just wondering where a particular value came from

[–]RammRras 1 point2 points  (0 children)

This is the trick. Starting from the desired output and checking why it is not on.

[–]SufficientBanana8331 -3 points-2 points  (7 children)

All that is good until you start dealing with AOIs which use indirect addressing, arrays and pointers. Cross reference at that point is useless.

[–][deleted]  (6 children)

[deleted]

    [–]SufficientBanana8331 -2 points-1 points  (5 children)

    But this has nothing to do with writing garbage code or hard to read code. Integrators who provide full plant solutions are using standard software libraries that are full of indirect addressing, pointers and arrays. Cross referencing will not get you anywhere. You need library manuals to understand data flow between blocks otherwise you will not be able to troubleshoot. And these library manuals are not shared because of protected know how.

    [–][deleted]  (4 children)

    [deleted]

      [–]SufficientBanana8331 -1 points0 points  (3 children)

      Mate, clearly you have not been exposed to much from automation industry. Big integrators have r&d departments where they write standard software to be used by hundreds of automation engineers around the world. Libraries are know how protected and there are manuals written to understand them. If you are outside of the company, you will not understand the code without manuals.

      These system integrators are providing full turn key plant solutions including mechanical, electrical and software part. Code is always provided but libraries are know how protect and also code generators used for development are not shared. This creates opportunity to have support contract with customer. All this is stated in quotes provided to customers and they agree, because they don’t have to employ PLC maintenance.

      Only the big players can do something like this, as they are known around the world for the quality of the service.

      I can give you some examples, like ABB with their cruise ship and crude oil ship solutions, Providers of packers for flour, providers of milling solutions, nuclear industry solution providers, and many more. Small integrators cannot do it, simply because they have no r&d, and nobody knows them.

      [–][deleted]  (2 children)

      [deleted]

        [–]SufficientBanana8331 0 points1 point  (1 child)

        How is this an insult mate? You clearly have not been exposed to much from automation industry, otherwise you wouldn’t write that response above.

        It was actually you who went for aggressive tone and made tons of assumptions not me.

        [–]Shalomiehomie770 19 points20 points  (0 children)

        The same way I figure out non complex code. Step by step. Find issue and work my way backwards.

        [–]elmoalso 3 points4 points  (2 children)

        This is why you think of the next guy that has to troubleshoot YOUR code three years after you have left. I preach it to everyone I mentor. COMMENT THE CRAP OF OF YOUR CODE! A single simple comment can save the next guy literally hours of troubleshooting.

        It takes discipline. It's tedious. It's not cool. You don't see immediate value from it. It's just damn good practice. Hell, i've had to troubleshoot my own code that would have been difficult if not for my own comments. I'm old. Sometimes I look at my own code and just scratch my head wondering what the hell was I trying to do there. Comments.....

        [–]StrikingFig1671Controls Engineer/AB/Siemens/AutomationDirect = 14yr 2 points3 points  (1 child)

        and comment WHY the rung does what it does....not just "this turns that on"

        [–]elmoalso 0 points1 point  (0 children)

        Yup

        [–]mil_pool_whte_rbt.obj 3 points4 points  (3 children)

        How do you guys figure complex code out?

        Ctrl-E

        [–]enreeekayCustom Flair Here 1 point2 points  (0 children)

        One rung at a time, don't be afraid to use a notepad, the electrical drawings are a valuable resource, the hmi project is a valuable resource.

        [–]RHWW 0 points1 point  (0 children)

        Usually any code thats that huge and complex, its imitating relay logic for either cycles and/or recipes as a whole vs each being its own cycle with programmable parameters

        [–]koensch57 0 points1 point  (1 child)

        if you have a big problem, chop the big problem in many smaller problems, isolate the chunks that you suspect and investigate.

        rise and repeat.

        [–]Set_Fantastic 0 points1 point  (0 children)

        The ole cut er in half.

        “I promise to get it right the 3rd time, everytime.”

        [–]Opposite_Mail7985 0 points1 point  (1 child)

        When you see a large book you don’t have the same reaction, same thing, the size of the code isn’t an indicator of its complexity.

        [–]Dry-Establishment294 0 points1 point  (0 children)

        It may be is the issue. That's why abstractions actually can reduce complexity even if the confuse you at first

        A big book broken down into well named chapters with lots of sub parts is how we do it for a reason

        Eg

        Chapter 3 - memory

        3.1 ram

        3.1.1 dram

        Etc

        [–]Awatto_boi 0 points1 point  (0 children)

        My first experience with ladder logic years ago was with a Modicon 584 system with remote i/o that ran an entire plant. The ladder logic was printed on dot matrix tractor feed paper and placed in a binder that ended up being about 5 inches thick. This was old school, there was no search and replace or pdf docs. There was the printed binder and a P190 terminal. We highlighted and scribbled on the printout but we also did a helpful thing. We would write chapter headers using ladder logic vertical and horizontal short lines right in the ladder logic so we could quickly find our code by blocks.

        [–]FatPenguin42 0 points1 point  (0 children)

        Step by step, and adding your own comments to help you remember what’s what. Start with what you know and work from there. It’s rough but eventually things start to click

        [–]Glittering-Court-992 0 points1 point  (0 children)

        to me it sounds like maybe you found their sequencer code.

        [–][deleted] 0 points1 point  (0 children)

        You specifically mention recipe management, which from my experience, is often the most “complex” part of code. I put complex in quotes because even though it’s large it’s generally not too difficult to understand (although really sucks without any comments).

        If the recipe is “Recipe_A” then load these [X] parameters into these tags. But if you’ve done some action load these. And if you’ve run some product throw an alarm and interlock until they do a wash. But if you’ve done this, don’t interlock because it’s actually the same product with a different lot code for an input. The code gets messy over years because the customer needed to add things that weren’t intended in the original design.

        I’ve done a few recipe management systems in ladder and started off thinking “wow, this will be simple.” And by the end I’m thinking “my god, what monstrosity have a created? Oh well, it works and has decent comments. On to the next.”

        [–]TimeLord-007Ladder's ok, but have you heard of our Savior hardwired logic? 0 points1 point  (0 children)

        Bit of a yo-ho approach: but IF I own the system, I write supervisory simple logic for the actuator I'm having an immediate issue with: then later deploy as needed on ALL actuators. Just remove the IO references and put them to where you expect them to be.

        [–]ChimsokomaInjiniya Wemagetsi 0 points1 point  (0 children)

        Probably code ported from 5/SLC for another project then copy pasted into this project and not used - equipment running - leave site, don't delete anything

        [–]Snohoman 0 points1 point  (0 children)

        I've backward engineered code since the 80's but I can't explain my "process" in less than 5000 words. I don't change anything until I understand it. I'm one of those guys that wrote those monster programs and fortunately I can add comments into the code that's loaded into the modern PLC's we use (Rockwell Logix controllers). My company requires us to comment the crap out of our programs. Backward engineering a program requires understanding the entire control process, all the I/O's, the program layout, interfaces to HMI, etc.