LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview program to measure lock-in data not working

Solved!
Go to solution

I have written a program in Labview for storing in a text file all 4 data signals (Vx,Vy,Vr,Theta) which are displayed on the panel of my SR865A Lock-in Amplifier. The SR865A is connected to my PC via Keithley 488B GPIB cable.The snapshot of the block diagram of the program is attached below. But everytime I run the program, I get an ERR(6) from the GPIB READ command of my program. The available commands are OUTR?x, OUTP?x, SNAP?x,y,r and SNAPD?. The first three are used to give single data output i.e. data pertaining to a single parameter, but each shows the same error ERR(6). SNAPD? however shows only the x channel data while it should show a string containing data from all 4 panels at a single instant.  

 

Can someone tell me why the error is showing and why SNAPD? is not working?

0 Kudos
Message 1 of 5
(2,869 Views)

Why do you have a Request service in your code? You are not setting the SRQ bits in the snippet, nor are you clearing anything after the service request. Try something simple like this below, use the right address.

 

Snap26.png

 

I suggest you use VISA functions instead of GPIB, it is more future proof.

 

Your code seems a bit Rube-Goldberg. Why are you updating the current in your loop, it never changes? Why aren't you using numbers for frequency? Use numbers and convert to string for your command, rather than start with a string and constantly convert to a number.

 

mcduff

Message 2 of 5
(2,824 Views)
Solution
Accepted by topic author anik97

The other reason you are only getting 1 value from SNAPD? is that you are converting the string to a SINGLE number.

 

Here's something quick, not posting the VI, by recreating it will help you learn. Remember to change the VISA address to the address of your instrument.

 

Snap27.png

mcduff

Message 3 of 5
(2,816 Views)

Thanks a lot, mcduff. I changed the program as per your advice. Guess what it worked straight. The program is attached below, in case someone requires it.

0 Kudos
Message 4 of 5
(2,779 Views)

Glad to help.

 

Attached is a "mock-up" of how you can improve your VI.

 

Snap33.png

  1. When you allocate your array before the loop, the memory burden is much smaller. In your current loop, a new array has to be allocated because the size is changing.
  2. Since you have a fixed number of points a for loop is a better choice than a while loop.
  3. Adding a stop button is nice in case you want to the program to stop gracefully before all your points are scanned.
  4. You have a time delay of 6 seconds after your change the frequency, autorange, and autoscale. You have a time wait of 8 seconds in loop. Get rid of the time wait and make your delay 8 seconds if you want your loop to run at that rate. It is not good to have multiple time delays in the same loop.
  5. After your loop finishes, that is, this function should be outside of the loop, add a close file VI. It is always good practice to close references.
  6. The VISA commands have an "Address out" terminal, you can use that. see below. Makes the wiring neater.

Snap34.png

  1. Rather than use an X-Y plot, you can a waveform graph, that way you don't need multiple copies of a frequency array. See below.

Snap35.png

mcduff

0 Kudos
Message 5 of 5
(2,764 Views)