Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing out on Serial Read

Solved!
Go to solution

I've got a problem with reading data in labview and also in MAX.  MAX says the device is fine, and I can even communicate to update attributes correctly.  I'm certan the data is being transmitted correctly because I'm able to retrieve the data with no problems in Matlab.

 

The device I'm using is a DLP-USB245M which is a USB device that creates a virtual serial interface.

 

Some code I'm using to test the device is attached.  It always takes 10 seconds and times out.  I would appreciate any pointers.

0 Kudos
Message 1 of 16
(4,474 Views)
I don't understand what you are trying to do. Why are you flushing the buffer before each time you do a read. Any data in the buffer is erased so what do you expect to read? Does the instrument constantly send data with being issued a command? If you do need the flush the buffer, you should do that and the configure serial port once - when your top level VI starts.
Message 2 of 16
(4,453 Views)
Your VI doesn't send a command to tell hardware to do anything. It will always just wait for 78 bytes which will never be there. What's the command to the DLP-USB245M that you send in with Matlab?
Richard






Message 3 of 16
(4,446 Views)

This is just code to grab 78 bytes of data to verify that I can even do that.  This isn't a sub-vi.  Is that why you were thinking I was flushing the buffer or am I doing something else wrong.

 

The only thing I need to do is assert the transmit enable, once I assert the transmit enable the device just continuously sends data.  I assumed this was done by the read function, but I'm assuming this is my problem.  All I have to do in matlab is this:

 

s = serial(COMport);
s.Terminator = 0;
s.InputBufferSize = 78*Nframes * 10;
fopen(s);

0 Kudos
Message 4 of 16
(4,414 Views)
  • I'm not sure what a "0" for the terminator means in matlab, but in LabVIEW, it means Linefeed. Are you sure the termination character is Linefeed?
  • You need to get rid of the Flush
  • Read less then 78 bytes just as a test, to see if you get something. If there's less than 78 bytes on the port and you try to read 78, it'll timeout every time.

 

 

 

 

 

Message Edited by Broken Arrow on 10-26-2009 12:15 PM
Richard






Message 5 of 16
(4,408 Views)

The string ends with 0x00.  I'm still not understanding where I am doing a flush.  Could you point it out for me?

 

I've also tried to read data in MAX, with no luck there either.  I can write to the device and update control with no problems. 

0 Kudos
Message 6 of 16
(4,401 Views)
And I made a mistake when I looked at the VI. I thought the Set I/O buffer Size function was the Flush Buffer function. You don't need that either. You also say that you need to assert transmit enable. You are not doing any handshaking so you are not asserting anything. Specifically, what pin are you trying to assert? You can assert DTR or RTS with a property node.
Message 7 of 16
(4,397 Views)

was1984 wrote:

The string ends with 0x00. 


my bad, a 10 is a linefeed, you have it set to 00.

 

What Dennis said! Smiley Happy

 

Idea Exhange Idea: Make those functions look more different!

 

Message Edited by Broken Arrow on 10-26-2009 12:39 PM
Richard






Message 8 of 16
(4,392 Views)
I'm not really sure if its DTR or RTS, since this is a USB port with a virtual COM interface.  The actual signal pin is called TXE#, but there is nothing in the documentation about DTR or RTS.
0 Kudos
Message 9 of 16
(4,391 Views)

I don't know of any pin called TXE#. Could you attach the manual so someone can see what the actual pin is?

 

Does the instrument have a built-in USB>RS-232 converter or are you using something separate?

Message 10 of 16
(4,384 Views)