LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help Buffering Shared Variables

Synchronous communication using shared variables can be a challenge. You definitely should not have buffers on the variables you use for handshaking. One good approach is having a boolean for "Host Ready" and one for "Target Ready". Then make sure you set them in the right order. For instance, on the host you could poll the Target Ready in a loop that exits when it is true. Then the host writes its value to the Data shared variable, then writes true to Host Ready. On the target, it would first write target ready, then poll for Host Ready to go true. After host ready goes true, you know that Data Variable has a recent value. You can even check the timestamp to make sure.
 
Another good DevZone that might help you is the Command-Based Architecture. It uses TCP but with shared variables the concept is the same.
 
You would just use a string variable instead of the TCP writes and reads.
 
Richard

Field Sales Engineer, New Jersey
National Instruments
0 Kudos
Message 11 of 16
(1,465 Views)

I'm familiar with that Command-Based Architecture example.  (I struggled with it for some time, and was so happy when LV8 was released since shared variables would surely solve all my problems!)  I think the Shared Variable Client-Server example in LV8 works on pretty much the same principle.

Here's what I have now on the Host PC when I need to read data.  I think it works, but I'm a little worried about what that uninitialized shift register might do.

I'm still having some problems with the compiled VIs and shared variables; maybe I'll start a new thread about that later.

0 Kudos
Message 12 of 16
(1,452 Views)
Kehander,
        Unitialized shift registers worry me to.  Why don't you initialize it?.  By compiled VIs, do you mean built applications?  You will need to programmtically deploy the shared variables if that is the case.

Cheers,

NathanT
0 Kudos
Message 13 of 16
(1,441 Views)

Programatically deploy?  Do you mean with the Library.Deploy Library method?

So in summary, I have to:

  • Add code to Read Data Trisample to deploy the library
  • Build Read Data Trisample VI on the RT target
  • Call the built application from the Host PC

But even then, it seems I won't be able to see the front panel of the VI on the RT target unless I put in code to enable the Remote Panel.  This is turning into an awful lot of code to save myself the trouble of clicking three times (double-click the VI in the project to open it on the target, then click the Run button)!  Surely there is a simpler way to do this?

Could you perhaps provide a brief example of how to do this with the Shared Variable Client-Server example?

Maybe initializing the shift register with an empty array will work after all; this will require some more testing.

0 Kudos
Message 14 of 16
(1,430 Views)
Kehander,
       Yes, I mean programmtically deploy with Library.Deploy Library method.  For the most part, RT VIs are meant to run without front panels.  If you just need to front panel for debugging, than you can enable remote debugging on your executable.  You can then connect to it when it is running on your PXI and see the front panel and block diagram for debugging purposes.  The remote front panel is a good tool if you want the user to see the RT front panel on the finished application.  You can set the RT executable as a startup executable which will start as soon as the PXI boots up.  If you would like to always use the development environment to run your application, that is also an option.

Cheers,

Nathan
0 Kudos
Message 15 of 16
(1,404 Views)
Perhaps I was not clear: it was always my intention to run everything through the development environment. My sole concern was saving myself (and the end users who will also be running it through the development environment) the trouble of making those three clicks, since the program on the Host PC can't do anything without the program running on the RT target.

With that in mind, is it possible to do what I suggested without building the application on the RT target first? Perhaps I can just programatically deploy the whole VI along with the shared variables, and then call it from the Host PC?

(If it is not possible, would it be bold to suggest that it ought to be?)
0 Kudos
Message 16 of 16
(1,398 Views)