Defining 'TRUE' and 'FALSE' in Studio 5000

buchnich

Member
Join Date
Sep 2020
Location
Minnesota
Posts
7
Hi Everyone,

I have a somewhat silly question. I've primarily programmed with Beckhoff PLCs in the past. In those, we can assign the string TRUE or FALSE to their literal values of 1 and 0. It is nice because it makes it clear when assigning the Boolean value to a variable, that the variable is in fact a Boolean type.

However, I can't seem to find a way to assign this in Studio 5000. Is there a way to do this?

As an example, this is how I'd like to do assignments to Boolean variables:

bTestVar := TRUE;

Instead, this is how I'm currently having to do it in Studio5000:

bTestVar := 1;

Thanks everyone!
 
Create a tag called TRUE and one called FALSE (BOOL data type). You can either set TRUE to 1 in the tag data base, or put it on a rung in the main routine as an unconditional OTE, so that it's value you cannot be changed. You could also put an unconditional OTU of your FALSE tag to make sure that it is always 0.
 
Last edited:
Do you actually need TRUE and FALSE assignments ?


I'm not up to speed on STL, but in C++ a statement like ...

If (bTestVar) ....

Will evaluate as TRUE if bTestVar is non-zer0, and FALSE if it is zero.

In other words, you don't need to do the comparison ...

If (bTestVar == TRUE) ....

Does STL compile the same way ?
 
I have the same question. What is the need?


It's a style query; it's a want not a need:


[...] we can assign the string TRUE or FALSE to their literal values of 1 and 0. It is nice because it makes it clear when assigning the Boolean value to a variable, that the variable is in fact a Boolean type. [...]

As an example, this is how I'd like to do assignments to Boolean variables:

bTestVar := TRUE;
[...]
I think @dmroeder provdided the answer, but unless the OP replies we will never know. E.g. the equivalent of summat like this:


Code:
VAR_GLOBAL
  TRUE : BOOL := 1;
  FALSE : BOOL := 0;
...
END_VAR
but using dialogs/menus, as I think there is no explicit VAR/END_VAR block in RSLogix
 
Last edited:
In Controller Scoped Tags, create the new tags.
Create FALSE as a constant.
Create TRUE, but don't tick the constant box... first go in and change its value.. then edit the tag and tick the constant box.
ALWAYS_ON and ALWAYS_OFF are common names people give these tags.
 
In LADDER, I adopted the following philosophy....

As a senior systems engineer, in charge of any number of programmers, I banned the use of AFI instructions, and banned the use of unconditional branches to override a bit or other instruction.

Each programmer had his own "Always_On" bit, for instance mine would have been AON_DB (Always ON, plus my initials).

This made it easy to "mark" my work, anytime I wanted to, and it enabled the programmers to do the same, with no conflicts.

You could cross-reference your marker bit, and immediately see where you had "bookmarked" for future work.

If anyone needed an "Always_OFF" bit, they would use XIO AON_xx, meaning you only had one bit to cross-reference instead of two.
 
Daba, an enhanced version of that would be a UDT with various datatypes(Bool, Float, Dint, TMR, CNT, etc.) for testing and a naming standard Test_ProgrammerName

To find any test tags search Test_
 
With a nod to RonB, one could perhaps posit that the proper names for the always "on" and "off" bits would be ONE and ZERO, because, while rungs can be true or false, bits can only be 0 or 1.


But then, in ST, why would someone assign ONE or ZERO, when 1 or 0 would work just as well?


Then again, in ST the "bit" is declared a BOOL, so maybe TRUE/FALSE is reasonable.


jes' sayin'
 

Similar Topics

Non-PLC guys asking me to explain all the interlocks of my system in a document. Problem is for this system its a little complicated (OR...
Replies
16
Views
5,407
Hello all. I am working on a project where there are 7 vents which have a cooling function with a S7-1200 station and a KTP Basic panel (1st.gen)...
Replies
6
Views
2,560
Hi guys, I asked this question on the Codesys website and didn't have much success with it. I'm looking at a way of defining arrays for real...
Replies
8
Views
5,479
hi to everyone, we are using ISaGRAF for programming our PLC. The problem is that we want to change the IO boards of the computer that we use...
Replies
0
Views
1,876
Hi I'm trying to define a string array using Citects SCADA package and I've got an error that I can't shift. I've defined a variable of the...
Replies
10
Views
13,078
Back
Top Bottom