Sign in to follow this  
Followers 0
ct8356

How to link a symbol name with an integer and a boolean value?

2 posts in this topic

I can link a name with an integer by creating an entry in the symbol table, with name "name" and type "INT". I can do a similar thing for a name and a boolean value. But what if I want to link a single name with an integer AND a boolean value? For example, if I am naming a fault for my machine, I might call it "CircuitBreakerTripped". I want this to have an integer value "1", to show its position in my list of faults... and I want it to have a boolean value of "true or false", to show if the fault is true or false. How might I do this? Edited by ct8356

Share this post


Link to post
Share on other sites
Depending upon exactly what you are trying to do, there are a couple of ways to do this. You can create two different symbols to refer to the same address (they cannot be exactly the same name though): CircuitBreakerTrippedInteger = W10 (being an integer, it uses the whole 16 bit word) CircuitBreakerTrippedBit = W10.00 Then, use a move instruction to move a &0 or &1 into W10. W10.00 will naturally follow suit and be on or off. Or, if you are using a CJ2 PLC, you could create a structure called CircuitBreakerTripped. This structure (data type in CX-Programmer) could have 2 members (Bit (type BOOL) and Integer (type INT)). Then you would have to create a symbol that is of type CircuitBreakerTripped. Say that the Symbol name is CircuitBreakerTripped1, then you could use: CircuitBreakerTripped1.Integer for the integer function and CircuitBreakerTripped1.Bit for the bit function However, these would be two different memory locations and you would have to handle both in your code. For instance you would need to have a coil for CircuitBreakerTripped1.Bit and then MOV instructions to move a #0 into CircuitBreakerTripped1.Integer when the coil is off and a #1 when the coil is on. Hopefully one of these two suggestions will help. In either case, you cannot use the exact same name to reference both.
1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0