OE-FET / keithley2600

Python driver for Keithley 2600 series instruments.
https://keithley2600.readthedocs.io
MIT License
43 stars 17 forks source link

Small addition to allow context managers #23

Open orgua opened 2 years ago

orgua commented 2 years ago

main problem I had: faulty scripts leave the SMU in a weird state - so restarting the script often fails at basic tasks (like accessing keithley.smua) because the TSP-Commant-Set wasn't read successfully (or other weird behavior).

i added the option to use this module in a context and haven't had the problem since. This way of accessing remote devices allows to automatically disconnect on exceptions.

with Keithley2600(f"TCPIP0::{smu_ip}::INSTR") as kth:
    kth.reset()
    smu = kth.smua
    smu.sense = smu.SENSE_REMOTE
    smu.source.limiti = current_A
    smu.source.autorangev = smu.AUTORANGE_ON
    smu.source.func = smu.OUTPUT_DCVOLTS
    smu.measure.autozero = smu.AUTOZERO_AUTO
    smu.measure.autorangei = smu.AUTORANGE_ON
    smu.measure.nplc = 16
    smu.source.levelv = voltage_V
    smu.source.output = smu.OUTPUT_ON
orgua commented 2 years ago

Sorry, i got no notification about new messages in this thread :( I added a doc-string and extended the main readme with the example.

orgua commented 10 months ago

Any chance that it gets ever mainlined? It's a small but helpful feature for cleaner and more pythonic code.

orgua commented 3 months ago

Is there a reason to stall this? Your requested changes were implemented almost 2 years ago. i rather prefer that this PR is closed if it is unwanted so I can delete my fork.