LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OPC data tag-single bit

I am trying to read OPC data tags using LabView 6.0
For bit data, the tag list says 1=ON, 0=OFF
What data type should I use to read and write a single bit?

I have tried I8 and boolean, but neither seem to work.
0 Kudos
Message 1 of 6
(4,100 Views)
Hello!  Thanks for contacting National Instruments.

Are you using DataSocket or LabVIEW DSC to communicate with the OPC?  This KB may be of help to you, as it discusses some of the example programs that ship with LabVIEW.  If you still have questions after reading that KB, please post some of your code, so that we can take a look at what you have setup.



Lorielle P.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(4,078 Views)
I am using DataSocket interface.  The data bits represents valve on/off. So bit 1 turns valve 1 ON/OFF, bit 2 valve 2 and so on.
The OPC tag is set up with 1byte for valve 1-8 and single bits for the each valve individually.
I can operate the valves using the OPC server's read write function by sending a 1 or 0.

In Labview I can send a binary 8bit data (I8 data type), but I have to address valves as a group.
I don't see any data type that hold 1 bit.

I have tried using a boolean control but that does not work.

Perhaps I could just send a 0 or 1 decimal using an integer data type?

Thanks,
Dingin
0 Kudos
Message 3 of 6
(4,074 Views)
Here is the read tag byte data as viewed from the OPC server explorer.
The send tag is similar structure.

Again I can use data socket to read (or write)the entire byte, but I don't
know how to address individual bits


Download All
0 Kudos
Message 4 of 6
(4,072 Views)
Some choices you could do.
 
1.  Read the byte and XOR with a byte that has the bit corresponding to the interested valve set to 1, all other bits being zero.  This changes the state of that valve from on to off or off to on.
2.  Read the byte and OR it with a byte where the appropriate bit is set to 1, this guarantees that bit to go on whether or not it is already on.
3.  Read the byte and AND it with a byte where all bits are 1 except for the valve you are interested in is set to zero.  This sets that bit to off whether it is already off or not.
0 Kudos
Message 5 of 6
(4,061 Views)
The DataSocket Read function should be able to read individual bits, since you can specify the data type for the function as a boolean.  Can you post your code or a screenshot of your block diagram, so that we can see what you have set up?
Lorielle P.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 6
(4,043 Views)