Comparison instruction?

daneoholic

Member
Join Date
Aug 2002
Posts
5
I have a program that records a position value from an encoder and stores it in an integer file each time the operator moves the machine to a new position and presses a button. Starting with N7:0
After there are > 100 stored positions stored the operator puts the machine in Auto and it's programed to move to N7:0 and perform its function. When it's finished it indexes to N7:1 and so on.
If you cycle the auto switch then the machine moves back to N7:0 to start again.
I'm trying to figure a way, when auto is cycled to compare the present position (of the machine) with the values in N7 and move to the next largest one from its present position.
Any suggestions on how to approach this would be appreciated
Thanks
Phil
 
You could

develop some 'cycle in progress' value and use that in the AUTO button logic. If cycle_in_progress = true, don't reset.
 
If "Auto" = 1 AND "Present Position" Not Equal "N7:0" AND "Present Position" is DONE , then One-Shot Add 1 to "Present Position", then [continue the program].

It always helps to state the brand and model of PLC, and the name and version of the programming software. Based on the addresses, I would guess it is RSLogix 500 software for a SLC controller.
 
Last edited:
Good call Lancie as I was thinking the same thing. You forgot your ENDIF though. Hehehhee,,, just messin' with ya. :)
 
Thanks Lancie1
So I would be using an indexed address to "cycle" through the integer file?
I've been trying to figure this out using the FIFO, FFL and FFU but aren't quite there yet.
 
It always helps to state the brand and model of PLC, and the name and version of the programming software.
This will dictate the type of instructions available. For instance the PLC-5 has more extensive file search capabilities. In the SLCs there's a lot more 'roll your own' to be done.
 
Starting with N7:0
After there are > 100 stored positions stored the operator puts the machine in Auto and it's programed to move to N7:0 and perform its function. When it's finished it indexes to N7:1 and so on.
If you cycle the auto switch then the machine moves back to N7:0 to start again.
I'm trying to figure a way, when auto is cycled to compare the present position (of the machine) with the values in N7 and move to the next largest one from its present position.

Any suggestions on how to approach this would be appreciated
Thanks
Phil

I'm confused (easily enough done). Is the sequence to be N7:0 through N7:99 sequentially? Or, is the sequence from lowest value in N7:x to highest? I'm taking it that the AUTO switch resetting to zero is not a good thing?
 
Yes the sequence is to be N7:0 through N7:99 sequentially.
Currently, when the machine is initially put into auto I have the machine move back toward N7:0 position and use a LEQ to stop it at the first position. As long as the auto switch isn't cycled it completes its task at each location until N7:99 then shuts down. (The values in the N7: file do increase as the word address increases because they are loaded from an ever increasing encoder value.
The problem is: if the auto switch is turned off then back on (cycled) the machine moves back to N7:0 as it did when initially put into auto.
I need it to move to the next higher value in the integer file from its current position i.e. HSC.acc.
I been trying FFL, FFU, SQU, today and haven't been able to get it yet.
Thanks for the response!
 
I been trying FFL, FFU, SQU, today and haven't been able to get it yet.
Because your machine is already set up to use a step number, then you don't need to add to the problems by adding a FIFO.

All you need to do is to study the program to find out how it increments the value of the N7 sequence number. Somewhere in your program at the end of each step, there should be a ADD instruction that says Add 1 to N7:xx and store it in N7:yy (Assuming N7:yy is the address of the current Step Number). If not, look for some other method of incrementing the Step Number, such as Indirect Addressing in a loop, or a For-Next loop.

(The values in the N7: file do increase as the word address increases because they are loaded from an ever increasing encoder value.)
That sounds like it might be using the encoder to generate an indirect address for N7:[xx], where xx is furnished by the encoder. It could be N7:[xx + yy], where the yy comes from the encoder, and the xx is simply the next sequential address in N7.

The action of returning to N7:0 was programmed to allow the machine to start at Step 1. Now you want to change that action so that the last Step Number is always saved in a temporary memory location (some N7 location that is unused, maybe N7:255 but check to make sure that is not used and is not an existing Step Number). With the current last Step Number saved during each Step AND when the last step completes, set N7:255 back to 0, then when the machine restarts, have it check the value of N7:255. If it is 0, then do a normal start at Step 0. If it is not 0 (meaning that there was an interruption and restart), then have it start at the value of N7:255 + 1. After that, proceed normally.

It is probably about time for you to ZIP your RSLogix 500 program (or the part of it that includes the incrementing of the N7 file) and post it so we can help you with it. Another way is to print the program to a PDF file, then post that.
 
Last edited:

Similar Topics

Hi guys! Can someone post how to use this function? Really having difficulties to use it. thanks. Regards, Brooks
Replies
4
Views
3,615
Hello everyone, I am working on a plc simulation program and I put four GEQ comparison instruction in series on a rung to unlatch a bit and it...
Replies
25
Views
3,623
In my SLC 504 programs, I have used the FBC instruction to scan a word for a bit that has been set. This instruction is not supported in the...
Replies
2
Views
4,211
Per title - what's the worst and best wire duct brands you have worked with, and why? They all look the same on the outside, but there are...
Replies
13
Views
2,391
I have installed a Cognex barcode scanner on a machine. I have a 1769-L18ER CompactLogix processor. I have communication setup and working. I...
Replies
26
Views
4,545
Back
Top Bottom