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