Examples of bad programming

I don't have a particular issue with any of OTL/OTU/OTE.

It's grating when OTL/OTU aren't used in complementary pairs or are referenced all over the place, or there's gigantic OTE rungs dependent on 38317229 other conditions.
 
Overuse of ONS/OSR, OTLs and OTUs is usually an indicator that the author is NOT versed in PLC programming, more from the traditional languages; they are "confused" by the programs continuous scanning.
 
Unless someone copies the same off bit & uses it elsewhere…

When I add a bypass or XIO test bit I always create a new one and label it something like:

Toggle on to bypass bad clampdown pressure switch
Toggle off to disable hydraulic valve 3

That way after testing, or running for 18 months without the pressure switch, it can just be toggled and left so it's there for the next failure.
 
The one I remember the most vividly was a Unity Pro program with about 128 IOs if I want to be generous, maybe 3/4 were DI.


First time I got there, it took me 30 minutes just to upload the program (using ETH).


There was a DI remap. That was 8000 rungs in one section, all mixed-up with no clear pattern. With tags looking like BI0001, BI0002 and so on. You cannot search comments with Schneider, it's one of two things Rockwell has an advantage in my book.


I'm only talking about the DI remap, but the rest was similar, with stupid SFC written in ladder to make it worse. Maintenance crew couldn't troubleshoot anything in there.



They were running it on the "big" Quantum rig, scan time was over 80ms, watchdog was set at 100 ms and sometimes came in.


At first I needed to replace things in there, it was a fun time to untangled that...



Then they asked that we redo the programming on all 4 units. I redid the whole thing from scratch with the same PLC, it was then running around 12 ms and it was way easier to understand.


I don't know why someone would have done a 8000 rungs remap on a brand new project back then. HMIs and SCADA were a mess too.
 
I also hate the SCADA scaling of AIs when a float is available.


-Hey, my pressure value is not good on operator screens!
-We changed the faulty 0-15 PSIG transmitter which was bad to a 0-20 PSIG and rescaled it in the PLC. You should have the same value as before.
-No, I'm reading the raw value from PLC and do my own scaling, so I'll need an outage to push that to production.
-WHY DO YOU DO THAT?!? WHY DO YOU HATE US?
 
Many years ago I was sent out on a urgent service assignment to help one of our engineers who was having problems starting up a winder with a Series Six PLC. The customer had specified Series Six, but the engineer was more familiar with Allen Bradley, so he had started with a PLC3 program for that model winder and translated it to Series Six as best he could. I wasn't all that familiar with our winder product line, but I had experience with the Series Six, which we used on another of our product lines. The winder installation was running late, the restart of the paper machine was looming, but we managed to get it working and avoid any penalties.

In delving into the original PLC3 program to try and figure out what the program was supposed to accomplish, I noticed some oddly constructed rungs. Upon doing some research after I got back to the office, I found out that the PLC3 program had itself been translated from a Series Six program written for a job a few years prior. A ladder logic game of telephone... I still cringe at all those wasted hours.
 
I don't know why someone would have done a 8000 rungs remap on a brand new project back then. HMIs and SCADA were a mess too.


Gut feeling someone converted a program from somewhere... I've seen similar in a Flexlogix that was converted from a Honeywell DCS even older than that PLC. Most tags were named "VarXXXX where XXXX is a number. No comments and the only logic that was understandable was additions over the years.

Not a complex system overall, but if no one knows how it works and there's pressure on you to bring it back into operation in a week, I can understand someone doing stuff like this.
 
Gut feeling someone converted a program from somewhere... I've seen similar in a Flexlogix that was converted from a Honeywell DCS even older than that PLC. Most tags were named "VarXXXX where XXXX is a number. No comments and the only logic that was understandable was additions over the years.

Not a complex system overall, but if no one knows how it works and there's pressure on you to bring it back into operation in a week, I can understand someone doing stuff like this.

I can understand this as well but I see this all too often with new machines. Usually the cookie cutter type machines. (casing, strapping, etc...). I get these gut feelings as well when I see PanelView controls on a PanelView Plus for example. To me this is a sign that the PLC program was probably well constructed in 1980-something but has been hacked instead of reconstructed in 2000-something.

I don't have many pet peeves with programming styles. I've spent more time modifying other's programs rather than programming from scratch. I judge by machine performance.

BTW... if any of you run into one of my programs... I'm sorry.
 
I saw that a lot when they'd only put an old Concept program into Unity Pro 2, but this wasn't the case there, they created that new overkill remap that they look they are using about 5% of it. It looks more to me that they reused something from an unrelated project to save time.


I know a guy who does that, put in every possible option he can in there wishing he could re-use its code over and over. It's gotten so fat that now he needs bigger PLCs and with each new project comes new things he didn't have so it never stops. But double the CPU, double the price. And he put rising trig everywhere, I hate that code.



Also, my memory was bad, it was not 8000 rungs, but 5000 hum, I don't know how to call that, index lines? On the left of the screenshot. Anyway, when scrolling through that while online, it's still a lot and it's very slow.

Sans titre.jpg
 
Last edited:
I can understand this as well but I see this all too often with new machines. Usually the cookie cutter type machines. (casing, strapping, etc...).


That's usually how you make money with machinery... but it requires proper planning which is where things break down. One of the best PLC programs I worked on was exactly like this, a cookie cutter with all the bells and whistles that can be configured on and off with bits. The only "issue" it had was when going to a customer that bought some particular function, we had to mess around for a bit to make them feel like they're getting their money's worth rather than showing up and leaving 15 minutes later. LOL



I get these gut feelings as well when I see PanelView controls on a PanelView Plus for example. To me this is a sign that the PLC program was probably well constructed in 1980-something but has been hacked instead of reconstructed in 2000-something.


It takes a strong character, with an equally supportive boss, to stand up to operators and manage change of their day-to-day. That's probably where this lands in my experience.



One other example of poor programming practices is when things that should be in the SCADA are in the PLC and vice-versa. I'm now working in a system that has login authorisations done in the PLC. It's ****, not secure at all and a lot of faff to deal with when SCADA's nowadays come with stuff like this out of the box that is pretty robust. On the other hand, I've seen SCADA's calculating stuff and running some boolean logic to instruct the PLC what to do rather than being all on the PLC.
 
I have the joy of maintaining some old PLC-5s. One of them has everything packed into one routine, it has 1641 rungs.

I cut my PLC teeth on PLC-5s so I would actually find joy in that. Maybe not 1641 rungs packed in LAD2, tho...

My first exposure to the PLC-5 was in a process plant that had probably 60 5/20's with a combined I/O count of something like 15,000. One OEM had a what I thought was a simple chemical batching process (maybe 200 I/O) and was required to use a 5/20. The programmer couldn't make it work to meet specifications after dozens of startup and "service" visits. His program became soooo bloated with 1500 or more rungs packed in LAD2 that he had to upgrade, on his dime, to a 5/40. Meanwhile the rest of the plant is running along smoothly on 5/20s.

I was about to be gifted the task of taking over that batching process when they lost patience with the vendor. First step would have been: start over with a new program.
 
One thing that has to be spoken about although there are some very poorly written programs out there, often (especially in the past without simulation programs we have now), is that you have to think about being on-site, production manager looking over your shoulder asking when it will be in production, the fact you are tired, in a noisy environment & struggling a bit on some problem operation that may not have been seen in the original spec. so in some circumstances even the best programmers sometimes have to divert from their normal strict routine of problem sorting & making the code right, work & look good. Then the brain saying can't wait to get back to the hotel for that juicy steak & pint.
I certainly remember one occassion where under pressure to get the plant running as they wanted it, I modified the code, worked well, on my way home the brain was still working overtime, suddenly a simple solution came into my head I realised the modifications were a bit on the fly & this new solution would have been easy to implement & keep my code in some sort of order, when sometime later I was asked to add some extra features I thought I would modify the scrappy code I put in previously as well as put in the new routines, however, when I got to site I thought to myself, NAH... If things go wrong on that original code I'm in for trouble so left it even though I was not happy.
 
I ran across some equipment from an OEM who had been given some of my programming to replicate. They took entire subroutines and made Add On Instructions from them. They didn't even do a good job of copying. There are alot of mistakes and of course if an AOI has an error in it, its going to show up every place that AOI is used.

On the same equipment they had a Panelview and it was equally as impressive. They had alot of alarms but used little home rolled message displays to pop up rather than the built in alarm function. No acknowledge, time stamp and they all had different ways to reset.

They also created users and accounts but didn't use the security or log in/out capability of the Panelview.

I've been asked to make some additions to this and am struggling with just how much of this I "fix"....
 

Similar Topics

Hi Folks, I'm giving a presentation on integrating cyber security information into the Operator HMI, and would like to show some examples of good...
Replies
8
Views
8,572
Hello, looking for ladder logic examples of the rmp instruction. Any videos out there showing how its done? Specifically looking for speed control...
Replies
1
Views
798
Hi all I am just new to this and relatively new to plc programming, I have been self teaching myself for just over a year now and have done...
Replies
36
Views
9,975
Hello, I have the software and emulate program and I am looking for application examples one by one in order to practice, test them on simulation...
Replies
4
Views
2,659
So basically I want to copy Ladders 10-19 to 20-29, 30-39 etc. All the way up to Lad 180-189 For a total of 18 copies. LAD 10-19 use...
Replies
6
Views
1,963
Back
Top Bottom