first time using cpt instruction

irondesk40

Member
Join Date
Jan 2008
Location
nc
Posts
630
trying to use a cpt instruction to enter the following

(n7:0/9000)*100

how do you enter the divide symbol?
that appears to be what I am doing wrong
 
Watch for roundoff error if you are storing that result in an N file. If you are and the range of N7:0 allows it, you are better off doing N7:0 * 100 | 9000.
 
Also, if you are saving the result to a floating point register then enter your constants as floats. N7:0|9000.0*100.0.

It looks like you are performing a percentage calculation, so if you must use integer math and N7:0 < 9000 then N7:0 | 9000 will be less than 1 - which will round to just 0 or 1 with integer math, giving you only 100 or 0 as your answer (This is what Robert was refering to). In this case you should re-arrange the equation to multiply by 100 first, then divide by 9000, or enter the constants as floats (ie 9000.0 and 100.0) even if you are storing the result in an integer.

Last, a word about constants and the CPT instruction. The CPT instruction takes longer to execute than single operation math instructions, but it is faster for longer computations because it doesn't have to take time to store and fetch intermediate results from memory. Where you are using constants, combining the two constants and using a single MUL or DIV instruction will be more efficient, ie N7:0 * 1.11111111e-2, or N7:0 | 90
 
Last edited:
thanks alot

never used the cpt instruction before, most of the things that i have done, i have been able to use the scp instruction.

I searched a slc500 instruction manual that I have as a pdf file, and was unable to find in it how to put the proper symbols in.

This site is great
 
irondesk40 said:
thanks alot

never used the cpt instruction before, most of the things that i have done, i have been able to use the scp instruction.

I searched a slc500 instruction manual that I have as a pdf file, and was unable to find in it how to put the proper symbols in.

This site is great

Don't know about the PDF, but it is in RSLogix500 CPT help:

Expressions - The expression is zero or more lines, with up to 28 characters per line, up to 255 characters. Instructions that can be used in the Expression include: +, -, *, l (DIV), SQR, - (NEG), NOT, XOR, OR, AND, TOD, FRD, LN, TAN, ABS, DEG, RAD, SIN, COS, ATN, ASN, ACS, LOG, and ** (XPY). The execution of a CPT instruction is longer than a single arithmetic operation and uses more instruction words.
 

Similar Topics

Hello, Trying to understand the MOD in Logix 5000 when used in a CPT block. I'm familiar with MOD or modulo as a ratio or division...
Replies
6
Views
3,549
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...
Replies
5
Views
2,839
Hello all L30ER, rs 5000 MINI Using a laser as redundancy for encoder for linear motion. Placement is critical. Please look over this CPT...
Replies
10
Views
3,332
I have 4 outputs which cycle off-back on, one at a time if more than 1 output shuts off I need to set an alarm I`m wanting to use the compute...
Replies
3
Views
1,888
I want to average a phorsphorus reading (F8:20) over an hour (4 samples/hr). Ranged 0.03 to 3.0 mg/l. I may want to increase it to 4 or an 8 hr...
Replies
15
Views
5,596
Back
Top Bottom