Git Product home page Git Product logo

sci_instr's Introduction

sci_instr

Module to communicate with scientific instruments via a VISA connection. Hide actual commands (e.g. SCPI) in a yaml file and access instrument features via automatically generated class properties.

Purpose

Instead of a lot of SCPI commands that you have to memorize or look up and that clutter the code:

osc.write(':CHAN4:POS 0') 
osc.write(':TRIG:LEV4 0.6')
points = osc.query(':ACQuire:POINts')

use class properties for easier access and setting of instrument properties:

osc.ch4_position = 0
osc.ch4_triglvl  = 0.6
points = osc.points

Prerequisites

You will need pyvisa (https://pyvisa.readthedocs.io/en/stable/), yaml and numpy (e.g. via anaconda https://www.continuum.io/downloads)

How to use

For usage of an existing instrument you need to import visa and the instrument class you want to use.

import visa
from sci_instr.oscilloscope import RS_RTO1044

Then generate a visa resource manager and use it in combination with the visa address of your instrument to create an instance of the instrument.

rm = visa.ResourceManager()
osc = RS_RTO1044(rm,'TCPIP0::192.168.0.11::inst0::INSTR')

How to create new instruments

For minimal usage you need to create a yaml file with your instrument commands.

readOnlyProps contain all instrument properties that are only read and that may return an arbitrary string.

readWriteProps can be read and written to and return usually doubles (if post processing of instrument answers is needed you need a subclass of Instrument and define your own _process_read_values)

readBinaryTraces usually used to transfer larger datasets in binary formats using pyvisas query_values

Example: Create a yaml config file in config\Oscilloscopes\TestOsc.yaml:

readOnlyProps:
    name        : '*IDN'

readWriteProps:
    time_range  : :TIMebase:RANGe

readBinaryTraces:
    ch1_data    : :CHAN1:WAV1:DATA

To then use your instrument use the generic Instrument class and tell it which yaml file to use for creating the class properties:

import visa
import os
from sci_instr.generic import Instrument


osc = Instrument(rm,'TCPIP0::192.168.0.11::inst0::INSTR',conffile=os.path.join('Oscilloscopes','TestOsc.yaml'))

print(osc.name)
print(osc.time_range)

Authors

  • Tim Hellwig - Initial work -

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

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.