Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA didn't receive

I have developed a program which uses VISA Write and VISA Read (also Find Resource, Configure Serial Port, and VISA Close) to serially communicate multi-packet messages over my computers serial port to a development board running a serial interface in VHDL.  (see here)  However, I have an intermittent problem where I'll run my serial VI to communicate with my board, but don't get a response back.

I've connected an oscilloscope up to the serial Rx/Tx lines and I can see both the transmission to and response from my board. 

However, the LabVIEW VISA Read function reports that no packets were received and no errors are reported.  I am using VISA Read with an Instrument Property Node which determines how many "Bytes at Port" and triggers the VISA Read.
 
Since I am transmitting and waiting for a response from the board (which could take up to .2ms for a 12-bit packet at 115.2kB/s), I have timers and a wait sequence built in to make sure and catch any incoming packets before ending the VI subroutine. 
 
Any other suggestions as to why VISA calls might not be catching incoming packets about 1/6th of the time?
 
Jeremy
 
 
0 Kudos
Message 1 of 6
(4,231 Views)
I am assuming that since LabVIEW runs much slower than many protocols (VHDL, Serial, I2C at ns, us speeds versus a computer is understandable), it must buffer the inputs on its communication ports.  Therefore I'm assuming that regardless of the size and speed of my LabVIEW program, I should still be able to do a VISA Read command and read the last message received on the serial port, right?  (my program isn't actually that large, but just eliminating sources of error).  Guys at NI, if there are other known cases of VISA commands missing packets, please let me know.
 
Jeremy
0 Kudos
Message 2 of 6
(4,201 Views)
Can you post the code you've written? If you are using a VISA Bytes at Serial Port immediately after you do a write, it's possible that the instrument is responding slower than the program so that the byte count is zero. You can try putting a delay before checking the byte count or put the VISA Bytes at Serial Port inside a while loop and exit the loop when the byte count is greater than zero. If you do that, you would also want to add some timeout function so that the loop doesn't spin forever if and when there's a problem.
0 Kudos
Message 3 of 6
(4,183 Views)
Attached is my serial communication program.
 
I am using the "VISA Bytes at Serial Port" block right after my serial transmit.  However, in debugging I've already implemented an 8-cycle wait before the VI will exit so that if my board/instrument is slower/faster it should still be caught.  Limiting it to eight cycles also prevents an infinite loop as you suggested.
0 Kudos
Message 4 of 6
(4,174 Views)
This is what I had in mind for you to try.
0 Kudos
Message 5 of 6
(4,165 Views)
Based on what Dennis Knutson suggested, I completely rewrote my program (attached).  There are now no longer any missed transmissions.
 
Jeremy
0 Kudos
Message 6 of 6
(4,054 Views)