LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA write/read using RS232

Here is the actual VI. Thanks!
0 Kudos
Message 11 of 18
(2,791 Views)
You should defenitely include a session close and a delay as mentioned in my prev post.
Message Edited by muks on 09-02-2008 10:25 AM
0 Kudos
Message 12 of 18
(2,776 Views)

You are running your code too fast. Even if you don't perceive any delay when watching at the Hyperterminal screen, this does not mean that there isn't.

Give the device a chance to prepare and send you the response; the simplest way is to put a delay between the write and the read: 100 or 200 ms may be enough.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 13 of 18
(2,775 Views)

Hi Guys,

Thanks very much for all the suggestions. Unfortunately the writing to the instrument is still not consistent. I have included delays in two places in addition to the visa close. I am attaching the VI again. Please see if I am making any other silly mistake. I have tried enabling and disabling the termination character but it makes no difference at all. I have tried all combinations of \n, \r and \r\n but as before the stupid instrument is behaving in exactly the same way.

 

Thanks again,

Sunil.

0 Kudos
Message 14 of 18
(2,757 Views)

You need to wire your VISA reference & error cluster for ALL cases within a Case Structure.

 

Also, your WAITs were a bit useless.. 

 

I modified your VI.  Try the one attached.

 

R

 

I forgot to ask which LV version you are using.  The attachment was edited in LV8.2.

In your particular case, you would always write to the port and then read from it.  So you could remove the two (outer) Case Structures that ask if you want to write or to read, because, in your case you always want to do both. 
Message Edited by JoeLabView on 09-02-2008 01:17 PM
Message 15 of 18
(2,754 Views)

Here is what I meant in my last post by removing the Case Structures.... Try this one..

 

Do you expect any substantial delays between the time to write and to read?  If so, use the Delay control to adjust the wait period.

 

R

 

Message 16 of 18
(2,747 Views)

Thanks Joe. The read was working well with the changes you made to the VI. The write was having the same problem. It would write sometimes but not at other times. I ended up putting the write in a while loop which goes on writing until someting appears on the read buffer. It works within 1-2 seconds - which will do for my present requirement.

 

Many thanks for your help!

0 Kudos
Message 17 of 18
(2,722 Views)

Serial Write do not need to be in a loop.  Almost sounds a communication speed...  or end-of-line character...

 

Glad it works, but I'm curious, when you say you write in a loop, do you send the same command over & over again?

Maybe you simply need to put additional delay between the write and the read, using the Delay control.  It is in ms, so you could try 1000ms, for instance..

 

R

Message 18 of 18
(2,704 Views)