best plc programming tips:

Here's a really stupid error that I made the first time I used TIA. It will absolutely allow you to assign multiple things to the same bit.
For example I'd written a program that used say M10.0, but also had a real/double word value that was assigned to MD8, which takes up MB8, MB9, MB10 and MB11. As my value was changing, M10.0 was seeminly doing whatever the hell it wanted as that bit was encompassed in the MD8 value. Then I found the assignment list and realised what an idiot I am.

Nevermind Bubba, everything makes sense when you write it. When you come back to it two years later you'll wish you'd kept it simple.

Yes, but very easy to do. Especially easy to do w/ 'some' plc's more than others.

Quick story:
I don't remember how the conversation started. Just going to presume I said something like: "It's cool that all of the orrifice plates are the same".
customer: wtf?
me: they are all using the same constant in the program.
Apparently the customer had been driving to each of them in his service truck, correcting the program at each one and moving to the next one.
But, the customer was unaware that each site was using the same %MW/4x/located memory on the variable.
Worse: They were reporting the data to a college university that was studying the data.
Only he and I know that all those years, California University was studying bad data.

P.S. Totally unrelated to this post, but if anyone knows someone that was studying Aera Energy Automatic Well Testing oil data before 2005, hint hint.
 
Last edited:
What is the best way to mark a tag as being written to in a plc from an hmi?
I would add some text to the tag.
What would the text be?
it could be 'hmi'.
Ok, but then every tag in the hmi software would have 'hmi' at the end (if you wanted them to match the plc tag). That would look dumb in the hmi.
hmm
Capitalize the tag? Saw a company that did that. It falls apart somewhere.
 
What is the best way to mark a tag as being written to in a plc from an hmi?/QUOTE]


In the comments?

If a suffix of "_HMI" is going look dumb in the HMI, then so is "_SP" or "_TRG" or "_OP" (setpoint or target or operator).

That is kind of what I did.
I wrote a section of code (pou in codesys) called hmi or something.
I made sure to comment it's purpose.

Just wondering what you all do here.
 
Along the lines of MAP_INPUTS and MAP_OUTPUTS, I use program names like MAP_HMI_IN and MAP_HMI_OUT, makes it pretty clear if the HMI is writing a value to somewhere (numeric input for example) or reading it from somewhere (display process value, etc). So now there's minimum 4 files just to get I/O, let alone actually process anything.
 
Make sure all routines are Called.

Double check scope of tags (Local vs Global). In RSLogix5000/Studio5000, Controller scope vs. Program scope.
 
HMI_ for any tag being written to from an HMI works for us.
Mapping data changed for HMIs or Message Write data in Rockwell is another one to ensure the data isn't changing states midway through the code when the write happens. Saves many hours with intermittent issues that happen so fast you'll never see.
 
HMI_ for any tag being written to from an HMI works for us.
Mapping data changed for HMIs or Message Write data in Rockwell is another one to ensure the data isn't changing states midway through the code when the write happens. Saves many hours with intermittent issues that happen so fast you'll never see.

Yes, the asynchronous writes to the plc in the AB. I experienced that. I wrote code to confirm that the value could change in between lines of code.
 
An very senior programmer once told me:
"Always break the code down to it's simplest form"
He said it better. Basically the KISS principle.
But building simple objects is key.
 
Yes to mapping inputs and outputs. This way your core logic stays the same and you are mapping into it.
KEEP IT SIMPLE. Just because the Logic supports all sorts of fancy operations, does not mean you have to invent ways to use them. I get very tired of running into logic that someone wanted to show how fancy (or complicated) they could do it.
 
Mapping IO, or Mapping anything related to IO including words containing IO like in devicenet type setups. It's frustrating enough to have to know how somebody mapped it, just make it look as simple as possible before throwing that data in the program without a good single file mapping setup. Same goes for things like device settings/M files in logix500, etc... I shouldn't find the M file setup 3/4 of the way down a random file unassociated with the encoder setup.


Leave comments above individual instructions that are important as to where they come from or why.

Comment on rungs to show what each section does so nobody has to decipher what something does later.


Leave a master comment in the main rung that has a list of all edits and changes made and where they were made and why. A good list has helped me later to not only know what someone else did, but what I did last time I modified something... Especially when it took me 30 minutes of clicking through find all or cross referencing to get to the source of an issue the first time.


working with other people who fix/build/repair/integrate/program, it has always helped to know who last worked on something, so you can go to the source with a questions of what was changed last and why. put your name somewhere in it, we typically make a new file save with date and initials when something gets changed.


and I'm not the most experienced programmer, so I don't know why they would do this, but I feel like using memory saving programming tricks like disabling rungs unless scanned and using jumps and labels when the program is not large enough to cause a problem just doesn't help. I even adds to the issues from my experience. I think this goes back to 'KISS'.
 
Last edited:
What is the best way to mark a tag as being written to in a plc from an hmi?
I would add some text to the tag.


My tags are Temperature_SP and Temperature_SP_Entry for the HMI entered new value.


To toggle a BOOL the watched tag is Pump_Enabled and the HMI button is Pump_Enable_PB to tell the PLC to toggle it, if everything is OK to toggle it, not just have the HMI directly toggle something. The same with values, the PLC makes sure the new value is in the allowed range and conditions are OK to change the value
 

Similar Topics

Hi there PLC aficionados, I have a quick question for you. Do you use Linux in your integrator/automation engineer/Technician role? If, yes which...
Replies
20
Views
8,190
hello, I got a job in a factory. I would like to develop my PLC programming skills. I know that every person has his own way of learning but if...
Replies
9
Views
2,473
Or, what PLC do you enjoy programming the most? I enjoy programming software/environments that allow me to mix different languages. I like to do...
Replies
13
Views
6,164
I have a business in the packaging industry and I would like to get proficient with PLC programming, troubleshooting, etc. I come from a computer...
Replies
6
Views
9,999
Old topic, but since serial ports are disapearing rapidly, ...I thought I'd ask the question again.
Replies
20
Views
12,100
Back
Top Bottom