LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multithreading with multiple GPIBs

I'm trying to resolve a problem I'm having using 2 Stanford Research SR620s
(Universal Time Counter) that have been defined as RT 16 and RT 17.

Within Labview 5.1, I have a while loop where I'm doing data acquisition
from
both RTs. RT16 may take 10 seconds to complete its task while RT17 may take

7 seconds to complete its task. I don't want RT17 to begin taking more data
until RT16 has completed is job. I figure that within a while loop I should
be able to
control the synching.

Labview says I should be able to multi thread automatically but I don't see
that
happening. What I see is a ping pong effect where data is acquired by RT16

which switches control to RT17 and vice versa. I can't get them to acquire
d
ata
simultaneously. (Note: The command string used in the SR620 to acquire data
is STRT;WAI;XAVG? which begins the data acquisition; waits until it is done;

and sends back the mean value. That WAI command makes me think that I'm
not
doing multi threading properly.)

Looking thru the NI Application notes, it seems what I want to be done should

be do-able. Any clues on what I'm missing. I'm currently not using any
SRQ
commands but it didn't sound like I needed to. I've also verified that the

Preference "Run with multiple threads" is checked.

Thanks in advance !!!
0 Kudos
Message 1 of 3
(4,055 Views)
Assuming you have one GPIB board, your application needs to change to
get the behavior you want. The board can only do one thing at a time, so if
you tell it you want to read from an instrument, and this takes several
seconds, then the board can't do anything else until the data comes in or
you send another command to kill the read. (This is true even if you use
the "asynchronous" GPIB calls.)
This is why GPIB devices can request service--you can send a command to
each instrument, and they send you a message when they're ready to send data
back to you. It's a way of having the instrument asynchronously notify you
when you should take action. The first instrument to complete its
acquisition will notify you first.
Another solution would be to use two
GPIB boards--one for each
instrument. You wouldn't have to change anything in your application,
except for configuring the address of the instruments.
I hope this helps explain what's going on.


Brian
0 Kudos
Message 2 of 3
(4,055 Views)
Frank Leong wrote:

> . RT16 may take 10 seconds to complete its task while RT17 may take
> 7 seconds to complete its task. I don't want RT17 to begin taking more data
> until RT16 has completed is job. I figure that within a while loop I should
> be able to
> control the synching.
>
> Labview says I should be able to multi thread automatically but I don't see
> that
> happening.

Multi-thread would happen automatically if the two were in different loops.
It may also occur if there are say 2 subvis in one loop. One problem (as pointed
out)
is the way GPIB works. To my mind multi-thread will do you no good in this app.

> What I see is a ping pong effect where data is acquired by RT16
>
> which switches control to RT17 and vice versa. I can't get them to acquire

> data
> simultaneously. (Note: The command string used in the SR620 to acquire data
> is STRT;WAI;XAVG? which begins the data acquisition; waits until it is done;
>
> and sends back the mean value. That WAI command makes me think that I'm
> not
> doing multi threading properly.)

Here is my suggestion to fix this. I do not know about there Counters so
this idea may not be valid.
Setup the 2 counters and make them single trigger (SW trigger).
enter while loop, send a GET (group execute trigger) to RT16 & 17
this sends a trigger command to the addresses specified.
They should now both start acq.
You may want to put a wait for the longest one.
send the XAVG? to each one and read back.
This should cause them to start at the same time
and then read back the data.
Hope this is useful.
Kevin Kent
0 Kudos
Message 3 of 3
(4,055 Views)