LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication Not Functioning Fully

Solved!
Go to solution

Hi,

 

I'm trying use a USB GPIO module with LabVIEW. It uses a driver to allow serial communication with the device.

 

I’m using the basic serial example vi that is supposed to be able to read and write to a serial device once the settings are inputted.

The problem is that is won’t do either of those, while a normal terminal program with the same setting can communicate just fine.

 

The odd thing is, there seems to be a buffer somewhere near the COM port, because none of the LabVIEWcommands will go through to the device, but if any command is sent from the terminal afterwards, it pushes an earlier LabVIEWcommand through first. Even with the Labview program closed. The read function in LabVIEW also tends to return whatever the write function sent.

 

I would appreciate any insight or advice!

 

0 Kudos
Message 1 of 14
(3,684 Views)

You did not give us enough information to do more than guess.

 

Guess1: Your device has a communications protocol which includes a termination character. The terminal program appends a termination character but your LabVIEW code does not.

 

If termination characters are not the issue, then tell us what device manufacturer and model you are using along with its communications protocol.

 

Lynn

0 Kudos
Message 2 of 14
(3,664 Views)

Thank you for your reply Lynn,

 

I'm using a NUMATO 8 Channel USB GPIO Module. It doesn't seem to care whether there is a termination character or not. I've tried both in LabVIEW and the terminal with the same results (the terminal gives the option of appending with \n or not). I've even tried different BAUD rates in each, with the same results. The module seems to have autobaud.

 

I'm using the sample Basic Serial Write and Read.vi that comes with LabVIEW, but i can post the code if neccesary. All of the options (Data bits, baud rate, parity, ect.) are set to the same as the terminal.

 

Is there any additional information that would help?

0 Kudos
Message 3 of 14
(3,646 Views)

@whodatwhosaywhodat wrote:

 

The odd thing is, there seems to be a buffer somewhere near the COM port, because none of the LabVIEWcommands will go through to the device, but if any command is sent from the terminal afterwards, it pushes an earlier LabVIEWcommand through first. Even with the Labview program closed. The read function in LabVIEW also tends to return whatever the write function sent.

 

I would appreciate any insight or advice!

 


Termination Character Termination Character Termination Character

This is your problem.

 

I bet that when you are using the termainal you can type in your command and nothing happens until you hit the Enter/Return key?

You have to do the same from your LabVIEW code. Your device will nothing until you send it the "Enter/Return key"

 

The "buffer somewhere" is the buffer on your GPIO. LabVIEW is sending all the character to the buffer on the GPIO. The GPIO does nothing because you did not send a Termination Character. Then when you close LabVIEW and open your terminal program and send a new command to the GPIO buffer, the old LabVIEW command is still sitting there and is processed first before the new stuff.

 

But as pointed out the GPIO will not do anything until you either hit the Enter/Return key or send it a Termination Character.

Omar
0 Kudos
Message 4 of 14
(3,641 Views)

Omar,

 

I have tried adding the termination character to the end of the write buffer, toggling the Enable Termination Char option, and making sure the display option for the write buffer string is backslash code. All combinations of these produced the same results.

 

Is there another option I could try?

 

It makes sense that the buffer is in the device.

 

Thanks

0 Kudos
Message 5 of 14
(3,620 Views)

@whodatwhosaywhodat wrote:

 

I'm using a NUMATO 8 Channel USB GPIO Module. It doesn't seem to care whether there is a termination character or not. I've tried both in LabVIEW and the terminal with the same results (the terminal gives the option of appending with \n or not). I've even tried different BAUD rates in each, with the same results. The module seems to have autobaud.

 

I'm using the sample Basic Serial Write and Read.vi that comes with LabVIEW, but i can post the code if neccesary. All of the options (Data bits, baud rate, parity, ect.) are set to the same as the terminal.

 

Is there any additional information that would help?


I checked the Numato web site and in their sample code they show appending a termination character to the commands that they send.

http://svn.numato.cc/dl.php?repname=numatocc&path=%2Fsamplecode%2Flabview%2Fsimple%2Fusbsimplecomman...

 

I am sure a termination character is required!

 

Since you are using their USB driver it never is really RS232 so baud rate does not mean anything

Omar
0 Kudos
Message 6 of 14
(3,617 Views)

Unfortunatly I have not been able to open that document because I have an older version of LabVIEW (2012).

 

Thats good to know it needs it though. The question is now why won't LabVIEW send one? I'm not sure how else to make it.

 

Thanks!

0 Kudos
Message 7 of 14
(3,610 Views)

Please share some code to show what you have tried.  You are likely missing something.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 14
(3,606 Views)

This the vi I'm using. Some of the inputs I've been using in the write buffer are:

 

gpio\sset\s4\n

 

ver\n

(should return a value to read, which it does not)

 

Thanks

0 Kudos
Message 9 of 14
(3,588 Views)
Solution
Accepted by topic author whodatwhosaywhodat

From YOUR NUMATO manual page 10

 

3. To send a command to the module, use an API equivalent to write/writefile and pass the buffer/string containing the command. It is important to append Carriage Return (ASCII 13) to emulate the ENTER key

 

The code you posted is using a \n (ASCII 10) Line Feed or New Line

You need to use \r (ASCII 13) Carriage Return

Omar
Message 10 of 14
(3,535 Views)