06-25-2015 12:16 PM - edited 06-25-2015 12:24 PM
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.
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!
06-25-2015 12:31 PM
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:
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-25-2015 01:23 PM
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.
06-25-2015 01:24 PM
Also I am using RS232, so I switched that 83 to 80. Thanks for pointing that out.
06-25-2015 01:33 PM
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..
06-25-2015 01:45 PM
Just in case you didn't understand my previous reply
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.
06-25-2015 02:00 PM
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.
06-25-2015 02:02 PM
@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> ---'
06-25-2015 02:05 PM - edited 06-25-2015 02:05 PM
@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:
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-25-2015 02:06 PM - edited 06-25-2015 02:09 PM
@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.
BTW: NI IO Trace is a very good tool for debugging serial communication problems. Check the 'Start' menu / National Instruments