Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cryomagnetics driver and examples LM500 helium level meter #396

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 176 additions & 0 deletions docs/examples/Cryomagnetics/LM_500.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "9daeb510-4d2f-4983-abc8-3810f5df1630",
"metadata": {},
"source": [
"# Example for Cyromagnetics Model LM-500 Helium Level meter"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "e28ca2c2-f89d-4782-a20a-17e4cb6f1e5d",
"metadata": {},
"outputs": [],
"source": [
"import qcodes as qc\n",
"from qcodes import Station, load_or_create_experiment, \\\n",
" initialise_database, Measurement\n",
"from qcodes.dataset.plotting import plot_by_id\n",
"from qcodes.utils.dataset.doNd import do1d"
]
},
{
"cell_type": "markdown",
"id": "0a75a0be-ab2e-4035-9aed-a4768ee80d4f",
"metadata": {},
"source": [
"# Import qcodes_contrib_drivers LM_500 driver"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "fe9332c5-2026-4388-8e39-46e172b79cab",
"metadata": {},
"outputs": [],
"source": [
"from qcodes_contrib_drivers.drivers.Cryomagnetics.LM_500 import LM_500"
]
},
{
"cell_type": "markdown",
"id": "03531e54-b2cb-443b-bc2e-1ed7c617f976",
"metadata": {},
"source": [
"# Connect to the instrument - this case GPIB"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "9d97e8aa-3845-40f8-b8f4-fa38e189f225",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The LM_500 level meter units have been set to cm.\n"
]
}
],
"source": [
"helvl = LM_500('helvl', address = 'GPIB0::7::INSTR')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "ca328c2c-9571-44ef-ade4-c48ad94a5329",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"helvl:\n",
"\tparameter value\n",
"--------------------------------------------------------------------------------\n",
"IDN :\t{'vendor': 'Cryomagnetics', 'model': 'LM-500', 'serial': '4681', '...\n",
"he_level :\tNone (cm)\n",
"timeout :\t5 (s)\n",
"units :\tcm \n"
]
}
],
"source": [
"helvl.print_readable_snapshot()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "61d041e2-0a42-4856-b7f8-7d1bf3096f8f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'cm'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"helvl.units()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "ec104881-b4bc-421e-8631-47cbeca8336e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-4.4"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"helvl.he_level()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9a0af95a-96db-4ea5-abbc-0aebf7137600",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "bcb0a562-6d62-4235-96ca-9fc252c872bf",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.10"
},
"nbsphinx": {
"execute": "never"
},
},
"nbformat": 4,
"nbformat_minor": 5
}
58 changes: 58 additions & 0 deletions src/qcodes_contrib_drivers/drivers/Cryomagnetics/LM_500.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This Python file uses the following encoding: utf-8

"""
Created on 11-2020
@author: Nath !
Updated by Elyjah <elyjah.kiyooka@cea.fr>, June 2022

"""

import time
from qcodes import VisaInstrument, validators as vals

class LM_500(VisaInstrument):
"""
This is the qcodes driver for the LM_500 Helium lvl monitor.
"""

def __init__(self, name, address, **kwargs):
super().__init__(name, address, terminator='\n', **kwargs)

idn = self.IDN.get()
self.model = idn['model']
print ('The LM_500 level meter units have been set to cm.')

self.add_parameter(name='he_level',
label = 'Measure Helium level as float',
get_cmd = self._get_float,
get_parser = float,
vals = vals.Numbers(),
unit = self._get_unit(),
docstring="Measure the helium level in the units defined by the user as a float without the units printed.")

self.add_parameter(name='units',
label = 'Set unit',
get_cmd = 'UNITS?',
get_parser = str,
set_cmd = self._set_unit,
set_parser = str,
vals=vals.Enum('cm','in','percent','%'),
initial_value = 'cm',
docstring="Get and set the units for measurement.")

def _set_unit(self, val:str)->None:
self.visa_handle.write('UNITS {}'.format(val))
self.he_level.unit = val

def _get_float(self)->float:
"""Parce the output of measure to strip the units off, and outputs just the value as a float.
"""
output = self.visa_handle.query('MEAS? 1')
units = self.visa_handle.query('UNITS?')
return float(output.replace(units,''))

def _get_unit(self)->str:
"""Gets units of measurements to add to parameter.
"""
return self.visa_handle.query('UNITS?')