LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Make visa write return sooner

This is somewhat a continuation from this thread but I figured it was different enough to warrant another one. My question is this: I have multiple visa (serial) references in an array. I use an autoindexing for loop to write to each one. I have benchmarked the VISA write function and it takes 14 ms to execute when writing 68 bytes of data with a 38,400 baud rate. Because I have them in a for loop if I am using 8 serial ports, it takes over 100 ms for the for loop to complete. By this time, the hardware has expected another write to have happened on the first serial port, but because the subsequent writes (which are in serial..ha..ha.) take so long to execute, it hasn't written again. I know one solution is to put them in parallel, but I am trying to avoid spawning off threads on a PXI chassis based on the number of serial connections I have. This not only complicates the serial communication, but greatly complicates my application because then I would need to manage a dynamic number of queues being used to pass data to my host communication thread.

 

As a side note, I have tried both synchronous and asych writes.

 

Is their any way to communicate via serial, maybe on a lower level than visa, so it just sticks the data in a transmit buffer and leaves it there for the hardware to manage, rather than waiting for what looks to be a return after the data has been sent.

0 Kudos
Message 1 of 5
(2,288 Views)

I am using a PXI 8431 card

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

for(imstuck) wrote:

As a side note, I have tried both synchronous and asych writes.

 

Is their any way to communicate via serial, maybe on a lower level than visa, so it just sticks the data in a transmit buffer and leaves it there for the hardware to manage, rather than waiting for what looks to be a return after the data has been sent.


Well, the async writes should be about as fast as you can go.  but the math (14mS for 68 bytes at 38400 Baud) seems off.  How are you connected to the PXI device.  I'm thinking a chassis controller might have less latency than say a MXI bridge.  You aren't doining anything silly like re-initing the VISA session right?  Put a conditional probe on the session in- is it valid?


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 5
(2,265 Views)

@Jeff Bohrer wrote:

Well, the async writes should be about as fast as you can go.  but the math (14mS for 68 bytes at 38400 Baud) seems off.  How are you connected to the PXI device.  I'm thinking a chassis controller might have less latency than say a MXI bridge.  You aren't doining anything silly like re-initing the VISA session right?  Put a conditional probe on the session in- is it valid?


 

Currently I'm not sure how I am connected. However, I can say that no, I am not opening and closing the session in the loop. I made a test program that is just visa open, loop with visa writes, then visa close outside the loop. I have also verified the string truly is 68 bytes and there aren't extra characters in there I'm missing, or something like that.

 

I have connected a scope up to the serial line. I put a gap of a few ms between writes so I can see where one transmission ends and the next one starts when looking at the scope. If I (on the scope) measure the delta time between the start and end of the transmission, it's ~19.4 ms. If I calculate 68 bytes*8 bits/byte + 3 bits for start stop parity / 38400 baud I get .0142 seconds or 14.2 ms. Is this calculation correct? The result is very close to what my benchmarking of the Visa Write is showing. Also, I'm curious of the 5 ms discrepancy between the delta t on the scope and the visa function time to execute. Any more thoughts?

0 Kudos
Message 4 of 5
(2,233 Views)

If I (on the scope) measure the delta time between the start and end of the transmission, it's ~19.4 ms. If I calculate 68 bytes*8 bits/byte + 3 bits for start stop parity / 38400 baud I get .0142 seconds or 14.2 ms. Is this calculation correct?

 

Guess not- the start to end of TX is 19.4mSec- can't argue with imperical data (maybe there is some handshaking going on?)

 

If you are using the Async VISA calls you are just dumping data to write to a buffer and leaving. so the VISA write execution time won't = TX time till the buffer is full and it can't write to it till it moves out.Smiley Wink

 

looks like time to manage additional queues- you aren't going to get there from here on that PC- faster DMA access might help.


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 5
(2,217 Views)