LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication Problem

Solved!
Go to solution

Hi,

 

I want to control an instrument via Labview serial port, but I'm unable to communicate properly with it.  It works perfectly when I use Hyper Terminal, but as soon that I'm using the "Basic Serial Write and Read.vi", I have some timeout issue.  The "write" doesn't give me any error,  however the "read" is never working.  Unfortunately, none or the commands seems to work.  That seems like a communication problem. 

 

Here's the parameters of communication for the instrument:

Baud Rate: 115200

Data Bits: 8

Stop Bits: 1

Parity: None

Flow Control: None

Termination Charaters: \r\n

 

Thru MAX, the communication port is OK and I'm able to open the test Panel.  Howerver, I'm not able to acces the information when I'm asking some query, or there's no action to simple commands.

 

Thanks for you help

0 Kudos
Message 1 of 16
(3,449 Views)

Usually in situations like what you have described the problem is that you did not send the termination characters.  You must do so explicitly in LV.    Make sure the "string to write" control is set to '\' Codes Display and then type the codes for the termination characters at the end of the command:

 

DO_SOMETHING\r\n

 

See if that helps.

 

Lynn

0 Kudos
Message 2 of 16
(3,442 Views)

Hi Lynn,

 

Thru MAX, I've been able to sent the command and get some answer to my query.  However, with LV basic serial communication, I still struggling to get the same result.  Maybe I'm doing something wrong again.

 

Thanks for you help

 

Francis

0 Kudos
Message 3 of 16
(3,430 Views)

You cannot set two characters for the termination character. It's one character, not two. If the instrument ends its messages with \r\n, then you should set your termination character to \n.

0 Kudos
Message 4 of 16
(3,426 Views)

Hi,

 

I did all the things you told me.  I even use the example Advance Serial Communication VI but I still have this error:

 

Error -1073807339 occurred at VISA Read in Advanced Serial Write and Read.vi

 

To be honnest with you, I don't have a clue what I'm going wrong.

 

Thanks for you help

 

Francis

 

 

 

0 Kudos
Message 5 of 16
(3,416 Views)

That's a timeout error.

 

It also means it is time for you to post your VI so we can see what you are doing.  Also, any link to the device's communication manual is helpful.

0 Kudos
Message 6 of 16
(3,412 Views)

I have used the example from LV2009: Advanced Serial Write and Read.vi.  Just to make sure I didn't make a mistake in coding. I just make the current value as default, so you can see what I really sent to the instrument.

 

In the manual, you can go to section 9.1. RS-232 Communication Protocol (p.75) and 9.2. RS-232 Command Set (p.76-77).

 

Thank for you time and help

 

 

 

 

 

0 Kudos
Message 7 of 16
(3,405 Views)
Solution
Accepted by topic author StarFiber

@StarFiber wrote:

I have used the example from LV2009: Advanced Serial Write and Read.vi.  Just to make sure I didn't make a mistake in coding. I just make the current value as default, so you can see what I really sent to the instrument.


I am assuming you're not actually sending *IDN? since that's not even a command that's supported by the instrument.

 

The instrument requires that you terminate write commands with BOTH a \r and \n. By using the "End write with termination character?" only the \n is being sent since that's what the termination character is set to. It's not clear how the instrument will respond, if at all, if it does not see both \r and \n. So, turn this off, set the "string to write" to display in '\' codes mode (right-click and select it from the popup), and enter the command, followed by \r\n. Alternatively, you could leave that option on, but you must make sure you add \r to your command in the "string to write" textbox.

Message 8 of 16
(3,393 Views)

Well, the VI you attached as the baud rate set for 9600 instead of 115,200.   And the command you are writing is *IDN? which did not appear in the manual.  I don't know if this is the copy of the VI where you set your commands as the default values, or not.

 

Assuming that isn't the problem, the next step would be to download and run portmon.  See what happens when you are able to make things work through hyperterminal, and compare it to what happens with LabVIEW.

0 Kudos
Message 9 of 16
(3,386 Views)

Thanks...It seems to be the solution.  However, the read takes a little time before it response.

 

At least I can communication via LV.  Not I'l try to optimize it.

 

Regards,

 

Francis

0 Kudos
Message 10 of 16
(3,382 Views)