Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication Problem

Hello,

I am having trouble communicating via serial.  I am able to communicate (with default serial settings) with my instrument using a VISA test panel in MAX, but as soon as I try in LabView it doesn't work.  I have been using the attached VI.  If I send, say, *idn? nothing will happen, but if I try to send it again I get an error on the device.  Thus it is probably writing correctly but not reading.  Any suggestions?

I have tried this VI with both an Agilent E3645A power supply and 34401A multimeter.

Thanks!
0 Kudos
Message 1 of 5
(3,521 Views)
Nick,

as the error on the device shows up with the 2nd attempt, I'd say your termination character is not properly set. Thus the device expects more for the first command to be complete. And when the 2nd attempt is performed, it recognises an unknown command or timeout and issues an error. RTFM and check for the device's termination character. Usually it is either 0x0d or 0x0a or 0x0d0a (\r, \n or \r\n in the '\' display mode and CR, LF or CRLF in ASCII).
HTH   and Greetings from Germany!
--
Uwe

0 Kudos
Message 2 of 5
(3,509 Views)
Hello,

That didn't quite work.  I tried each of those termination characters to no avail.

When I am able to successfully read/write with a test panel in MAX, I send *IDN?\n and receive HEWLETT-PACKARD,34401A,0,10-5-2\r\n
When I click on "View all settable attributes" under the Property Node tab in the test panel I am given that the termination character is 0x0A.

I am using the attached VI, which is modified from the previous one to allow changing of the read termination character.  I try sending *IDN?\n or *?IDN? using 0A, 0D, and 0D0A (which is what I would guess it is given the machines reply above) for read termination and I get errors.

Thanks!

Message Edited by Nick @EDM on 03-21-2006 07:04 PM

0 Kudos
Message 3 of 5
(3,486 Views)
Nick,

I have reviewed your code. Some comments/ideas:
  1. I do not like the termination character automatism as provided by VISA. Instead I prefer doing it myself. So I would change the display mode for 'write buffer ("")' to '\'-mode and add '\r\n\' as termination character.
    Additionally I would change 'Enable Termination Char (T)' to 'OFF'.
  2. You can not expect your device having sent the answer immediately after the request. In your VI you write the request and immediately check the answer size, which is, at this time, zero. So you read zero bytes of the answer.
    You should insert a wait inbetween VISA_write and Bytes_at_serial_port. The delay period depends on your transmission rate and the device. I'd start with 1000 ms and finetune this in iterations. So if it still does not work with 1000 ms, try 5000. If it does, work take half of the delay and try again until you find a minimum delay that does work. I'd suggest to add another 10% than to that delay to have some additional stability.
Greetings from Germany!
--
Uwe

Message 4 of 5
(3,470 Views)
Did both of those tips and it now works.  Thanks a lot!
0 Kudos
Message 5 of 5
(3,439 Views)