Boolean values in CPT instructions in RSLogix 5000

technolog

Lifetime Supporting Member
Join Date
May 2015
Location
Ohio
Posts
315
This should be a simple one.

I'm trying to use a boolean value in a CPT instruction to either add a value or not. This is the statement:

Local:7:I.Ch0Data + (RETARD_FOIL * HMI_FOIL_GAIN * ERROR_ABS)

Where Local:7:I.Ch0Data is an INT, RETARD_FOIL is the BOOL in question and HMI_FOIL_GAIN & ERROR_ABS are REALs.

When I try to compile it, I get an 'invalid expression or tag' error. When I replace the BOOL with a 1, the expression is accepted.

Why isn't the BOOL being evaluated as a 1 or 0? How can I get it to add HMI_FOIL_GAIN * ERROR_ABS if the BOOL is true but not if it's false, using a CPT instruction. I know I can do it other ways but I'd like to know what I'm doing wrong in the CPT.
 
Sounds like the CPT instruction won't support Boolean operators. Can't say that I've ever tried to do that in a Compute function, although I certainly have done it successfully in various HMI scripts over the years.
 
Why?
Because Rockwell does not allow BOOL data type in CPT.

You're not doing anything wrong, you're just trying to do something Rockwell doesn't allow.
 
Hey All. Firing up this thread 8 years later in case anyone out there knows something previous contributors did not.

I am trying to use CPT to do the exact same thing. I am not able to do it.

Anyone know how?

I understand i can complete the task other ways by using more rungs and some MOV instructions. But i would prefer to use BOOL tag value if i can
 
Certainly doesn't accept it in ST either. I suppose it's a shortcoming from the fact that types are loosely enforced and the developers didn't consider that someone would like to do it this way.

Should be fixed by V50... though by then, the CPT instruction will be removed. LOL /s
 
Sounds about right. Thank you.

Maybe when the next newbie livens up this post again in another 8 years RA might have included this function. But as @cardo... inferred, i should not hold my breath
 

Similar Topics

Hi all, I have the following problem: from a long list of boolean values (about 100) I should program each possible combination with the...
Replies
6
Views
3,073
Hi. I haven't touched an Allen Bradley PLC for more than 10 years and I'm kind of rusty. I want to do something really simple in a FBD section...
Replies
5
Views
803
All, i nto fully get it. I read trough some froums but not finaly make it running. so I try to ask. Hopefully anybody has the kindness to answers...
Replies
7
Views
1,168
Example: Take this boolean algebraic expression: note: I'm using a single quote to denote negation as I can't place a bar over the letter. (CA +...
Replies
9
Views
2,827
I was just curious if there is a way to search for a description of a boolean contained within a DINT/INT. For instance, I have a DINT[1] named...
Replies
6
Views
2,246
Back
Top Bottom