GithubHelp home page GithubHelp logo

yongxie-icmm / jisa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oe-fet/jisa

0.0 1.0 0.0 289.15 MB

Standardised instrument control, data handling and simple GUI creation library for making experiment control programs.

License: GNU Affero General Public License v3.0

Java 99.94% CSS 0.06%

jisa's Introduction

JISA - "Because no-one likes LabView"

JISA is a library that I created, here in the Cavendish Laboratory, because I really (really really really) do not like LabView. Not to mention they named their language "G" as if it's somehow comparable to C. This hubris cannot and will not stand.

In essence then, the purpose of JISA is to act as an alternative (and actually decent) means of creating experimental control systems. It comprises, largely, of three sections:

1. Standardised Instrument Control

JISA implements standard interfaces for each "type" of instrument, meaning that instruments are easily interchangeable. If we connect to a Keithley SMU and an Agilent SPA

// Connect to instruments
val keithley = K2600B(TCPIPAddress("192.168.0.5"))
val agilent  = Agilent4155X(GPIBAddress(20))

then JISA simply represents them as collections of SMU channels

// Get first channel from both instruments
val smuK = keithley.getChannel(0)
val smuA = agilent.getChannel(0)

meaning that operating them is done exactly the same way in JISA regardless of which make/model of instsrument they are from

smuK.setIntegrationTime(0.1)     // Set the integration time
smuK.useAutoRanges()             // Use auto ranging on current and voltage
smuK.setVoltage(5.0)             // Set to source 5.0 V
smuK.turnOn()                    // Enable output of channel
val currentK = smuK.getCurrent() // Measure current
smuK.turnOff()                   // Disable output of channel

smuA.setIntegrationTime(0.1)     // Set the integration time
smuA.useAutoRanges()             // Use auto ranging on current and voltage
smuA.setVoltage(5.0)             // Set to source 5.0 V
smuA.turnOn()                    // Enable output of channel
val currentA = smuA.getCurrent() // Measure current
smuA.turnOff()                   // Disable output of channel

2. Data Handling

// Create results storage
val results = ResultList("Voltage", "Current", "Temperature")

// Take 10 readings
repeat(10) {
    results.addData(smu.getVoltage(), smu.getCurrent(), tc.getTemperature())
}

// Easy output as CSV file
results.output("data.csv")  

3. GUI Building Blocks

// Create user-input panel
val params = Fields("Parameters")

// Add input fields to it
val minV = params.addDoubleField("Min V [V]", 0.0)
val maxV = params.addDoubleField("Max V [V]", 60.0)
val numV = params.addIntegerField("No. Steps", 61)

// Create plot
val plot = Plot("Results", "Voltage", "Current")

// Add panel and plot to a grid
val grid = Grid("Main Window", params, plot)

// Add start button to toolbar
grid.addToolbarButton("Start Sweep") {

    // Makes range starting at minV, ending at maxV in numV steps
    val voltages = Range.linear(
        minV.get(),   // Start at
        maxV.get(),   // End at
        numV.get()    // No. steps
    )   
    
    // Code to run sweep
    
}

// Show the grid in a window
grid.show()

JISA the Polyglot

JISA is written in Java, but because Java is all about magic beans, you can actually use it in almost any language. More specifically, any language that can either be compiled to java byte-code or interpreted by a Java program (so basically anything) can use the library.

For example, here's the same program written in Java, Kotlin, Python and even gosh-darn MATLAB:

Java - Classic style, robust but verbose, like a northern grandparent.

public class Main {

    public static void main(String[] args) throws Exception {

        SMU         smu     = new K2450(new GPIBAddress(0, 20));
        ResultTable results = new ResultList(new Col("Voltage", "V"), new Col("Current", "A"));

        smu.setVoltage(0.0);
        smu.turnOn();

        for (double v : Range.linear(0, 60, 61)) {

            smu.setVoltage(v);
            Util.sleep(500);
            results.addData(smu.getVoltage(), smu.getCurrent());

        }

        smu.turnOff();
        results.output("data.csv");

    }

}

Kotlin - Slick, simplified and concise without rocking the boat

fun main() {

    val smu     = K2450(GPIBAddress(0,20))
    val results = ResultList(Col("Voltage", "V"), Col("Current", "A"))

    smu.setVoltage(0.0)
    smu.turnOn()

    for (v in Range.linear(0.0, 60.0, 61)) {
    
        smu.setVoltage(v)
        Util.sleep(500)
        results.addData(smu.getVoltage(), smu.getCurrent())
        
    }
    
    smu.turnOff()
    results.output("data.csv")

}

Python (Jython) - "Screw your traditions, I'm a snake from the future"

To use in Python, take a look at PyJISA here.

def main():
    
    smu     = K2450(GPIBAddress(0,20))
    results = ResultList([Col("Voltage", "V"), Col("Current", "A")])

    smu.setVoltage(0.0)
    smu.turnOn()
    
    for v in Range.linear(0.0, 60.0, 61):
    
        smu.setVoltage(v)
        Util.sleep(500)
        results.addData([smu.getVoltage(), smu.getCurrent()])
    
    
    smu.turnOff()
    results.output("data.csv")


main()

MATLAB - Why?

function main()
    
    smu     = jisa.devices.K2450(JISA.Addresses.GPIBAddress(0,20));
    results = jisa.experiment.ResultList({'Voltage', 'Current'});

    results.setUnits({'V', 'A'});    

    smu.setVoltage(0.0);
    smu.turnOn();
    
    for v=jisa.maths.Range.linear(0.0, 60.0, 61)
    
        smu.setVoltage(v);
        jisa.Util.sleep(500);
        results.addData([smu.getVoltage(), smu.getCurrent()]);
        
    end
    
    smu.turnOff();
    results.output('data.csv');
    
end

We can then extend this program easily, with only two lines, to display a plot of the results as they come in. Taking the example in Kotlin:

fun main() {

    val smu     = K2450(GPIBAddress(0,20))
    val results = ResultList(Col("Voltage", "V"), Col("Current", "A")) 

    // Make a plot that watches our results
    val plot = Plot("Results", results)
    plot.show()

    smu.setVoltage(0.0)
    smu.turnOn()

    for (v in Range.linear(0.0, 60.0, 61)) {
    
        smu.setVoltage(v)
        Util.sleep(500)
        results.addData(smu.getVoltage(), smu.getCurrent())
        
    }
    
    smu.turnOff()
    results.output("data.csv")

}

Resulting in:

Supported Instruments

Currently Implemented Devices:

Model Type Class
Keithley 236 SMU (Single-Channel) K236
2400 Series SMU (Single-Channel) K2400
2450 SMU (Single-Channel) K2450
2600B Series SMU (Multi-Channel) K2600B
6430 SMU (Single-Channel) K6430
2200 DC Power Supply K2200
2182 Voltmeter K2182
Oxford Instruments ITC-503 Temperature Controller ITC503
IPS-120 Magnet Controller IPS120
ILM-200 He Level Meter ILM200
Lake Shore 336 Temperature Controller LS336
Stanford Research SR830 Lock-In Amplifier SR830
SR560 Voltage Pre-Amp SR560
Eurotherm 2408 Temperature Controller ET2408
Pico Technology USB-TC08 Thermometer (Multi-Channel) USBTC08

Prerequisites

Before being able to use JISA, you will need the Java Development Kit (JDK) 11 or newer installed.

Linux

Either you'll already have OpenJDK installed or you simply need to run something like:

sudo apt install openjdk-11-jdk

Windows and MacOS X

You can download pre-built OpenJDK packages (with installers) from the Adopt Open JDK website:

https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot

Using JISA

You can use JISA in your project simply by including the JISA.jar file as a library. This will work so-long as your project uses Java 11 or newer.

If using IntelliJ IDEA, this means adding JISA.jar to your project directory and, inside IDEA, right-clicking on it then selecting "Add as Library..."

jisa's People

Contributors

wuhrlwuhrd avatar leszekspalek avatar martinstatz avatar wawood avatar

Watchers

James Cloos avatar

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.