01-31-2017 08:50 AM
Hi again,
Sorry I am getting same Error (error56).
This time I changed the command to send from *IDN? to *OPC? and I am expected to get number 1 in response. this command is used to see if the instrument has finished the measurement or not and if it is finished the response it 1. Althought I get 1 after the error appeares, still this error shows. I have attached the code, which is same for both commands and changing the command results in the error.
Do you know if I need to change anything or do I need to ignore the error?
01-31-2017 09:45 AM
@basetgh wrote:
Hi again,
Sorry I am getting same Error (error56).
This time I changed the command to send from *IDN? to *OPC? and I am expected to get number 1 in response. this command is used to see if the instrument has finished the measurement or not and if it is finished the response it 1. Althought I get 1 after the error appeares, still this error shows. I have attached the code, which is same for both commands and changing the command results in the error.
You're still getting a timeout error on your TCP READ. It's either not sending the right termination character (\n) or you don't have your read configured correctly.
Can you right click the "data out" indicator, and select '\' Codes Display so that it look something like this. Run it again and see what it actually sends.
01-31-2017 12:08 PM
No same error. I have just changed the command that I want to send and it is just the output that has changed ( response from the instrumnet) otherise if I change the command to *IDN? instead of *OPC? the output is perfect.
01-31-2017 12:56 PM
Could fix it using line feed constant. now I changed my command and return is a number (1). again I get same error. I am wondering why the code worked for *IDN? commandand returned the name of the instrument but didnt work for *OPC? which returens a number after the completion of the measurement.
02-01-2017 04:33 AM
In NIMAX I have enabled Termination Character and set it on Line Feed - \n
when I send *OPC\n it returens 1\n with no error or timeout.
in the Labview it does the same and returens with timeout error.
02-01-2017 06:01 AM
@basetgh wrote:
In NIMAX I have enabled Termination Character and set it on Line Feed - \n
when I send *OPC\n it returens 1\n with no error or timeout.
in the Labview it does the same and returens with timeout error.
OK. Now I know that you receive ONLY a "\n" for the termination character.
Using TCP raw sockets is a little tricky. Here is why (from LabVIEW help). The "mode" only has 4 behaviors. Three of them are a variations of reading a number of bytes and timeouts. The other one, Mode 2, is the closest BUT is waits for a carriage return followed by a line feed (\r\n). None of them match what 99% of instruments send, including your instrument, which is ONLY a line feed (\n). None of them will work for you as-is.
I don't know why you are using raw sockets vs. VISA. I only had a few rare instances where I was required to use them, so I needed to write my own READ VI since the CRLF mode only terminated on BOTH the \r and \n. It basically is a wrapper that reads one byte at a time and exits the loop when it receives a \n. Here is what it look like.
If you can, I would suggest using VISA instead. It's much easier to implement and can be configured to your comms needs. Guilherme showed you how to do it in NI Max. Here is how you can do it programmatically.
02-01-2017 08:36 AM
Here is a working version using VISA. It builds your resource on-the-fly so you don't need to create it in NI MAX. The read throws a "Warning" Code 1073676293 in the Error Cluster. The warning indicates that the READ stopped due to the TermChar being read. You can either ignore it, or clear it. It will not affect any further operations.