Examples of bad programming

I worked at a plant that the senior programmer would just take out the JSR of aPLC5. For whatever reason he wouldn't delete the code. When the power would cycle to the plant. One of us would have to go in and toggle every analog card to get the correct configuration in it. This is when I learned about prescan and having multiple BTW. Once I deleted the old code that wasn't being scanned the problems went away.

I learned a lot about what not to do vs what to do from the senior guy. I explained I like to understand why not just blindly follow. So I questioned why did he do XYZ vs ABC. Sometimes I got an answer of "Just because" other times it was a well thought out answer.

I learned that messaging between controllers is a very powerful and dangerous tool. Using a message write just pushes data into a controller. So 50+ controllers just pushing data into another controller makes it fun to find out who sent what. From what I remember a message write uses 1 or 2 less connections than message read. So they used writes to keep network traffic down.
 
Wow, what an experience! Your story highlights the challenges of retrofitting systems without essential components and the ingenuity needed to make it work. It's a great lesson in the importance of considering all elements for a robust and reliable solution. Thanks for sharing!


I have a standard answer for customers that demand something like that out of ignorance or cheapness

"Tried it and it won't work"
 
Test bits EVERYWHERE

Started at a factory where each electrician had their own test bit, Carl was Test1, Test1timer and the like. Then mike was Test2_PE_problem and so on.

I just made a UDT of different basic tags, had them go through every PLC and replace their number and tags with the UDT tag "Test" and commented with their initials and then keep a log book of anything still in each PLC. Took a few weeks but really cleaned things up with only a few still in left in for outstanding issues.
 
One of the more special problems I had, was a plant with 5 PLCs and where the communication between them, was made with indirect addressing.

Since there were few communication channels in the PLC, there was a counter which counted 0-300, and where the number and the data belonging to the number were sent. There was a array at both ends with tag name Px-xxx. Receiver used number to store data in correct location in array.
In each PLC there were 4 arrays with receive data and 1 array with send data and all 5 arrays had 300 places with data to be used in the PLC program

It took some time to figure out the system
 
I have a standard answer for customers that demand something like that out of ignorance or cheapness

"Tried it and it won't work"

A little bit of explanation goes a long way, I've had to do it before when a customer requested a pick and place machine be built without sensors on the extend and retract positions on all cylinders.

"It can certainly be done without sensors like your previous engineer did, but the use of sensors means we can move as fast as possible and not rely on timer adjustments every day in order to maximize output, additionally your machine will actually be able to stop and tell the operator what it stopped for instead of putting through 1000 bad parts before they get back to check on it".
 
My first two big projects are real example of really bad programing. It was many, many years ago, and plants are still working without any problem. Fortunately I did really good site commission and extensive testing on site, so I've programmed enormous amount of good working interlocks.
Experience from that projects made me understand importance of good program, structure and label management from start and made me better.
 
I bet all of us would love the chance to re-write some of the programs we did in the past, the combination of being at the sharp end under pressure when commissioning & the expotential gain in experience ocer the years, must admit I have on a few times been able to re-visit a few jobs, one in particular was a soup making process, two of us worked on it, the process engineer from the company would steer us into his way of doing things, it worked well but seemed to me to be a bit of a mismash of code, not very flexible regarding the recipe structure (that was the main thing) any update to recipe other than simple ingredients etc. meant a lot of extra programming, some 10 years later I was given the opertunity to port the system from a very old S5 115 to a more powerful 155, I re-wrote most of the program, added a flexible recipe system unfortunately, did not commission it, the company I worked for went into liquidation, however, a guy that worked for us but was permanently on the customers site actually commissioned it, speaking to him over the commissioning period giving him some pointers of what if any had not been finished he was over the moon that the flexibility would make his job easier if the company wanted some changes.
 
Ha I had one the other day. Operators were complaining about the state of a hmi button.

Turned out the sparky had modified the "Invisible" button to turn Red/Green with the bit status!
 
One that still gets me here where I work is that we have systems that have been migrated from Klockner PLCs to Rockwell PLC5, then to Rockwell CLX.
There was an old trending system which read these tags, and in 2013 we changed to Transaction Manager, but when looking at many analog signals, there is a fudge factor (or offset) in the PLC (the reason for it is lost in history), which may also have a scaling factor in the Transaction Manager tags (historically from the old trending system), and then if you look in the SCADA, there may well be another scaling of the PLC value to Engineering Units for display.
And when you pull in the PLC5- CLX conversion involving 1771-IFE cards to CLX AI cards, there is another scaling to figure out the resolution differences between vintage cards and new cards...

Trying to ensure that the PLC does all the calculation work and is transparent to the SCADA and Trending with the same value is a thankless and almost endless task..
 
I just remember one thing that I saw and hated.


In Quantum PLCs. They used Modbus addressing to remap tags.


Let say you force Tag1 at %M1500 it would also turn on Tag2 at %M1500. But when you look up for Tag1, Tag2 don't show up, even more when Tag2 is hidden in an array. And they were doing control with both of them.



Why did they do that? Why?
 

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,566
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
797
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,974
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,658
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,961
Back
Top Bottom