I'm using OPC DA Automation Wrapper to connect to an AllenBradley PLC.
I now have the requirement to set a bit within a word, independently to any other bits.
Is there any way in which I can achieve this function rigorously?
The two options I have tried are:
Setup the word as seperate bits in the OPC server (Kepware). So in other words I have 16 tags, where each one is a bit in the word, the tag names then look like:
[FULLTAGNAME].0
[FULLTAGNAME].1
[FULLTAGNAME].2
However this means I need to keep many seperate OPCItem objects
The other method is to read the entire word, convert it into bits using BitConverter
, change the bit I need to alter and then write the hold word back to the PLC.
However during testing I found that thread 1 could read the word. Thread 2 would then write into the word, changing say bit 2. Thread 1 would then change bit 4 and write the whole word back and the change to bit 2 would be overwritten.
Does anyone know a way in which I can have a single OPCItem and write to a specific bit?? Or am I stuck with having a lot of OPCItems which relate to a certain bit??
Thanks