Clx - nop

BillRobinson

Member
Join Date
Oct 2006
Location
Sydney, Nova Scotia
Posts
185
I'm looking through a piece of ladder code put out by Allen Bradley and it's got NOP's all over the place. Is this just left over code from debugging or does is actually do anything in a ladder code?
 
NOP = No Operation

It's an instruction guaranteed to do absolutely nothing.

Which can be a good thing, if you want a rung to hang a comment on. Beats keeping track of dummy bits.
 
The NOP is also handy when you want to pass parameters into a subroutine but don't want to have to hang output logic on the end of the first rung after the SBR instruction.
 
So as you can see by the comments already, there is a use for the instruction. But your suspicion of left over code is certainly possible as well.

OG
 
The NOP is also handy when you want to pass parameters into a subroutine but don't want to have to hang output logic on the end of the first rung after the SBR instruction.

IMHO that is the only place I want to see a NOP

The SBR instruction is required to accept parameters passed to a subroutine, and is classed as a "Program Control Instruction".

I do not want to mix "Program Control Instructions" with application instructions, so I always put a NOP as the output instruction on the first rung of a subroutine file which uses an SBR - keeps everything in its proper place......
 
@ Alaric and Daba

Can you guys give a example. I have never had to pass paramets into a sub. Where and why would you need to do this. I have only had experience using subs to keep my programs organized and when logic is only needed sometimes.

Sounds interesting but i am lost?
 
If I'm planning a big change that must be done online, I will use NOPs as place markers. Otherwise passing parameters to subroutines is the only real use I can think of
 
If I'm planning a big change that must be done online, I will use NOPs as place markers. Otherwise passing parameters to subroutines is the only real use I can think of

Why use NOPs as place markers ?

Why not create a BOOL tag called TWControls or your name, put a rung at the bebinning of the code to OTU that tag, and use it as a AFI (use XIC) or AFT (use XIO). You can always cross-reference them instead of having to search for NOPs. And what if someone else puts a NOP in the code ???

And The PLC Kid - very often you will want to use a subroutine multiple times, with different data, you can pass Input parameters, and get back Return parameters - example : You write a subroutine to calculate the area of a circle (i know, easy, but this is an example), you will pass into the subroutine the radius or diameter, and get back the calculated area.

The use of subroutines in this way is being made obsolete in Logix5000 Vers. 16 and up by the Add-On Instruction feature.
 
Can you guys give a example.

here's a quick down-and-dirty example that I use in some of my classes ... this should be enough to give you the basic ideas - but ask if you have additional questions ...

first the "subroutine calls" ...

(continued in next post) ...

pass_parameters_1.JPG
 
Last edited:
and now the subroutine itself ...

and incidentally, the platforms that use RSLogix500 can't "pass parameters" this way ...

the next step of "elegance/complexity" might be to use Indirect Addressing to change the locations of the "passed parameters" - so that you'd only need one "calling" JSR rather than three ...

of course the more "elegance/complexity" you add, the harder the code gets for the mere mortals to troubleshoot at 3:00 o'clock in the morning ...

pass_parameters_2.JPG
 
Last edited:
I always use an NOP on an otherwise empty first rung of every subroutine.
The comment on this rung details what the subroutine does. Not in exact detail (the individual rung comments are for this)

For example.

SUBROUTINE PURPOSE:
To control and monitor the Waste Water Pump 5 (WWP-5)
This is a VFD controlled 3kw pump that transfers the raw sewage from the main holding tank to the aeration pond.


This little bit of info is so handy later on for either you or whoever follows you.

Regards Alan
 
Why use NOPs as place markers ?

Why not create a BOOL tag called TWControls or your name, put a rung at the bebinning of the code to OTU that tag, and use it as a AFI (use XIC) or AFT (use XIO). You can always cross-reference them instead of having to search for NOPs. And what if someone else puts a NOP in the code ???

Since you brought up the what if...what if someone deleted the OTU rung thinking it had been added for some debuging that was no longer used? Then some other person comes along and wonders what the BOOL tag TWControls does and toggles it? NOPs just seem safer to me. More than anything they are just in case someone else adds a rung and throws off my rung numbers in my note by one or two or twenty. Still nothing long term, a week at the max probably
 
One reason I advocate the use of bespoke tags for edit markers, false instructions, true instructions, etc. is that I have worked on projects that had multiple engineers writing code, simulating, and commissioning.

I made them use a tag named with their initials so that they could have their own "markers", and I could police that they were resolving issues by removing them. A quick x-ref on these tags easily showed their progress.

I banned the use of AFI's and shorted branches completely.
 
I used NOPs in the past in shorted branches. Until recent editions of RSLogix 5000 you could search for shorted branches. With a NOP in it, you could.
 

Similar Topics

Controller: 1756-L84E v.35 Prosoft MVI56E-MNETC for ModbusTCP/IP I'm having an issue with some of my write commands. The write command that...
Replies
0
Views
186
I have several Avery scale units and they are configured as Generic Ethernet modules, and I am actually reading the data fine for the weight...
Replies
2
Views
396
What's the best way to move a tag value from the panelview+7 to the clx plc. We display amps from a power meter on the panelview screen, read in...
Replies
1
Views
392
I'm running into an issue migrating a PLC-5 using the newer Logix Designer Export when opening a saved .ACD from RSLogix-5. It has multiple RIO...
Replies
2
Views
609
We have two sites that are stranded with no line of site, they are handled by phone/modem with a chain that includes: Stranded site (client)...
Replies
5
Views
892
Back
Top Bottom