![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
![]() |
#1 |
Lifetime Supporting Member
|
What is the point of the Rockwell CMP Instructions?
What is the point of the Rockwell CMP Instructions?
I would expect the power to lie in the ability to do nested conditions such as (TagA > TagB) XOR (TagC > TagD) but you can't do nested conditions as far as I can tell. You are only allowed to use one comparison operator. Can anyone fill me in on what this can do that a EQU, NEQ, GRT, LES Etc can't do?
__________________
SkyCad is by far the Best ECAD Schematic Software I have used. Fact my "Fun Facts" are never fun ![]() |
![]() |
![]() |
#2 |
Member
|
The power is in the more complex expression. But it still evaluates to one basic comparison.
(Tag1 * Tag2) + (Tag3 / Tag 4) > Tag5 The downside in part is that you don't see the current values or these tags, and you can't see the intermediate results, like what is Tag1 * Tag2? You can hover a cursor over each to see their current value but that gets tedious. Another benefit is reduced memory usage. The expression above would have taken four dedicated instructions as opposed to one CMP. The scan time would be roughly equivalent, but the logic memory usage would be reduced. That's my take. I've never really been a fan of the instruction. OG
__________________
I despise when people take random quotes and ascribe them to me - Julius Caesar |
![]() |
![]() |
#3 |
Member
|
There have been time I split a CPT into multiple CPT's just to see the intermediate result written to a temp tag.
|
![]() |
![]() |
#4 |
Lifetime Supporting Member
![]() ![]() Join Date: Sep 2014
Location: California
Posts: 192
|
My most common usage would be something like
ABS( SP - PV ) > AlarmSP pretty handy to do in one instruction. |
![]() |
![]() |
#5 |
Lifetime Supporting Member
![]() ![]() Join Date: Jun 2012
Location: Australia
Posts: 3,176
|
I use it occasionally for deviation, e.g. if you're trying to see if something is within a tolerance window.
PV > Setpoint + Tolerance PV < Setpoint - Tolerance Otherwise you have to create additional tags to determine the upper and lower bounds of your tolerance window. Sometimes this is handy, but sometimes it seems pointless to create two new tags and four instructions, when I can just throw a CMP at it and call it a day. |
![]() |
![]() |
#6 |
Member
![]() ![]() Join Date: Sep 2015
Location: KY
Posts: 389
|
In reality it’s in place to avoid a rather large rung of ladder for an equation that can be evaluated with one instruction.
Also don’t forget within a CMP order of operations really matter, regardless of what country and when you learned math. |
![]() |
![]() |
#7 |
Member
|
Or maths.
![]()
__________________
I despise when people take random quotes and ascribe them to me - Julius Caesar |
![]() |
![]() |
#8 |
Lifetime Supporting Member + Moderator
|
There will be a trade-off for the additional memory usage as the instructions CMP and CPT execute, for it to hold intermediate values during the computation of the expressions. More parentheses, more memory usage. However, this memory usage is reclaimed after each instruction completes.
Scan times for CMP and CPT are always longer than doing the equivalent math(s) in cascaded simple math(s) instructions. The reason being that the expressions are "parsed" before evaluation, to decide on the evalution order, even if there are no parentheses in the expressions. Breaking the expressions into simple comparison and math(s) instructions will dictate the order of evaluation.
__________________
___________________________ ![]() abtrain@tiscali.co.uk www.abtrain.co.uk tel: 07506 73 9999 Everything works with smoke. Let it out, and it stops working. Nil Carborundem Illegitimi |
![]() |
![]() |
#9 | |
Member
|
Quote:
I then created a whole new project where I used a CPT to perform those same four functions. Again, copy and paste to get 1024 rungs. The "short" method used 495k of RAM with a scan time of 80-90 microseconds. In both cases I am measuring the program scan time, not the task scan time. There is no other logic or tasks. Interestingly, the offline memory estimate for both was the same. The memory usage mentioned was online. Like you said, the factors, including the math that you perform, the data type used, and the complexity of the expression all make a difference. I suspect I could generate another example where the results are closer or even flipped. But I have long held the belief that the CPT saves memory, but not scan time. In fact, I believed there might be a slight scan time penalty that would just about even out as the expression got more complex. Again, totally unscientific. Just a workbench result. OG EDIT: Just did another example and the scan time results went the other way. However, memory usage was still nearly 1/2 using the compute.
__________________
I despise when people take random quotes and ascribe them to me - Julius Caesar Last edited by Operaghost; Yesterday at 02:35 PM. |
|
![]() |
![]() |
#10 | |
Lifetime Supporting Member + Moderator
|
This is from the "Help" on the CPT instruction ...
Quote:
__________________
___________________________ ![]() abtrain@tiscali.co.uk www.abtrain.co.uk tel: 07506 73 9999 Everything works with smoke. Let it out, and it stops working. Nil Carborundem Illegitimi |
|
![]() |
![]() |
#11 |
Lifetime Supporting Member + Moderator
|
I once worked on a brewery job where the boiling of the Wort is controlled by a liquor balance equation.
It was quite complex, so I entered it into a CPT instruction, the expression copy/pasted from the functional specification. The first Wort Boiling was a failure, and they immediately pointed the finger at the programmer, me. I showed them the rung in the code, and took a screen-shot of it, printed it and gave it to the brewer to compare against what was in the FS. Ten minutes later he returned to say the equation perfectly matched the FS, but then admitted the FS was wrong !
__________________
___________________________ ![]() abtrain@tiscali.co.uk www.abtrain.co.uk tel: 07506 73 9999 Everything works with smoke. Let it out, and it stops working. Nil Carborundem Illegitimi |
![]() |
![]() |
Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Multiple MSG instructions SLC5/05 TO SLC5/05 | glenncooper | LIVE PLC Questions And Answers | 7 | January 4th, 2017 08:59 AM |
Rockwell 1734-AENT Point IO module keeps faulting | Ninja Pirate | LIVE PLC Questions And Answers | 17 | July 12th, 2016 09:42 AM |
QuickPanel View DF1 driver error | rgraley1 | LIVE PLC Questions And Answers | 2 | October 7th, 2014 11:22 AM |
Io | neilot | LIVE PLC Questions And Answers | 6 | June 30th, 2014 06:22 PM |
Ti 555 I/o ? | bentleya | LIVE PLC Questions And Answers | 3 | March 17th, 2003 10:36 AM |