LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Datasocket value updates

I am writing an executable program that uses datasocket that reads/writes to a OPC server for a PLC and populates some shared variables (LabVIEW 2011). 

 

I am having a few problems.  The biggest problem is that when the program starts my boolean values do not always update with the current value from the OPC server.  When the OPC value changes then the indicator will track the correct values.  I am binding front panel indicators using datasocket, some are read only and some are write only.  The read/write does not always seem to do what I want for some reason.  For example, I have a boolean that indicates if there is a halt condition on the PLC.  In LabVIEW I have a indicator with the default set as true (error) so when the program starts it should update with the correct value of false that the OPC is showing.  If I manually toggle the OPC value then the indicator will update correctly.  Is there a way to force the indicator to read from the OPC server when my program starts?  I tried adding "opc:\\ServerName\OPCServer\ItemName?updaterate=100​&deadband=0.7" but it did not help during startup.  I found it in a few posts on the forums, but most datasocket posts seem quite old.

 

I have tried OPC clients and they work fine reading values.  So I am thinking that it is just the datasocket trying to be efficient and only update when the value changes.  So I need to force it to update when the program starts.

 

The other problem is that sometimes it takes a long time for datasocket to make all the connections and turn the LED's green.  I was wanting to put a revolving indicator (progress) bar showing that something was actually happening.  But it seems like the datasocket operations run before any code runs, so it looks like the program just hangs and any programming I do runs after datasocket has run.

 

Thanks

0 Kudos
Message 1 of 5
(3,523 Views)

It looks like using a datasocket read.vi to update local variables of the indicators before my main while loop seems to work.  But I am hoping there is a better way to do this.

0 Kudos
Message 2 of 5
(3,508 Views)

Hi Bryan,

 

I am not quite sure on how you have the application setup but, as far as I understood, I was looking at the following document and think that if you don't have already marked your false contant to wait for updated value, it could help with the indicators not being updated when you would like them to.

 

Hope you can find it helpful!

Regards,

Sil.VI
0 Kudos
Message 3 of 5
(3,457 Views)

Thanks for the attempt.  I am binding front panel controls.  "You won't see this delay if you make the DataSocket connections on the front panel rather than using the DataSocket VIs"

 

The indicators are not being updated when the program first runs.  I have ended up putting a datasocket read.vi  before my loop that populates the indicators with the correct values.  Not pretty, but it works.  I also notice that this is only happening with booleans, numbers seem to update on first run with no issues.  So if I changed all the flags (booleans) in my PLC program to numbers the issue would probably go away as well.  But I am going to pass on doing that for now.

 

Thanks

0 Kudos
Message 4 of 5
(3,441 Views)

Hi Bryan,

 

I know that it seems a very late answer and you had probably finished your project, but I just wanted to share a solution that might help as well with the Front Panel binding with Datasockets URL connected to NI OPC Server, since I tackled the same challenge (Some Variables were not updated at the beginning of the VI run) and I had tried to use the Datasocket property nodes (Enabled, URL,...) at the start of the code, but nothing changed ...

 

However, I found out that it is very important to Change the variables to Indicators when binded with READ ONLY sockets or to Controls when binded with WRITE ONLY sockets. This solved the whole issue, but I did not yet test how this will work with READ/WRITE variables, but if you had further experiences with the Front Panel binding, it would be great to share it 🙂

 

Best Regards,

Ahmed Zahran

0 Kudos
Message 5 of 5
(2,957 Views)