Reputation: 1
I connected the string pot to the agilent data logger and am trying to read the change in resistance from moving the position of the string.
import numpy as np
import pyvisa as visa
import time
from datetime import datetime, date
import pandas as pd
import matplotlib.pyplot as plt
import time
import threading
import signal
instrument_address = 'USB0::0x0957::0x0507::MY50000230::0::INSTR' #Data logger address
If I read the displacement directly from the agilent display I am getting the linear change in ohms. If I do it through the python script it changes to voltage and I am just getting a signal that rises and goes back to zero (it looks like it is showing relative displacement).
Does someone know how to get the output in ohms?
def instrument(instrument_address: str,
instrument_access_protocol_name: str) -> object() :
rm = visa.ResourceManager()
instrument_access_protocol_name =
rm.open_resource(instrument_address)
instrument_access_protocol_name.write('*RST')
instrument_access_protocol_name.write('*CLS')
instrument_access_protocol_name.write(':DISPlay:STATe %d' % (0))
instrument_access_protocol_name.timeout = 10000
return instrument_access_protocol_name
SP_ch = '3001:3002' #channels to read
SP_alfa = '1'
SP_resistance = '1'
instrument_name = 'my_instrument'
my_instrument = instrument(instrument_address, instrument_name)
#channel list defined
def Scan_list(my_instrument: str, Channel_list: list):
Channel_list = str(Channel_list)
Channel_list =
Channel_list.replace('[','').replace(']','').replace('','')
separator = ''
Scan_Channel_list = separator.join(['@',Channel_list])
my_instrument.write(':ROUTe:SCAN (%s)' % (Scan_Channel_list))
print('\n\nSetting up automated scan')
print(':ROUTe:SCAN (%s)' % (Scan_Channel_list))
my_instrument.query_ascii_values('READ?')
class SP:
def __init__(self, instrument: str, SP_alfa: str, SP_resistance:
str, SP_ch: str):
self.instrument = instrument
self.SP_alfa = SP_alfa
self.SP_ch =''
self.SP_ch = self.SP_ch.join(['@', SP_ch])
self.SP_resistance = SP_resistance
self.configureSP()
self.senseSP()
def configureSP(self):
self.instrument.write('CONF:RES %s,%s' % (self.SP_ch, self.SP_resistance))
print('\nString Pot configuration')
print('CONF:RES %s,%s' % (self.SP_ch, self.SP_resistance))
def senseSP(self):
self.instrument.write(':SENSe:RESistance:OCOMpensated %d,%s' % (1, self.SP_ch))
self.instrument.write(':SENSe:RESistance:RANGe %G,%s' % (10000.0, self.SP_ch))
self.instrument.write(':SENSe:RESistance:RESolution %s,%s' % ('DEFault', self.SP_ch))
self.instrument.write(':SENSe:RESistance:ZERO:AUTO %s,%s' % ('ON', self.SP_ch))
Upvotes: 0
Views: 34