From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Why isn't LabVIEW using the right termination character, while NI MAX does?

I believe my problem stems from the same problem as the threads I made here and here, which both involve problems with termination characters. I thought I solved this problem in the latter of those two, but I was wrong and I'm still very lost.

 

Right now I am trying to communicate with my SR720 LCR meter. Here is its manual. I can communicate with it perfectly in NI MAX. I send commands, query, etc, and it responds with correct data.

 

Now, I am trying to get it to work with my LV program. As an example that it is working perfectly in NI MAX, which I'll try to replicate in LV, here's what I do in NI MAX:

 

 

1: Write Operation (freq?)

Return Count: 5 bytes

2: Read Operation
Return Count: 2 bytes
3\n

3: Write Operation (freq2)

Return Count: 5 bytes

4: Write Operation (xall?)

Return Count: 5 bytes

5: Read Operation
Return Count: 30 bytes
G1C6.9126E-08,G1R2.6772E01,99\n

6: Write Operation (freq?)

Return Count: 5 bytes

7: Read Operation
Return Count: 2 bytes
2\n

This basically does the following: query the frequency, it returns "3", set the frequency to "2", then query the measurement value, it returns the correct value of the test capacitor I have in the machine, and then query the frequency again, which returns "2", as expected. This works perfectly.

 

Here's my program where I attempt to do the same thing:

 

TestSR720__newline.png

 

I'm using the correct VISA name. If I run this, it does change the value of the frequency, but the raw string I read in is "I1C9.9999E20,I1R9.9999E20,99", which is wrong (it's the same capacitor in there as 5 seconds ago when I did it with NI MAX). The manual says that this means "Invalid measurement, no measurement completed, A/D converter errors." I've added the delays just to make sure there's nothing going on with commands being entered too closely too each other (though it's really not necessary).

 

Now, what gets stranger is, if I instead of freq3, do freq3\n, it does return the correct value from the machine ("G2C6.7889E-08,G2R1.2804E00,99"), but it doesn't change the frequency, and the machine displays "SYN ERROR" on its screen.

 

If instead of freq3\n, I concatenate a line feed constant or a end of line constant onto the end of freq3, it changes the frequency but returns a garbage measurement (as for the VI snippet above). Concatenating a LF to the end of xall? as well does the same.

 

What's going on here? The manual says:

 

A command to the
SR715/720 consists of a four character command
mnemonic, arguments if necessary, and a
command terminator. The terminator may be
either a carriage return <cr> or linefeed <lf> on
RS232, or a linefeed <lf> or EOI on GPIB. No
command processing occurs until a command
terminator is received.

 

This seems like it should work then. Clearly NI MAX is inserting one of those automatically. Okay, but when I try it in LV, it doesn't work.

 

I've also tried the solution here, even though the page says it's probably not necessary, but it didn't work anyway, with either LF or the end of line constants.

 

Does anyone know what might be going on? This is very very frustrating. Thank you.

0 Kudos
Message 1 of 5
(3,703 Views)

I'm guessing you entered a '\n' in a string constant configured for 'normal' display.  See here for more info on display modes of strings.  

 

http://zone.ni.com/reference/en-XX/help/371361M-01/lvhowto/string_shortcut_menu_items/ 

0 Kudos
Message 2 of 5
(3,692 Views)

Thanks, I'll try to investigate that. Your link is broken for me, btw.

0 Kudos
Message 3 of 5
(3,683 Views)

If you look closely at your write data in MAX, it is NOT sending a termination character.  So you should remove the Line Feed constants from your write strings.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5
(3,680 Views)

Ok, after looking at the manual a little closer, I think you might be having an issue with how a Windows machine handles the End Of Line.  For Windows, EOL is actually 2 characters: Carriage Return and Line Feed.  According to that manual, it should not care.  But it might be the issue.

 

So what I recommend is to not use the EOL in the command strings.  Instead, let VISA add the termination character to all of the writes for you.  It makes life a little bit simpler.  There is a simple property that you set.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 5
(3,678 Views)