Red lion program ?

ceilingwalker

Lifetime Supporting Member
Join Date
Mar 2010
Location
Phoenix, AZ
Posts
1,589
Hello, I am trying to write a program within Crimson V3 that will perform a calculation then display the result. For example I have things line of code:
Tag1=tag2*3.13/tag3*tag4/72.5;
It compiles okay however, it "72.5" as my result. I have tried with parenthesis and without, with the same result. Any help would be great. Thank you
 
You didn't provide the values of Tag2, Tag3, or Tag4, but I assume you're expecting an answer other than 72.5? Are you saying that it produces 72.5 regardless of the tag values? Are your tags set up as integer or floating point (real)? Where do you have this line of code located--in a program or as an action somewhere? Are you sure the program (or action) is being executed?
 
You didn't provide the values of Tag2, Tag3, or Tag4, but I assume you're expecting an answer other than 72.5? Are you saying that it produces 72.5 regardless of the tag values? Are your tags set up as integer or floating point (real)? Where do you have this line of code located--in a program or as an action somewhere? Are you sure the program (or action) is being executed?

Those tags are variables that will be entered from the touch screen. They are all floating decimal points however, for the sake of keeping it simple, I made them integers, for now. I was able to get it to at least translate, without error however, I get a "0" for the tag that this equation is supposed to send its answer to.
 
I'm not a crimson expert but try with this using parenthesis and spaces:

Tag1=(tag2 * 3.13) / (tag3 * tag4) / 72.5

The parenthesis did work, however I had to place them around each tag or constant, to get it to translate without a syntax error. Thank you for the advice.
 
Those tags are variables that will be entered from the touch screen. They are all floating decimal points however, for the sake of keeping it simple, I made them integers, for now. I was able to get it to at least translate, without error however, I get a "0" for the tag that this equation is supposed to send its answer to.

The tags need to be floating point to work through the math properly...I suspect that is what you are doing, but plugging in whole numbers for ease of testing?

The result you are getting...a zero in the tag in Crimson or in some external device?
 
The tags need to be floating point to work through the math properly...I suspect that is what you are doing, but plugging in whole numbers for ease of testing?

The result you are getting...a zero in the tag in Crimson or in some external device?

The problem was I am using floating decimal point and I had it set to integer in my Crimson program. Works wonders when the data types match. Can't believe I missed this! Thanks for your reply.
 

Similar Topics

Hi All, As a precaution my company has been collecting copies all the HMI and PLC programs. I have recorded copies of most of our sites...
Replies
0
Views
91
I have to admit that I see no reason for protecting automation programs so customers can not access the application file, apart from extortion...
Replies
1
Views
1,695
Hi Everyone, Got a new project where I am going to read the level of a tank via Modbus and I need to use the tank strapping chart to convert it to...
Replies
8
Views
2,557
Hey, I have a SN 6000 setup and I was wondering how to / if I can connect to a controllogix PLC using a 1756-EN2T card. I have attempted to set...
Replies
1
Views
1,457
Hi I have a small script I wrote in "Programs" that I want to call when a buttom is pressed on the HMI. How do I call this program from a button...
Replies
6
Views
2,104
Back
Top Bottom