Git Product home page Git Product logo

labinstruments's Introduction

LabInstruments

PyVISA wrappers for some of my lab instruments: Rigol DL3021, Agilent DSO-X 3024

Note: I use a USB connection to all of those instruments and use pyvisa-py as a backend driver on Linux. Getting the connection to work is the sole responsibility of PyVISA

Note: This project does not aim to be complete for any instrument, but I just add whatever function I want to try out, or need to use for some project. If you need to use other functions please submit a pull request or an issue if you have no idea of how to implement it. Refer to the programming manual of your instrument for details on the commands available.

Installation

On Debian/Ubuntu:

sudo apt -y install python3-dev python3-pip python3-usb
sudo pip3 install pyvisa pyvisa-py

Now you can clone LabInstruments:

git clone https://github.com/ulikoehler/LabInstruments.git

You also need to find the PyVISA ID of your instrument:

python3 LabInstruments/IdentifyInstruments.py

If you've setup your hardware & PyVISA installation correctly (see Installation above for PyVISA & ensure that your instrument is plugged in and turned on), you will see information like

Trying to open resource:  USB0::6833::3601::DL3A204100212::0::INSTR
        It's a RIGOL TECHNOLOGIES DL3021 with serial DL3A204100212

The PyVISA ID in this example is USB0::6833::3601::DL3A204100212::0::INSTR.

If it's telling you No PyVISA resources found, try to re-run it as root using sudo! If that works and you are using an instrument connected via USB or via USB adapter, refer to How to fix ALL USB permission issues on Linux once and for all.

Usage example

This example connects to a Rigol DL3021 and configures it correctly.

Be sure to insert your specific PyVISA ID in the example!

Place this script in the directory where the LabInstruments directory is located.

#!/usr/bin/env python3
import pyvisa
from LabInstruments.DL3000 import DL3000

rm = pyvisa.ResourceManager()
inst = DL3021(rm.open_resource('USB0::6833::3601::DL3A204100212::0::INSTR'))
# Reset to factory settings (always do this to ensure a 100% consistent state)
inst.reset()

inst.set_mode("CURRENT") # CC
inst.set_cc_current(0.850) #A
inst.enable() # Switch ON
# Read voltage
print("{} V".format(inst.voltage()))
inst.disable() # Switch OFF

I recommend you add LabInstruments to your project as a git submodule:

git submodule init
git submodule add https://github.com/ulikoehler/LabInstruments.git LabInstruments

Troubleshooting

PyVISA doesn't find your device? Refer to How to fix PyVISA not finding any USB instruments

Got a Found a device whose serial number cannot be read. The partial VISA resource name is ... error? Refer to How to fix PyVISA ‘Found a device whose serial number cannot be read. The partial VISA resource name is: USB0::[…]::[…]::???::0::INSTR’

labinstruments's People

Contributors

ulikoehler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

labinstruments's Issues

Problem with connecting using Ubuntu

Hi,

I tested your code using windows 10, after installing the NI-Visa drivers, I was able to connect my RIGOL DL3021 and communicate with my device. Somehow, after changeing my OS into Ubuntu 22.04, I can not communicate with my device. The error which I get says: "ValueError: No device found" and obviously it can not find any resources. I just want to know if I have to install any specific driver or package for using the code on ubuntu?

Thank you in advance for your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.