Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication with SR245 going slowly

I'm not sure whether this is a hardware or a software issue.

 

I'm trying to communicate with a Stanford Reserach Systems computer interface module, SR245.  I use the "serial write" command in labview to query the value of one of the channels on the SR245.  I then read the port using the standard "serial read" command.  If I put this into a loop to read the channel multiple times, each iteration takes ~300 ms, which is prohibitively long.  I have no idea why it's going so slowly; according to what I can gather from the manual for the SR245, the A/D rate should be in the vicinity of 1 kHz and the box takes 500 us to complete an average function like the one I am requesting.

0 Kudos
Message 1 of 11
(4,227 Views)

Can you post your code?

0 Kudos
Message 2 of 11
(4,226 Views)

Ok, here it is.  This VI takes about N/3 seconds to complete, for N reads.  In the second frame I read a fixed number of bytes from the serial port (20). 

 

The way I was previously doing this was to use the "bytes at port" command to tell the VI to read everything at the port (which ended up being 6 bytes).  In this case, the wait time in frame 1 had to be about 300 ms (consistent with the length of time to complete N reads in the attached VI).  If it were 200 or shorter, "bytes at port" would return fewer than 6 bytes; the read would be incomplete.

 

Thanks for looking.

0 Kudos
Message 3 of 11
(4,218 Views)

Are you opening and closing the VISA session in another vi?  Where are you setting the baud rate etc?

0 Kudos
Message 4 of 11
(4,215 Views)

Sorry, yes, the session is initialized in another VI with the "configure serial port" function.  The baud rate is 19200.  Once I initialize the port, I never close it.

0 Kudos
Message 5 of 11
(4,212 Views)

What is the timeout set to?

0 Kudos
Message 6 of 11
(4,209 Views)

All inputs other than baud rate and termination character were left at their default values, so 10 seconds for the timeout (No flow control, no parity, 1 stop bit, 8 data bits.).  I just tried changing it, and found that the read operation will not complete if the timeout is shorter than 300 ms. 

0 Kudos
Message 7 of 11
(4,207 Views)

Manual says that SR245 can operate in either sync or async mode.  Async will return value right away and sync will wait for some sort of ext trigger.  Which mode are you running in?

0 Kudos
Message 8 of 11
(4,201 Views)

Asynchronous.

0 Kudos
Message 9 of 11
(4,199 Views)

I don't see anything in your code that would cause this.  Page 47 of manual has a section titled 'Wait Command' that might be related to what you are seeing.

0 Kudos
Message 10 of 11
(4,186 Views)