CPT Instruction problems

Coles

Member
Join Date
Sep 2009
Location
HVGB
Posts
9
Having problems with this simple equation in Logic5000. Trying to convert 4-20mA input to its eng. equivalent. I am using 1769-IF8 input module with a L35E processor. The scaling is set to be 4mA=4000 and 20mA=20000. This is what I have been trying to write....

Let X equal real Analog input, lets assume 12000 for ease of calculation.

Let URV (Upper Range Value of process) equal 2700 ft^3


((X-4000)/16000)*URV

Result in the destination should be

((12000-4000)/16000)*2700=1350

1350 should now be shifted in the dest. tag, but it do not change, it remains at zero

If I simplify my equation by removing the -4000 it works. How should I enter the equation?
 
When I type the equation that you provided into a CPT statement on my L35, I get 1350...

Could it be an issue where X is an integer, the CPT statement assumes that everything else needs to be an integer and the decimal values (8000/16000 = 0.5) are lost? Try entering everything with a .0 after it so it knows to use floating point math instead of integer math...

((X-4000.0)/16000.0)*URV

Where X = INT or DINT and URV is Real/Floating Point.
 
CowDung just beat me to it but, I'll post anyway.

What is the data type of the destination tag. If it is not real, the data may be getting truncated mid computation.

I think this is what might be happening if we take it step by step:

1. 12000 - 4000 = 8000
2. 8000 / 16000 = 0.5 => actually gets truncated to 0.
3. 0 * 2700 = 0.


Try changing destination tag type to real or rearrange equation like this:
((12000-4000)*2700/16000)=1350

1. 12000 - 4000 = 8000
2. 8000 * 2700 = 21600000
3. 21600000 / 16000 = 1350

Be careful not to exceed 2,147,483,647 at any point in the computation.
 
This is the form I use:

(RawData-RawMin)*(EUMax-EUMin)/(RawMax-RawMin)+EUMin

It handles odd ranges like -50 to 150 DegC.

In your example that matches up to:
(X-4000)*(2700-0)/(20000-4000)+0

I think Cowdung nailed it. My money is on integer conversion.
 
Last edited:
I think gmferg is correct--the problem is probably the data type of the destination. If it is a DINT or INT, you get 0. If it is Floating Point, you get 1350.
 
gmferg and cowdung are right on.

I ran into this exact datatype/syntax issue with CPT yesterday, where I was scaling the output reference to a PowerFlex.
 

Similar Topics

I have ran into something I have not seen before and wondering if any one had any ideas. The logic I'm currently troubleshooting is using a...
Replies
3
Views
1,634
Needing help with this, keep getting an error...
Replies
16
Views
4,901
What is the symbol for divide used in a CPT Instruction Expressions - The expression is zero or more lines, with up to 28 characters per line, up...
Replies
11
Views
3,554
Hey Everyone I was wanting to get some advise on the math below on this expression for a SCP instruction...
Replies
17
Views
5,199
I am trying to add 15 items together using a cpt instruction in logix5000. All of the items are in the same array is there a way i can type in the...
Replies
4
Views
2,217
Back
Top Bottom