LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you troubleshoot a USB virtual COM port?

Solved!
Go to solution

Object

Send commands from Labview to an Arduino Board using the Advanced Serial Write and Read.VI. 

Problem no commands are being received by the Arduino Board.

However, I can use the Serial Monitor built into the Arduino IDE to send commands to the Arduino board and obtain the required result.

I checked the baud rate, the COM port designation and the command is a simple string like 600,0.  The VI shows no error message.

 

Hence, I am looking for suggestions on how to troubleshoot a USB virtual COM port.

 

Howard

 


 

0 Kudos
Message 1 of 19
(4,562 Views)

If you are using Windows, portmon lets you see exactly what is being sent. Compare what you see the Arduino IDE sends, and what your LabVIEW code sends:

http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx

 

0 Kudos
Message 2 of 19
(4,557 Views)

My guess is that you are neglecting to terminate the string you are sending to the Arduino with a specific character, so the Arduino knows it's seen the end of the message. This is typically done by sending a carriage return and/or linefeed character at the end.

0 Kudos
Message 3 of 19
(4,529 Views)

Replying to suggestion to use Portmon.

 

I have attached a zip file containing files used to test the transmission of commands between a Labview VI and an Arduino board.   The file labeled SendReceiveTest.log is a Portmon log file taken during one run of the SerialWriteRead.VI.  The VI was requested to transmit a simple command like 123,456K.  The command contains two numeric fields separated by a comma and a terminating character. The terminating character may be any non numeric character.  The run ended with error code -1073807339 meaning timeout expired.  I looked at the log data but could not find and clues on why I am having problems sending simple commands to an Arduino board.  Hence can you look at the log file to see if it provides any clues as to why this VI can't send simple commands to an Arduino board.


Included in the zip file is the SerialReceive sketch used with the SendReceiveTest.  The expected results were obtained using Arduino's Serial Monitor.   To recreate the SendReceivTest you will need to copy the TextFinder library to Arduino's library and run the SerialReceive sketch. 

 

I used MAX to verify the COM port is working properly and both the Labview VI and the serial monitor were using the same COM values.

 

I am still looking for suggestions on how to fix this serial send receive problem.

 

Howard

0 Kudos
Message 4 of 19
(4,504 Views)

Hey hrh1818,

 

That timeout error usually occurs when you're trying to read data from the serial port when there's no data available to be read. Are you positive that the Arduino is sending back 32 bytes of data? 

 

One thing you could try is adding a VISA Property Node, and then select the Serial Settings > Number of Bytes at Port property. I'd do the VISA Write, put in a short time delay to give the Arduino time to respond, and then check the number of bytes at the port. I suspect that it's less than 32 bytes. So what's happening is that the VISA Read is just sitting there waiting for the 32 bytes of data to come in, but that data doesn't ever get there before the timeout expires.

 

Let us know if that works!

 

Thanks,

0 Kudos
Message 5 of 19
(4,473 Views)

This line in the portmon log says eight Bytes were written:

IRP_MJ_WRITE SUCCESS Length 8: 765,879j

 

What did the log show when using the Arduino IDE? A very brief look at TextFinder.cpp makes me think that perhaps the IDE is null-terminating the string.

0 Kudos
Message 6 of 19
(4,460 Views)

Reply to Todd Lesher message

 

Thank you for your help.


Attached is PortmonLogFile100112.txt.  This log file was taken when using Arduino's Serial Monitor to send the command 123,456H to the Arduino board.  I don't see a nul character at the end of  the string.  I only posted a very small percentage of the text accumulated in the log file  Arduino's Serial Monitor does a lot of busy work.  Over 30,00 transactions took place during one write read session.
 
Howard
0 Kudos
Message 7 of 19
(4,445 Views)

Ah, yes. No null character, there.

Your SimpleWriteRead.vi has the termination character enabled, and you are trying to read 32 Bytes.

Does anyone remember if VISA Read will return after those 32 Bytes, even if the term char isn't encountered?

 

I wonder how many Bytes are sitting at the port waiting to be read?

0 Kudos
Message 8 of 19
(4,440 Views)

VISA Read Details

This function might return less than the number of bytes requested if the function reaches the end of the buffer, reaches a termination character, or if a timeout occurs. The output error cluster indicates if a timeout has occurred.

 
Quote above is from the detailed help for VISA Read.

  

If 8 bytes are being transmitted without termination character, a timeout error should occur.  If the number of bytes is known and fixed, set the Byte Count to that value.  Otherwise use Bytes at Port or read the data one byte at a time and accumulate the result in a shift register.

 

Lynn

 

0 Kudos
Message 9 of 19
(4,437 Views)

 Reply to Daniels message.

 

Thank you for your help.

 

The time out occurs because the Arduinio board is not sending back any data.  Attached is the file FreeSerialPortMonitor.txt.  This file shows the write and read data for when Labview and the Arduino Serial Monitor was used to send a sample command to the Arduino board.

 

As far as I can tell it looks like when Labview is used the Arduino board does not respond to the command.  Evidentially there is a subtle difference between how Labview and Arduino's Serial Monitor communicates with an Arduino board.

Any additional suggestions?

Howard

 

0 Kudos
Message 10 of 19
(4,435 Views)