PLC5 Bulk Comparisons... FSC??

tom_stalcup

Lifetime Supporting Member
Join Date
Jan 2004
Location
fresno
Posts
461
I was looking for a method to compare twelve values (say N35:35-N35:46) against a specified value(say, 5). Instead of just daisy chaining twelve comparison statements, I was thinking about using the FSC command(file search/compare). In the manual, it says that when searching, and the parameters of the search are met, in order to start searching again you need to turn off the .IN bit. Does anyone have a preset structure they use for this type of command? I don't see any examples in the manual or the help files, and thought I would pick your brains before I started experimenting.

I'm using this to verify the the timer presets of twelve different timers are withing the range I'm going to set, before allowing the operators to adjust the values outside of the allowable ranges.
 
Yes, you have to reset the .IN bit. You also have to reset the .FD bit. Each time the instruction finds a match, it stops, file position indicated by the R?:?.POS value. If the IN bit is true, you can then add the value of POS to 35, and use that as an indirect address to move the correct value from the N35:35-N35:47 range to the proper timer. By putting an unconditional unlatch on the .IN bit and the .FD bit with the MOV isntruction, you can proceed with the next check on the next scan. You will have to have some logic however to detect when the comparrison failed, because the FSC instruction will just skip to the next element in the file. Without that logic you will not get an alarm that one of the timer presets was out of range. You could use a DTR instruction in conjunction with a XIO FD to detect that a match failed, but if two or more in a row fail that will complicate determining which parameter is out of range for alarming. If you operate the instruction in numerical mode and use a combination of the .FD and DN bits to detect if a match was not found, then you have to account for the one scan delay on the DN bit.


If you have a PLC-5 enhanced series C processor you can also program the check as a FOR NEXT loop in either LL or ST language using indirect addressing. It might be simpler for picking out which one of the integers is out of range for a timer preset. In ST you can do the test and move the value to the timer preset in a single pass, and set an alarm if it fails with an IF-THEN-ELSE statement. The beauty of a For-Next loop is you can start the index at 35 to 47 (For N7:0 :- 35 to 47 Do) and thus skip the step of adding the index to 35 to get an indirect address.

See the attached PDF file for an example of how to do this with a For-Next in Ladder on the PLC-5 - The PLC 5 does this operations very smoothly as it has a FOR/NXT instruction pair - nowhere nearly as clumsy as the SLC-500 is.

In this example, the loop counts using N7:0 from 35 to 47, and check the range of the value. It it is OK it moves it immediately to the timer .PRE (I entered .ACC when I entered the program, it should be .PRE, sorry, I was in a hurry). If it is not OK, then it sets an alarm bit that can be used to identify exactly which value was out of range.
 
Last edited:
Excellent... Thanks for the help Alaric. I took a good look and everything, and I think I have a good grasp on the commands needed.
However, in the interest of the other mechanics following the code, I finally decided to go with the twelve comparison statements in a row method however.... As much as I like playing with new commands and ways of doing things, for this particular application it's a little overkill. I don't actually need to know with value is out of spec, because this is for a group "increment/decrement" setup from the panelview. I just need to make sure that when they try to raise all the values at once, it won't do all of them if it will put one value out of spec.... Timer values don't seem to like negative values for some reason. šŸ™ƒ

I'll definitely keep both of these methods in my (constantly) expanding toolbox for future projects.
 
I use FSC's all the time on PLC5's; usually to automate a BTW to a module. An example might be for manually tuning a temperature control module; it is expensive (in terms of communications channels and time) to constantly write the gains block to the module, especially as it is normally only loaded on powerup.

I copy the gains block (56 words or so) from the actual BTW area to a backup area, and then do an FSC every second or so to compare the two. If all the values are equal, nothing needs to be done, but if one changes, it triggers a BTW of the new values, and copies them over to the backup area.

I use the same technique for anything that might need to be dynamically changed once in a while (like analog scaling values, or counter module setup's, etc).
 

Similar Topics

I am using the following formula and I am getting error, Invalid Expression - too many closing parenthesis. when i copy the formula to notepad or...
Replies
4
Views
152
Preface: Kinda long, so I made section titles Intro: I just want to see if anyone here has seen anything similar. A PLC5-40 series C enhanced...
Replies
3
Views
365
Hi, can anyone help me get a pdf file for this RSP files. They are from a PLC5. Thanks
Replies
5
Views
517
Hello all, I am seeing this behaviour where an integer file (N46:33), has an integer in binary (11110) which is 30 in decimal. I did a...
Replies
7
Views
516
Back
Top Bottom