Can a variable created with one of these data types be referenced at the bit level?
If so, what would be the syntax to use?
Objective is to create a virtual I/O point (coil) that will be used in my strategy, which PacDisplay will in turn also recognize it as a Boolean point and not as its int32 parent tag.
From what I read from your â[B][U]Testing for True[/U][/B]â post is that you are testing the entire âint32â variable value to see if it is âTrueâ or false instead of checking an individual bit in that double word.
What I want is to simply set or clear an individual bit (bits 0-31) in that int32 variable.
i.e. Want to [B]Set[/B] int32(bit 5) or (bit 7) or (bit 11) etc., etc.
In the PLC world (in its simplest form) I can do;
--[ Some Input On ]----------------------------(My Variable.Bit2) - Done. Simple and clean!
In OPTO world, am I going to have to do something like;
int32_test [B][OR][/B] 2^Bit //pseudo code example
Or, similar using OPTO script every time I want to set or clear a bit in one of my local variables?
Can this be done without using OPTO script? This could get really cumbersome and frustrating if I am dealing with or, want to/have to deal with lots of Boolean variables. Example shown was for just setting one bit. Checking for true and comparisons with other variables will need to be done as well.
Is there a simpler way?
Just out of curiosity, why is âBooleanâ Data type not available in PacControl ?
Sounds like you need âbit setâ and âbit clearâ commands.
You will find them on page 278 and 292 in doc 1701, the pac control command reference.
PACâs are a little more liberating than their younger siblings PLCâs.
I once worked with a programmer that came from PLC land, and he was a big bit set/bit clear guy.
He would use the same int32 variable all over the place, and use different bits in different parts of the program.
Rightly he claimed that it was more efficient, however in a PAC, we have lots of memory and not need to get down to flipping bits just to save a few bytes.
When time came to debug and commission the system I lost track of the number of times he shot himself in the foot by losing track of which part of the program (strategy) set which bits.
Slowly but surely he came to see that it really was a lot simpler and far more efficient to just use an appropriately named int for true and false.
It makes the program easier to read and debug when your under pressure and it sure makes things a lot easier for someone else to come along at a latter time and work on the system.
Just my real world 2cents worth.
The nice thing about programming is that its art and not science. Thus there is no right and wrong, its what ever works for you.
PACâs are a little more liberating than their younger siblings PLCâs.
I guess this one is debatable. PLCâs have come a long way.
In a PAC, we have lots of memory and not need to get down to flipping bits just to save a few bytes.
Well this one I guess depends on how you use it.
I can use one Int32 (2-bytes) to toggle 32 outputs (for example when in manual mode) or, buffer 32 input bits. In a PAC, the same would take 64-Bytes to do the same. So there is a big difference.
The nice thing about programming is that its art and not science. Thus there is no right and wrong, its what ever works for you.
Agreed,
And thanks for pointing out âpage 278 and 292 in doc 1701â not sure how I missed it. Been thru over 1500 pages of documentation in the last few days.
We have a lota lota lota customers that have written some pretty big strategies and never come up against any issues of 64 bytes vs 2 bytes. PACâs have megabytes of memory, so they can write their strategies the way they want.
At the end of the day, they get the job done, and thatâs the important thing.
No worries about the bit set and clear, I always keep at hand a printed copy of form 1703, the pac control commands quick reference.
The commands are grouped by type, so its easy to narrow down what is there, and then you can dig deeper for any command after that in form 1701.
Hi All, I can see the thread that Mary linked to is no longer valid⌠are there any recent threads related to this? Iâm trying to get a Groov View button to trigger a chart in PAC Control, but Iâm having issues with checking if the bit/variable is true or false.
I have tried Variable True? and Bit On? Logical functions but none seem to be working. Iâve just got the int32 variable linked to a button in Groov View, which I can confirm is being written true as Iâm viewing the state of said variable via an LED on the same page. I just canât seem to get this state change in PAC Control. Mind you, I specified the Bit on Groov View to be Bit 1.
The Variable True command should work - can you post the code/logic or screenshot of what you are trying?
FYI, by setting bit 1 - the value of the integer will be 2. Setting bit 0 will set the integer value to 1. I think you can leave the bit field empty in groov view and it will set all bits to 1 (value -1). It shouldnât matter if using the âVariable Trueâ command as any non-zero value would return true (value <> 0).