1

I am using pymeasure to extract results from a device connected via GPIB to my computer, a Lock-In amplifier (which can generate voltage in a sine wave and measure AC voltage in reference to frequency). Using the pymeasure package, I am trying to extract two values from the device, magnitude and phase, using code similar to this:

from pymeasure.instruments.srs import SR830
from time import sleep



LI = SR830("GPIB address")

LI.reference_source="Internal"
LI.frequency=668.4
        #LI.time_constant=4/LI.frequency
sleep(3*LI.time_constant)
LI.auto_gain()
    
sleep(10)
#these throwaways are there to get rid of data dumps that sometimes occur in lockin (not sure why?)
throwaway=LI.magnitude
throwaway2=LI.magnitude

def lock_in_test(repeats=1):
   
    itr=0
    while itr<repeats:
        # self.LI.auto_gain()
        # sleep(10)
        # self.get_measurements([0,0],'r')
        res=LI.magnitude
        sleep(3)
        phase=LI.phase
        print(f"mag={res},phase={phase}")
        sleep(1)
        itr+=1

lock_in_test(10)

I expect to get results of order 0.1 for phase at the setup I am using, as shown on the device's screen, and about 7e-6 for magnitude. However, the results I get are:

mag=9.0,phase=7.67835e-06
mag=7.67788e-06,phase=7.67788e-06
mag=10.37,phase=7.70722e-06
mag=10.37,phase=7.61545e-06
mag=10.37,phase=7.73097e-06
mag=10.37,phase=7.68859e-06
mag=10.37,phase=7.67648e-06
mag=10.37,phase=7.69558e-06
mag=10.37,phase=7.65413e-06
mag=10.37,phase=7.68114e-06

Which has two problems:

  1. it appears to keep repeating the same (wrong) value for magnitude from some point,
  2. it appear to read the magnitude when calling LI.phase

when commenting out the LI.phase line, the results for magnitude become reasonable. I already tried slowing down the GPIB bus speed, as suggested in some forums. Why is this happening? is this the result of some internal memory of the Lock-in amplifier? if so, how can I fix this problem?

0

Browse other questions tagged or ask your own question.