LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication with Agilent Vacuum Pump

Hi,

 

I'm currently trying to communicate with an Agilent TwisTorr 304 FS AG Rack Controller via serial with LabVIEW. My computer detects the controller through some software given to me by Agilent, so it is hooked up correctly. My issue is that I'm not sure how to send the commands to the pump correctly.

 

 

Here is a screenshot of the relevant part of the manual.

 

page1.PNG 

 

page2.PNG

page3.PNG

 

I want to use to use the READ PUMP STATUS command. Just sending the numbers with a \n (i.e. 028332303530033837\n) doesn't work and gives me an error. I'm fairly new to serial communications so perhaps I'm missing some sort of format guideline or something?

 

Thanks!

Message 1 of 42
(8,930 Views)

You might be mixing your string formatting a bit. Right click whatever string you are writing that command as and select "Hex Display", which is what you want in order to send those hex commands. Once you do this, the "\n" values will show up in hex as well, but it doesn't look like you need those. Instead use the "CRC" command "38 37" and see how it works. You should be able to write the string you included above, in hex format without the \n, and receive the response that the manual says there.

 

Some alterations to that line might be needed based on the following:

  • Are you using RS232 or RS485? Change that address bit to "80" instead of "83" if RS232.
    • If RS485, make sure your address is "3" on the device. Is it's different then you'll have to alter the "83" to something else.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 2 of 42
(8,894 Views)

Hey James,

 

Thanks for the reply! It still doesn't seem to be working, but nonetheless I feel like I'm making progress. I am still getting a Timeout error. Does this Hex code look correct to you? All I did was type in the numbers in the READ PUMP STATUS command (without a \n), then click Hex Display to get the string you see there.

 

twistorrcode.PNG

 

 

0 Kudos
Message 3 of 42
(8,884 Views)

Also I am using RS232, so I switched that 83 to 80. Thanks for pointing that out.

0 Kudos
Message 4 of 42
(8,881 Views)

Your string is wrong. You need to enter the HEX value, not the ASCII equivalent. ex. hex 30 = "0", hex 32 = "2". What you need to see in your string is: 02 80... NOT 30 32 38 30..

0 Kudos
Message 5 of 42
(8,868 Views)

Just in case you didn't understand  my previous reply

 

  Command.png

 

In the future to create this string format, right click string and use "HEX Display". Also right click and under "Visible Items" select "Display Style"

 

NOTE: You will still run into problems using this snippet. This command is only valid for address "83" If you change the address to "80", then you will have to recalculate the CRC.

Message 6 of 42
(8,856 Views)

Ohhhhhh I think it just clicked for me. I understand what you said about not wanting the ASCII equivalent. You're saying the CRC is not the same if I switch 83 with 80. In the manual I notice it says the CRC is the XOR of all characters subsequent. What does XOR mean in this case? I haven't really done much hex stuff if you couldn't tell already, but I feel like we are so close to gettting this working.

0 Kudos
Message 7 of 42
(8,846 Views)

@jamiva wrote:

Also right click and under "Visible Items" select "Display Style"


Holy canole! I wish I had known that visible type option was there before today. It would have saved quite a number of headaches with a recent project where I was communicating with multiple devices with command sets written in hex and '\'.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 8 of 42
(8,844 Views)

@super_strong_dragons_n_stuff wrote:

Ohhhhhh I think it just clicked for me. I understand what you said about not wanting the ASCII equivalent. You're saying the CRC is not the same if I switch 83 with 80. In the manual I notice it says the CRC is the XOR of all characters subsequent. What does XOR mean in this case? I haven't really done much hex stuff if you couldn't tell already, but I feel like we are so close to gettting this working.


 

 

I'm not sure if there's an easier way when you have a bunch of strings, but this is an example of an XOR calculation with hex values:

Hex Checksum.png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 9 of 42
(8,839 Views)

@super_strong_dragons_n_stuff wrote:

Also I am using RS232, so I switched that 83 to 80. Thanks for pointing that out.


The message from the device is probably not 64 bit long, but you are trying to read this number of bytes, so the read operation will wait for '\n' (I guess the default termination character is ASCII 0x0A; line feed) or 64 bytes. This is the reason why you see the timeout.

Use the 'Configure Serial Port' VI to set the termination character to 0x03 (ETX) and enable it. Then use two read command in a row.

  • The first read command (you may set the the 'bytes to read' to some big number, i.e. 64) will read the reply, including to ETX
  • The second read command should be used with 'bytes to read'=2 so that you can read also the checksum

 

 BTW: NI IO Trace is a very good tool for debugging serial communication problems. Check the 'Start' menu / National Instruments

Message 10 of 42
(8,835 Views)