LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Correct way to use same instruments in 2 different VI's

I am trying to make a VI for automating Resistance vs Temperature measurements using LakeShore 336 temperature controller and Keysight B2912a source meter as the instruments.

 

So I want to make 2 separate VI's one to enter setpoint in LS336 in ramping mode (start to end at constant increment a second) and the other VI to take measurement data into a file and to plot the same on that VI (this VI will be in loop as long as user doesn't quit).

 

Now my doubt is that since 2 VI's are controlling LS336, should I use initialise and close blocks in both the VI's or Initialise in the control.vi and close in measure.vi.

 

I'm getting this doubt since If I keep both modules in both vi, then when I  use control.vi first then the instrument goes to the required mode but when I run the measure.vi it stops being in that mode but just goes to normal mode and reads temperature data.

 

0 Kudos
Message 1 of 4
(2,065 Views)

Hi ashwin,

 

Now my doubt is that since 2 VI's are controlling LS336, should I use initialise and close blocks in both the VI's or Initialise in the control.vi and close in measure.vi.

Init and close the communication in a 3rd VI and wire the VISA reference (?) to those 2 VIs…

 

It seems you have a shared resource here, so you also need to handle race conditions: it could be a bad idea to send commands to your device from two parallel running VIs: which VI gets which answer from your device?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(2,002 Views)

If you make a non-reentrant sub VI that writes a command and (waits for and) reads the answer, you should be OK. Splitting the write and read won't work, you'll get race conditions.

 

Alternatively, you can make something run in parallel, and have send\receive messages to\from it.

 

Alternatively, you can make something run in parallel, that continuously collects data, and stores it in a buffer that the rest of the application can read. This can be in combination with sending messages to it.

0 Kudos
Message 3 of 4
(1,993 Views)

In my experience, it is best to have a Queued Message Handler to take care of all communications with your controller.  This is a VI that runs in parallel with the rest of your code.  It accepts commands via a queue and does whatever it needs to in order to perform that command.  It should complete said command before it loops back around to looking for the next command.  I will often use the queue timeout to periodically grab measurements and send them out via another Queue or User Event for the sake of logging (have a separate QMH to handle logging of data).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(1,978 Views)