Comparing / copying data values

Brandon_K

Member
Join Date
Mar 2016
Location
Pittsburgh, PA
Posts
150
Hey guys. I have a situation where I need to compare a dynamic data value to a static value, then take the greater of the two and use that in my program.

I have some math which creates DATA_SCORE, which is then repacked into a string (DATA_SCORE_LCD) that is displayed on the PLC and HMI.

What I need to do is compare DATA_SCORE against "90". If the value is greater than 90, then I want to repack DATA_SCORE into DATA_SCORE_LCD string. If it's less than or equal to 90, then I want 90 packed into DATA_SCORE_LCD. So basically, at no point will the LCD/HMI ever display lower than 90.

I've played with the Compare Values instruction, but it doesn't look like I can copy the data from DATA_SCORE into a new memory location, it would only set a bit.

I'm using a Productivity2k.
 
I'm not familiar with the AutomationDirect Productivity 2000 environment, but if it's similar to every other PLC I've seen then you should be able to do the compare as you mentioned and then use the true/false outcome of that compare to enable a Move or Copy instruction which can then copy the data to memory. Do you have a URL for the AutomationDirect ladder logic manual or online help?
 
Joel has it right. CPD the value into a new tag. Then compare that tag < 90. If true, CPD 90 to the new tag. Next, put the new tag in the OLED instruction.
 
Last edited:
I'm not familiar with the AutomationDirect Productivity 2000 environment, but if it's similar to every other PLC I've seen then you should be able to do the compare as you mentioned and then use the true/false outcome of that compare to enable a Move or Copy instruction which can then copy the data to memory. Do you have a URL for the AutomationDirect ladder logic manual or online help?

Unfortunately I've never come across a full list of instructions anywhere online. The online manual (http://www.automationdirect.com/static/manuals/p2userm/p2userm.html) is the same as the printed manual. For a ladder newbie like myself, a list of instructions with some sort of definition or example of what they do would come in tremendously helpful. Their tech support is fantastic, but I'm an autodidact and much prefer learning on my own through reading and hands on.


Joel has it right. CPD the value into a new tag. Then compare that tag < 90. If true, CPD 90 to the new tag. Next, put the new tag in the OLED instruction.

Thanks for the info gents. I'll give it a shot tomorrow. I was assuming that there was an instruction that could do it all in one.

Just to make sure I'm on the right path, I would compare my dynamic value against 90. If equal to or greater than 90, I would have that turn on a switch on another rung to perform a copy data function to my final data location. If it's less than 90, I would have that turn on a switch on a third run to copy 90 to my final data location?
 
The Help within PSuite is pretty decent. Open an instruction and click the HELP button on the lower right to jump to the part of the help file related to that instruction.

To answer you last paragraph: Yes, except for the turn on a switch part. Not sure what you meant by that. Here is what I meant (I stuffed dummy text in lines 1, 2, and 4).

EDIT: I started with one of my own programs and did not change the source of the LCD instruction to match the "DATA_SCORE_LCDx" tags, but you get the idea. I was calling it "OLED" doh...I am pretty new with this software too, and I used a structure called "OLED" in my first few programs...it is LCD instruction like you said earlier...

OLED.png
 
Last edited:
You can use the LIM instruction. Put your dynamic value as the input, and you can use constants or tags for the limits. No need to enter any tags for the alarms. Then enter a tag for the output.

If the input exceeds the high limit, the output is clamped to the high limit value, if it drops below the low limit, it is clamped to the low limit value.
 
The Help within PSuite is pretty decent. Open an instruction and click the HELP button on the lower right to jump to the part of the help file related to that instruction.

This is what I love / hate about PLC's, a dozen different ways to perform the same function.

I've attached a screenshot of how I built my code last night. I added the LIM instruction this morning after rdast's reply. (I realize I can't run both at the same time).

The switches that I was talking about in my previous post are shown in the screenshot. I've never used the greater than / less than functions and quite honestly, didn't realize that you could do them that way.

With that said, is there any reason to choose one of these ways over the other? rdrast's suggestion would appear to be overall the most efficient.

Your suggestion vs the way I did it I would assume to be a wash as they both ultimately still use 3 lines of code.

Screenshot 2016-05-03 12.21.44.jpg
 
It would appear that I've misunderstood how the compare values instruction works.

It doesn't work the way I had it coded originally and I'm unsure why. If I flip the input 1 and input 2 values, it works, but in reverse.

I've swapped out my instruction with rdrast's suggestion of the LIM instruction. I used 90 as the low value and 200 as the high value and this tested perfectly. At no point does the display ever show a value higher than 200 or lower than 90.
 

Similar Topics

I’m running a micro 820 to measure a tank level, then turning on equipment at certain levels. I have an analog input (4-20) that I’m storing and...
Replies
10
Views
272
How do you go about implementing, on the M580 PLC, how many days, hours, minutes before a predefine event in the future? The RRTC_DT yields the...
Replies
3
Views
1,805
This is a Citect SCADA question I have Six variables of type REAL (Float) to compare and determine (identify) which variable has the highest...
Replies
4
Views
1,407
I have currently made a logic to read Serial input from a barcode scanner. The situation is that I need to read the barcode from the machine and...
Replies
5
Views
2,036
Hello, We are using Schneider SCADAPack 357 and Trimble Acutime 2000GPS. We are getting the data as a string(ASCII) from...
Replies
3
Views
1,471
Back
Top Bottom