├── .gitattributes ├── README.md ├── find_device.py ├── keithley_plotter.py └── one_shot.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # keithley2700-tutorial 2 | Python scripts for Keithley 2700 tutorial video 3 | To best use this set of code, first make sure to find the GPIB address of your device using the find_device.py 4 | From there, you can then use the one_shot.py script to make a one shot measurement from the keithley 2700. 5 | If everything is all good and working fine, use keithley_plotter.py as an example for live plotting. 6 | 7 | -------------------------------------------------------------------------------- /find_device.py: -------------------------------------------------------------------------------- 1 | import pyvisa 2 | 3 | print(pyvisa.ResourceManager().list_resources()) 4 | 5 | -------------------------------------------------------------------------------- /keithley_plotter.py: -------------------------------------------------------------------------------- 1 | import pyvisa 2 | import time 3 | import matplotlib.pyplot as plt 4 | 5 | 6 | # Initialize the keithley and create some useful variables 7 | multimeter = pyvisa.ResourceManager().open_resource('GPIB0::1::INSTR')# Connect to the keithley and set it to a variable named multimeter. 8 | multimeter.write(":ROUTe:CLOSe (@101)") # Set the keithley to measure channel 1 of card 1 9 | multimeter.write(":SENSe:FUNCtion 'TEMPerature'") # Set the keithley to measure temperature. 10 | timeList = [] # Create an empty list to store time values in. 11 | temperatureList = [] # Create an empty list to store temperature values in. 12 | startTime = time.time() # Create a variable that holds the starting timestamp. 13 | 14 | # Setup the plot 15 | plt.figure(figsize=(10,10)) # Initialize a matplotlib figure 16 | plt.xlabel('Elapsed Time (s)', fontsize=24) # Create a label for the x axis and set the font size to 24pt 17 | plt.xticks(fontsize=18) # Set the font size of the x tick numbers to 18pt 18 | plt.ylabel('Temperature ($^\circ$C)', fontsize=24) # Create a label for the y axis and set the font size to 24pt 19 | plt.yticks(fontsize=18) # Set the font size of the y tick numbers to 18pt 20 | 21 | 22 | # Create a while loop that continuously measures and plots data from the keithley forever. 23 | while True: 24 | temperatureReading = float(multimeter.query(':SENSe:DATA:FRESh?').split(',')[0][:-2]) # Read and process data from the keithley. 25 | temperatureList.append(temperatureReading) # Append processed data to the temperature list 26 | timeList.append(float(time.time() - startTime)) # Append time values to the time list 27 | time.sleep(0.5) # Interval to wait between collecting data points. 28 | plt.plot(timeList, temperatureList, color='blue', linewidth=10) # Plot the collected data with time on the x axis and temperature on the y axis. 29 | plt.pause(0.01) # This command is required for live plotting. This allows the code to keep running while the plot is shown. 30 | -------------------------------------------------------------------------------- /one_shot.py: -------------------------------------------------------------------------------- 1 | import pyvisa 2 | 3 | multimeter = pyvisa.ResourceManager().open_resource('GPIB0::1::INSTR') # Connect to the keithley and set it to a variable named multimeter. 4 | 5 | #multimeter.write(":ROUTe:CLOSe (@101)") # Set the keithley to measure channel 1 of card 1 6 | 7 | multimeter.write(":SENSe:FUNCtion 'TEMPerature'") # Set the keithley to measure temperature 8 | 9 | #print(multimeter.query(':SENSe:DATA:FRESh?')) # Collect the most recently measured data 10 | 11 | multimeter.write(":ROUTe:OPEN:ALL") # Open all card channels and thereby set the keithley to measure the front panel inputs. 12 | 13 | print(multimeter.query(':SENSe:DATA:FRESh?')) # Collect the most recently measured data --------------------------------------------------------------------------------