Hi,
is there any way to read bit status from 32-bit controller variable. I have OPC server where I have 32-bit variable, and I tried to make bit array (for tag datatype), but it was followed by error while creating a tag ("Array in not supported for this controller). I would want to show single bits status on the screen.
Thanks in advance!
Reading bits from 32-bit variable
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Reading bits from 32-bit variable
The OPC iX Controller copies the entire register that the tag is associated with. You can only associate a OPC register with a single tag. Which means that you would associate a UINT 32 iX tag with a register on your OPC server. You would handle parsing the bits on the iX Developer side.
You could use the tag's ValueChange event to parse the bits and assign them to 32 other tags. iX Developer does not allow you to use arrays anywhere but in the Chart object and in Script. Therefore if you want to display a bit's value it has to be in a tag, or you have to use an expression to parse the value and return just the single bit.
You could use the tag's ValueChange event to parse the bits and assign them to 32 other tags. iX Developer does not allow you to use arrays anywhere but in the Chart object and in Script. Therefore if you want to display a bit's value it has to be in a tag, or you have to use an expression to parse the value and return just the single bit.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: Reading bits from 32-bit variable
OK, thank you for the support!
Would there be examples (links etc.) somewhere how to do this parsing operation in correct way..?
Thanks!
Would there be examples (links etc.) somewhere how to do this parsing operation in correct way..?
Thanks!
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Reading bits from 32-bit variable
No, we do not have any examples. Standard bit wise functions are available and there is a lot of help online regarding how to deal with bits and masking using bit wise functions.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
-
- Posts: 4
- Joined: Mon May 11, 2015 7:11 am
Re: Reading bits from 32-bit variable
mark.monroe
Post subject: Re: Reading bits from 32-bit variable Reply with quote
No, we do not have any examples. Standard bit wise functions are available and there is a lot of help online regarding how to deal with bits and masking using bit wise functions.
would you mind to give us an example of reading each bits of the 32bit variable, because I havent found these a lot of help online!
Re: Reading bits from 32-bit variable
Hi,
Try doing something like this;
You can now access individual bits using their position in the array individualBits[]. Ex. individualBits[0] will give you the first position and so on.
Try doing something like this;
Code: Select all
using System.Linq;
int your32BitInt = 12345; //replace 12345 with your value, ex. Globals.Tags.xxx.Value;
string intConvert = Convert.ToString(your32BitInt, 2); //convert to binary in string
int[] individualBits = intConvert.PadLeft(32, '0') //add missing 0's from left
.Select(x => int.Parse(x.ToString())) //separate each individual char to int
.ToArray(); //convert to array
Reading bits from 32 bit variable
Im trying to open a new screen using LUA but I cant get it to work. Ive tried using the gre.send_event"change_screen" example above but it doesnt work. Im using 5.0.
Is this the only way to change the screen using LUA or am I missing something?
Thanks.
Is this the only way to change the screen using LUA or am I missing something?
Thanks.