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.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


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

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old July 28th, 2017, 03:32 PM   #1
technolog
Lifetime Supporting Member
United States

technolog is offline
 
Join Date: May 2015
Location: Ohio
Posts: 129
Boolean values in CPT instructions in RSLogix 5000

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.
  Reply With Quote
Old July 28th, 2017, 03:47 PM   #2
Bit_Bucket_07
Member
United States

Bit_Bucket_07 is offline
 
Bit_Bucket_07's Avatar
 
Join Date: Feb 2013
Location: Southeast US
Posts: 1,403
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.
__________________
  Reply With Quote
Old July 28th, 2017, 04:11 PM   #3
mellis
Member
United States

mellis is offline
 
Join Date: Nov 2004
Location: Cincinnati, Ohio
Posts: 802
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.
  Reply With Quote
Old July 28th, 2017, 10:30 PM   #4
janner_10
Supporting Member
United Kingdom

janner_10 is offline
 
Join Date: Dec 2014
Location: Tewkesbury
Posts: 637
It makes more sense to put the Bool in a contact calling the CPT to execute it or not, well to me anyhow.
  Reply With Quote
Old July 28th, 2017, 10:45 PM   #5
Bit_Bucket_07
Member
United States

Bit_Bucket_07 is offline
 
Bit_Bucket_07's Avatar
 
Join Date: Feb 2013
Location: Southeast US
Posts: 1,403
Quote:
Originally Posted by janner_10 View Post
It makes more sense to put the Bool in a contact calling the CPT to execute it or not, well to me anyhow.
Sounds like an elegant solution, although it would probably also be necessary to execute a move of the analog input to the result register of the compute function.
__________________
  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
Import/Export Tag Values in RSLogix 5000 dabestbank LIVE PLC Questions And Answers 13 January 11th, 2017 05:27 PM
RSLogix Emulate 5000 Sakubh LIVE PLC Questions And Answers 3 March 6th, 2015 10:52 AM
Strange Situation in RSLogix 5000 Saulo35 LIVE PLC Questions And Answers 3 February 3rd, 2015 03:58 PM
RSLogix 500 one shot vs RSLogix 5000 one shot Prayder LIVE PLC Questions And Answers 5 December 29th, 2014 04:50 PM
RSLogix 5000 v20 cross reference instructions? BAJ LIVE PLC Questions And Answers 0 February 27th, 2013 09:32 AM


All times are GMT -5. The time now is 08:34 PM.


.