Difference between 2 numbers using CPT

rta53

Lifetime Supporting Member
Join Date
Feb 2003
Location
North Carolina
Posts
619
I have a need to calculate the difference between two values in percent. I tried Google and found a formula that does exactly that. I attempted to put that into a CPT instruction in Studio 5000. You can use an absolute value in this instruction which I did. When I run the program and the difference is anything other than 0 all I get is 50. Anyone tried to do this or have a better way? Images are attached.

Difference.jpg Difference CPT.jpg
 
One thing I see is I think you need another set of parentheses, before ABS and after /2. Right now you're dividing like this:

30/4/2=3.75

and you want
30/(4/2)=15

Aside from that it looks right to me.
 
It hard to troubleshoot your problem when the example you posted doesn't match your description of the problem. In your post you said you always get 50 or 0, but in your example you got 1.$. You got because you were dividing by zero. Post an example showing you getting 50 when you think the answer shouldn't be 50.
 
Thanks for the suggestions. I believe I have it working now. With this equation I get a good number if both tags are other than zero. If one is zero the result is 200. If both are zero then I get 1$ as proof said.

Difference2.jpg
 

Similar Topics

Hello, I have a problem with AO- and AA-Tags. When I use for example the tag AO_Test with the address 200 and type the value 1,2 in, the AA-Tag...
Replies
7
Views
1,407
As per the title. This might seem like a basic question to many, but I'm unclear about the difference between a coil ( ) and an application...
Replies
28
Views
4,015
Good Morning , I have 2 Frequency Drive panels to build and commission . It is for 2 pump systems . Just wondering , what is the...
Replies
4
Views
1,963
Hi Experts, Good day! What are the differences between PCS7 SIMATIC Batch and PM Control? Do you have any manual like "Getting Started "...
Replies
0
Views
807
I have a Automation Direct Click Plus that you can buy option CPU slot modules for input/outputs. The slot modules have the options of sinking...
Replies
9
Views
2,810
Back
Top Bottom