Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Python Programming for Keithley 6487

Solved!
Go to solution

Hello,

I try to write a skript to run my measurement on a Keithley 6487. To get comfortable I wrote a small skript to play around but have trouble with the readout of voltage and current. I have little experience in writing pyvisa code for Keithley 2600 series but not for this one. The user manual also does not help very much. In the following code when "(...)device.query('MEAS:VOLT?'))" is reached the error "ERR -133" gets thrown which I looked up in the manual but dont know how to continue from here. I hope you can help me. Im connected via RS-232 since its the only "to-usb-adapter"  I have at the lab here.

Thank you in advance

import pyvisa
import time
import csv

def test_keithley_6487():
    # Create a resource manager
    rm = pyvisa.ResourceManager()

    # List all connected resources
    ports = rm.list_resources()
    print("Available ports:", ports)

    # Output file for logging measurements
    output_file = "keithley_6487_measurements.csv"
   
    # Attempt to connect to the Keithley 6487
    for port in ports:
        try:
            # Open the resource
            device = rm.open_resource(port)
            print(f"Connected to device at {port}")

            # Query device identification
            idn = device.query('*IDN?')
            print("Device ID:", idn)

            # Set communication parameters (if necessary)
            device.baud_rate = 9600
            device.data_bits = 8
            device.parity = pyvisa.constants.Parity.none
            device.stop_bits = pyvisa.constants.StopBits.one
            device.timeout = 5000  # 5 seconds

            # Set and measure voltage and current in a loop
            for voltage in [1.0, 2.0, 3.0, 4.0, 5.0]:
                # Set the voltage
                device.write(f'SOUR:VOLT {voltage}')
                print(f"Set voltage to: {voltage} V")

                # Wait certain amount of time (e.g. 2 sec)
                print("Going to wait 2 seconds") # Debug
                time.sleep(2)

                # Measure voltage
                print("Trying to read voltage...")
                measured_voltage = float(device.query('MEAS:VOLT?'))
                print(f"Measured voltage to be {measured_voltage}") # Debug
               

                # Measure current
                print("Trying to read current...")
                measured_current = float(device.query('MEAS:CURR?'))
                print(f"Measured current to be {measured_current}") # Debug

            # Set voltage back to 0.0 V
            device.write('SOUR:VOLT 0.0')
            print("Voltage set back to 0.0 V")

            # Close the device connection
            device.close()
            break  # Exit loop after successful connection

        except Exception as e:
            print(f"Failed to communicate with device at {port}: {e}")

if __name__ == "__main__":
    test_keithley_6487()

 

0 Kudos
Message 1 of 7
(358 Views)

Essentially, you are using a command that the instrument does not support!

 

As per the programmer's manual, there is no command such as "MEAS:VOLT?" or "MEAS:CURR?"

 

Please read the manual and use only compatible commands.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 7
(290 Views)

Thank you for your reply..

I already looked into the manual regarding this and did not find the correct commands..

Is there a chance you would know where to find them?

Thank you

 

0 Kudos
Message 3 of 7
(280 Views)

@Desm333 wrote:

Thank you for your reply..

I already looked into the manual regarding this and did not find the correct commands..

Is there a chance you would know where to find them?

Thank you

 


Checkout chapter 3 from pg.43 onwards

santo_13_0-1738012784811.png

Here is an SCPI example from the manual,

santo_13_1-1738012832889.png

 

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 4 of 7
(255 Views)

With "READ?" I only receive the information on the current and not the applied voltage which was main issue..

Reading the current works totally fine with it though..

 

0 Kudos
Message 5 of 7
(248 Views)
Solution
Accepted by topic author Desm333

@Desm333 wrote:

With "READ?" I only receive the information on the current and not the applied voltage which was main issue..

Reading the current works totally fine with it though..

 


I bet the 6487 cannot measure the applied voltage back, unlike an SMU (at least based on the user manual).

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 6 of 7
(243 Views)

Then I wont bet against it.

Thank you very much.

 

0 Kudos
Message 7 of 7
(236 Views)