LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 instances of one VI and access to common hardware

I have a VI that gets data from 2 GPIB devices. The measurement system has to be scalable. Running 2 instances of the VI is OK. They connect to their own set of hardware with one GPIB bus. But both that instruments have to collect data from one other instrument (GPIB or RS232, not yet decided). How can I implement that? I was thinking of creating another VI, that would continously get the data (temperature an so on, signals are slow changing) and both VI, would connect to it and get latest measurements.
0 Kudos
Message 1 of 7
(3,134 Views)
Nice computer. Must be running Windows. Smiley Very Happy

Creating a data collection VI is a typical method used. Another is to make the instrument access exclusive so that if one VI is trying to access it, the other has to wait. This latter approach may not be desirable, but then I don't know what your system is doing. The data collection VI mechanism can be implemented several ways. I would suggest looking at queues. There's a number of examples that ship with LabVIEW on using queues. Also, if you do a search on this forum you will come across this scenario, as many others have had this same issue, so you may even be able to find some examples.
0 Kudos
Message 2 of 7
(3,108 Views)
VI nr 2 is collecting temperature and light intensity data. VI 1 is doing some longer tests, which require getting temp and light values at the beggining of each test.

How can I make device 5 exclusive when I have 2 instances running? Can I make one VI aware of the second one? Maybe communicate? This would be great, because I could then specify a boolean variable: "I'm getting the data, go away!" 🙂
0 Kudos
Message 3 of 7
(3,099 Views)
I am not sure I understand what you want to do. Here is how I have interpreted your requirements: You have multiple instruments on one GPIB bus and may be adding more instruments, either on the same bus or through a serial port. Different instruments are read at different rates. Some data may need to be used by multiple parts of the program.

I agree with smercurio... on the concept of using a data collection VI. Looking at the scenario with all the instruments on one GPIB bus, create a VI which runs as a parallel independent loop. It does all the reads and writes to the GPIB. The data from each instrument is put into a queue (or queues if multiple destinations are required for the data) or an Action Engine (AE). The Consumers of the data remove the data from the queue or read it from the AE. The data can be read periodically (possibly with a different rate for each instrument) or on demand. If the on demand method is used, the data Consumers would send their requests to the GPIB VI via a queue or notifier.

If this is not what you want, please try to be more specific about your requirements. How much data is read from each instrument? How often? How many places does the data go?

Lynn
0 Kudos
Message 4 of 7
(3,089 Views)
Another option is to use VISA Locks. One VI check if the resource (i.e. a com port) is locked and if not lock it until it is done and then release it. Another VI would do the same. There is a shipping example that demonstrates this. If you are running two different executables, though, I don't think the VISA Lock would work
0 Kudos
Message 5 of 7
(3,085 Views)

Each VI1 is a separate instance. Each instance has 2 main devices logicly connected to it: VI1 - instr. 1 and 2, VI1´ - instr. 3 and 4 and so on. They only connect to their own hardware. But one instrument is common to every VI1 instance (instr. 5). It is read rarely: each instance needs the data from it every ~15s.

As instrument 5 is a multi channel A/C converter I need to send commands: change channel, read value in that order. My initial idea was to make another VI (VI2) that would handle getting data from this device. Then, somehow make VI1´s get the data from it.

0 Kudos
Message 6 of 7
(3,058 Views)

hi there

i'd check if there are any OPC-Servers for these devces. Or you may think about writing one single VI that does all the hardware communication and reads/writes data from/to Datasocket items or shared variables.

Then an arbitrary number of VIs could access the data without actually communicate with the hardware (even over the network!). Communication is then done by one single VI, so there would be no collisions.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 7 of 7
(3,042 Views)