LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LAN Communication with another software (Instrument)

Solved!
Go to solution

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?

 

 

Download All
0 Kudos
Message 11 of 17
(1,461 Views)

@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.

 

indicator w_codes.JPG

0 Kudos
Message 12 of 17
(1,448 Views)

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.

0 Kudos
Message 13 of 17
(1,441 Views)

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.

 

0 Kudos
Message 14 of 17
(1,431 Views)

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.

 

0 Kudos
Message 15 of 17
(1,412 Views)

@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.

TCP Read (mode).JPG

 

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.

tcp read wrapper.png

 


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.

Prog config.JPG

0 Kudos
Message 16 of 17
(1,403 Views)

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.

 

VISA_READ_WRITE (Socket).png

0 Kudos
Message 17 of 17
(1,385 Views)