LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with VISA...trying to write/read simple command from serial

Hi,
I am trying to use the AK protocol to send a simple command to a gas analyzer and read back the measurement. I have tried advanced_serial_write_and _read.vi but get an error message upon trying to read. I've verified all settings (baud, data bits, stop, parity, handshake) on the device and the vi. I can send the command to it through hyperterminal and get my result back but VISA seems to be doing some voodoo in the background that is not allowing me to see any results. I have edited the ...write_and_read.vi to not end with a termination character permanently and have added my own string concatonation to write what i need (in hyperterminal it is <ctl B>, space GKON, space, K0, space, <ctlC>) in ascii that is 0x0220474B4F4E204B302003   
My problem seems to be getting the read however, and i'm not sure if i can pull the raw ascii from the serial port...
any help would be GREATLY appreciated!
 
Dave
0 Kudos
Message 1 of 24
(4,530 Views)
VISA doesn't do any voodoo in the background. You don't mention the error code but I would assume it is the timeout error. This usually means that the instrument did not receive the correct command and probably because you are not formatting the string correctly. Post your VI so someone can look at how you've created the strings to send. In order to send control codes, you have to set your string controls/constants to either '\' Code Display or Hex Display. Have you done that?
0 Kudos
Message 2 of 24
(4,528 Views)
Thanks,
I will give that a try and post the code in a few minutes if it doen't work.
0 Kudos
Message 3 of 24
(4,523 Views)
Wow, thanks! That was at least half of my problem...not having the control set to hex. I still get the timeout error but then I get a reading. I will continue to work on it. If/when I get it working I'll post my finished code. Here's the 1/2 working vi...
0 Kudos
Message 4 of 24
(4,521 Views)
When you don't use the termination character for the read, you will get a timeout error if the exact number of bytes you specify for the read are not available. If you look at the Basic Serial Write and Read example, it uses the VISA Bytes at Serial Port to determine how many bytes are actually there and passes that to the VISA Read function. If the instrument does send a specific character, you can also use that with the VISA Configure Serial Port. That way, you don't have to be all that careful about telling the VISA Read how many bytes to read. The read will automatically terminate when the term character is detected and you can specify some randomly high number.
0 Kudos
Message 5 of 24
(4,520 Views)

I'm using the VISA Bytes at Serial Port and it's working great now 🙂 again i will post my finished vi when I've finished "prettying it up" in case it may help someone else trying to use the AK protocol.

Thanks so much

Dave

0 Kudos
Message 6 of 24
(4,515 Views)

As promised here's the finished code for writing to and reading from the 3000HM THC analyser [sic]... (I believe Signal Instruments is an English company)

Thanks so much for the quick responses and good help Dennis 🙂

 

Dave

 

Message 7 of 24
(4,504 Views)
hello guys, i seem to have a similar problem with ni visa. i want to communicate with a gas analyser, and take the same basic example "basic read and write ...", i only changed what i want to write to my analyser. there the manual states a specific order of bytes which i implemented and which should be correct. these are 14 bytes. and they are send to the instrument, thats a least what the return count of the visa write says. but i dont get any answer of the analyser. wht could be the problem, is there a problem with the timeout? thank u very much for ur help!!
0 Kudos
Message 8 of 24
(4,437 Views)
Did you read the entire thread? Are you sure you are sending the bytes in the correct format? Did you change the display format to hex? Are you sure the com settings are correct for the instrument? Are you sure you have the correct type of serial cable? Have you been able to communicate to the instrument with any other program (i.e. one from the vendor or Hyperterminal)?
 
There are numerous reasons for a timeout. Without seeing the instrument programming manual, the VI with the actual data you are sending, etc., it's pretty hard to isolate the problem. There are just too many things that can be wrong.
0 Kudos
Message 9 of 24
(4,430 Views)
Lorenzo, are you using the vi I posted? If so, the display should be set correctly.
By the way, What command are you sending/trying to send?
oh yeah. you do know that the instrument requires a null modem adapter right?


Message Edited by longzoo2 on 11-28-2007 11:57 AM
0 Kudos
Message 10 of 24
(4,424 Views)