You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old January 13th, 2021, 10:49 AM   #1
theColonel26
Lifetime Supporting Member
United States

theColonel26 is offline
 
theColonel26's Avatar
 
Join Date: Feb 2014
Location: West Michigan
Posts: 518
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
  Reply With Quote
Old January 13th, 2021, 11:14 AM   #2
Operaghost
Member
United States

Operaghost is offline
 
Operaghost's Avatar
 
Join Date: Apr 2002
Location: Dallas, TX USA
Posts: 2,992
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
  Reply With Quote
Old January 13th, 2021, 11:34 AM   #3
I_Automation
Member
United States

I_Automation is offline
 
I_Automation's Avatar
 
Join Date: Jun 2020
Location: Detroit, Michigan USA
Posts: 409
Quote:
Originally Posted by Operaghost View Post
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.... OG
There have been time I split a CPT into multiple CPT's just to see the intermediate result written to a temp tag.
  Reply With Quote
Old January 13th, 2021, 03:29 PM   #4
Gomez_
Lifetime Supporting Member
United States

Gomez_ is offline
 
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.
  Reply With Quote
Old January 13th, 2021, 06:55 PM   #5
ASF
Lifetime Supporting Member
Australia

ASF is offline
 
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.
  Reply With Quote
Old January 13th, 2021, 08:16 PM   #6
_Dock_
Member
United States

_Dock_ is online now
 
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.
  Reply With Quote
Old Yesterday, 09:16 AM   #7
Operaghost
Member
United States

Operaghost is offline
 
Operaghost's Avatar
 
Join Date: Apr 2002
Location: Dallas, TX USA
Posts: 2,992
Quote:
Originally Posted by _Dock_ View Post
...regardless of what country and when you learned math.
Or maths.
__________________
I despise when people take random quotes and ascribe them to me - Julius Caesar
  Reply With Quote
Old Yesterday, 11:34 AM   #8
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 5,030
Quote:
Originally Posted by Operaghost View Post
Another benefit is reduced memory usage.
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.


Quote:
Originally Posted by Operaghost View Post
The scan time would be roughly equivalent.
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.
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
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



  Reply With Quote
Old Yesterday, 02:16 PM   #9
Operaghost
Member
United States

Operaghost is offline
 
Operaghost's Avatar
 
Join Date: Apr 2002
Location: Dallas, TX USA
Posts: 2,992
Quote:
Originally Posted by daba View Post
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.
So, I just did an unscientific test. I created a new project and added one line of code with four math instructions. ADD, MUL, DIV, ABS. Each using the result from the previous instruction. I then copied and pasted until I had 1024 identical rungs. This "long" method program scan time was approximately 240-280 microseconds and used 948k of RAM.

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.
  Reply With Quote
Old Yesterday, 02:29 PM   #10
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 5,030
This is from the "Help" on the CPT instruction ...

Quote:
Originally Posted by RockwellAutomation
Description

The CPT instruction performs the arithmetic operations you define in the expression. When enabled, the CPT instruction evaluates the expression and places the result in the Destination.
The execution of a CPT instruction is slightly slower and uses more memory than the execution of the other compute/math instructions. The advantage of the CPT instruction is that it allows you to enter complex expressions in one instruction.
Tip: There is no limit to the length of an expression.
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
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



  Reply With Quote
Old Yesterday, 02:35 PM   #11
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 5,030
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 !
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
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



  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
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


All times are GMT -5. The time now is 06:20 PM.


.