{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Instrument Interfaces\n\nEvery instrument interfaces inherits a common state model,\nand an interface abstraction for a kind of service that instrument\nmay provide.\n\nEvery instrument has it's own submodule by its make and model,\nand interfaces for that instrument art imported through\nthat submodule.\n\nDifferent instruments can be used for the same measurement\nby swapping import statements.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from rminstr.instruments.HP3458A import Voltmeter" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Every interface in this package adheres to a common state\nmodel. Flow control often looks like this:\n\n1. Connect to instrument with the class and a VISA address.\n2. Bring to a safe initial state ``initial_setup()``.\n3. Adjust settings with ``setup``.\n4. Arm the instrument with ``arm``.\n5. Trigger the instrument with ``trigger``.\n6. Wait for data to be ready with ``wait_until_data_available``.\n7. Fetch data with ``fetch_data``.\n8. Back to step 3.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "vm = Voltmeter('GPIB0::16::INSTR')\nvm.initial_setup()\nvm.setup(v_range=1)\nvm.arm()\nvm.trigger()\nvm.wait_until_data_available(timeout=10)\n\n# Return a dictionary of numpy arrays.\ndata = vm.fetch_data()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Query an instruments state\nas needed\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "vm.query_state()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Close out the connection when you are done.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "vm.close()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.4" } }, "nbformat": 4, "nbformat_minor": 0 }