Commit 1c7c95a62f0 by YL

Commit: MMR3, MGC3 classes.

iMACRT usage example added.
parent 1a7b3e9b1b1
from pymanip import Session
from fluidlab.instruments.multimeter.mgc3 import MGC3
from fluidlab.instruments.multimeter.mmr3 import MMR3
import time
# Function used to get and echo the MMR3 *IDN?
def idmmr3():
with MMR3("192.168.1.18") as mmr3:
idr3 = mmr3.query_identification()
print("***********")
print("IDMMR3: " + str(idr3))
print("***********")
time.sleep(1)
pass
if idr3 != "":
return True
pass
else:
return False
pass
pass
# Function used to get and echo the MGC3 *IDN?
def idmgc3():
with MGC3("192.168.1.17") as mgc3:
idg3 = mgc3.query_identification()
print("IDMGC: " + str(idg3))
print("***********")
time.sleep(1)
pass
if idg3 != "":
return True
pass
else:
return False
pass
pass
# Function used to set up the MMR3
def setupmmr3():
with MMR3("192.168.1.18") as mmr3:
mmr3.r1_rangemode.set(0)
mmr3.r1_rangemode_i.set(0)
mmr3.r1_range_i.set(1)
mmr3.r1_i.set(0.00001)
time.sleep(1)
pass
pass
# Function used to set up the MGC3
def setupmgc3():
with MGC3("192.168.1.17") as mgc3:
mgc3.pid0_channel.set(0)
mgc3.pid0_prop.set(0.5)
mgc3.pid0_integral.set(0.01)
mgc3.pid0_res.set(100)
mgc3.pid0_maxpow.set(5)
mgc3.pid0_setpoint.set(33)
mgc3.pid0_onoff.set(1)
time.sleep(1)
pass
pass
def setpoint():
with MGC3("192.168.1.17") as mgc3:
sp = mgc3.pid0_setpoint.get()
return sp
pass
pass
# Function used to make a simple MMR3 measurement
def mesuremmr3():
with MMR3("192.168.1.18") as mmr3:
measr = mmr3.r1_convert.get()
return measr
pass
pass
# Function used to make a simple MGC3 measurement
def mesuremgc3():
with MGC3("192.168.1.17") as mgc3:
measg = mgc3.pid0_meas.get()
return measg
pass
pass
def main():
# Vars
basename = "demo"
# Echo IDN
chkr = idmmr3()
chkg = idmgc3()
# Make sure the instruments answer something
if chkr and chkg:
print("CONNECTION ESTABLISHED")
print("MEASURING WILL START...")
pass
# If not, exit program
else:
print("CONNECTION FAILED!")
print("ERR_OH_NO_IDN")
print("STOPPING PROGRAM...")
exit()
pass
# Start setup
print("***********")
print("SETTING UP MMR3")
setupmmr3()
print("***********")
print("SETTING UP MGC3")
setupmgc3()
# Start Session
# Where R1 = MMR3 meas and R2 = MGC3 meas
with Session(basename, ("T", "SP")) as MI:
print("**********")
print("START PLOT")
print("**********")
while True:
# Measurement
T = mesuremmr3()
SP = setpoint()
# Graph gen
MI.log_addline()
MI.log_plot(1, ("T", "SP"))
# Echo safety
print(T)
print(SP)
# Sleep until next meas
MI.sleep(1)
pass
if __name__ == "__main__":
main()
"""mgc3
============
.. autoclass:: MGC3
:members:
:private-members:
This class implements the MGC3 from the Institut Néel - VERSION 2.4
"""
from ipaddress import ip_address
from fluidlab.interfaces import PhysicalInterfaceType
from fluidlab.instruments.drivers import Driver
from fluidlab.instruments.features import (
QueryCommand,
WriteCommand,
FloatValue,
StringValue,
)
__all__ = ["MGC3"]
def out_port(ip):
"""
Out port is 12000 + last number of ip address
"""
ip = ip_address(ip)
return 12000 + (int(ip) & 0xFF)
class MGC3(Driver):
default_physical_interface = PhysicalInterfaceType.Ethernet
default_inter_params = {
"out_port": out_port,
"in_port": 12000,
"ethernet_protocol": "udp",
}
features = [
# Identification Query
QueryCommand("query_identification", "Identification Query", "*IDN?"),
# # # # # # # # # # # #
# Read-only commands #
# # # # # # # # # # # #
FloatValue("temperature", doc="MGC3 internal temperature", command_get="MGC3GET 0"),
# PID0 commands
FloatValue(
"pid0_meas",
doc="MGC3 PID_0 last measurement - in Kelvin",
command_get="MGC3GET 3",
),
FloatValue(
"pid0_s", doc="MGC3 PID_0 last watt measurement", command_get="MGC3GET 9"
),
FloatValue("pid0_status", doc="MGC3 PID_0 Status", command_get="MGC3GET 10"),
# PID1 commands
FloatValue(
"pid1_meas",
doc="MGC3 PID_1 last measurement - in Kelvin",
command_get="MGC3GET 15",
),
FloatValue(
"pid1_s", doc="MGC3 PID_1 last watt measurement", command_get="MGC3GET 21"
),
FloatValue("pid1_status", doc="MGC3 PID_1 Status", command_get="MGC3GET 22"),
# PID2 commands
FloatValue(
"pid2_meas",
doc="MGC3 PID_1 last measurement - in Kelvin",
command_get="MGC3GET 27",
),
FloatValue(
"pid2_s", doc="MGC3 PID_1 last watt measurement", command_get="MGC3GET 33"
),
FloatValue("pid2_status", doc="MGC3 PID_1 Status", command_get="MGC3GET 34"),
# Misc commands
FloatValue("i0_status", doc="MGC3 CH_0 Status", command_get="MGC3GET 38"),
FloatValue("i1_status", doc="MGC3 CH_1 Status", command_get="MGC3GET 40"),
FloatValue("i2_status", doc="MGC3 CH_2 Status", command_get="MGC3GET 42"),
FloatValue(
"user_voltage", doc="MGC3 Current user voltage", command_get="MGC3GET 43"
),
# # # # # # # # # #
# R+W commands #
# # # # # # # # # #
# PID0 commands
FloatValue(
"pid0_onoff",
doc="MGC3 PID 0, on (1) - off (0)",
command_get="MGC3GET 1",
command_set="MGC3SET 1",
pause_instrument=0.5,
),
FloatValue(
"pid0_setpoint",
doc="MGC3 PID 0, set wanted temperature (Kelvin)",
command_get="MGC3GET 2",
command_set="MGC3SET 2",
pause_instrument=0.5,
),
FloatValue(
"pid0_prop",
doc="MGC3 PID 0, proportional term",
command_get="MGC3GET 4",
command_set="MGC3SET 4",
pause_instrument=0.5,
),
FloatValue(
"pid0_integral",
doc="MGC3 PID 0, integral term",
command_get="MGC3GET 5",
command_set="MGC3SET 5",
pause_instrument=0.5,
),
FloatValue(
"pid0_deriv",
doc="MGC3 PID 0, derivative term",
command_get="MGC3GET 6",
command_set="MGC3SET 6",
pause_instrument=0.5,
),
FloatValue(
"pid0_maxpow",
doc="MGC3 PID 0, maximum power (W)",
command_get="MGC3GET 7",
command_set="MGC3SET 7",
pause_instrument=0.5,
),
FloatValue(
"pid0_res",
doc="MGC3 PID 0, Heat resistance value (Ohm)",
command_get="MGC3GET 8",
command_set="MGC3SET 8",
pause_instrument=0.5,
),
StringValue(
"pid0_name",
doc="MGC3 PID 0, measurement model name",
command_get="MGC3GET 11",
command_set="MGC3SET 11",
pause_instrument=1,
check_instrument_value=False,
),
FloatValue(
"pid0_channel",
doc="MGC3 PID 0, measurement channel",
command_get="MGC3GET 12",
command_set="MGC3SET 12",
pause_instrument=0.5,
),
# PID1 commands
FloatValue(
"pid1_onoff",
doc="MGC3 PID 1, on (1) - off (0)",
command_get="MGC3GET 13",
command_set="MGC3SET 13",
pause_instrument=0.5,
),
FloatValue(
"pid1_setpoint",
doc="MGC3 PID 1, set wanted temperature (Kelvin)",
command_get="MGC3GET 14",
command_set="MGC3SET 14",
pause_instrument=0.5,
),
FloatValue(
"pid1_prop",
doc="MGC3 PID 1, proportional term",
command_get="MGC3GET 16",
command_set="MGC3SET 16",
pause_instrument=0.5,
),
FloatValue(
"pid1_integral",
doc="MGC3 PID 1, integral term",
command_get="MGC3GET 17",
command_set="MGC3SET 17",
pause_instrument=0.5,
),
FloatValue(
"pid1_deriv",
doc="MGC3 PID 1, derivative term",
command_get="MGC3GET 18",
command_set="MGC3SET 18",
pause_instrument=0.5,
),
FloatValue(
"pid1_maxpow",
doc="MGC3 PID 1, maximum power (W)",
command_get="MGC3GET 19",
command_set="MGC3SET 19",
pause_instrument=0.5,
),
FloatValue(
"pid1_res",
doc="MGC3 PID 1, Heat resistance value (Ohm)",
command_get="MGC3GET 20",
command_set="MGC3SET 20",
pause_instrument=0.5,
),
StringValue(
"pid1_name",
doc="MGC3 PID 1, measurement model name",
command_get="MGC3GET 23",
command_set="MGC3SET 23",
pause_instrument=2,
),
FloatValue(
"pid1_channel",
doc="MGC3 PID 1, measurement channel",
command_get="MGC3GET 24",
command_set="MGC3SET 24",
pause_instrument=0.5,
),
# PID2 commands
FloatValue(
"pid2_onoff",
doc="MGC3 PID 2, on (1) - off (0)",
command_get="MGC3GET 25",
command_set="MGC3SET 25",
pause_instrument=0.5,
),
FloatValue(
"pid2_setpoint",
doc="MGC3 PID 2, set wanted temperature (Kelvin)",
command_get="MGC3GET 26",
command_set="MGC3SET 26",
pause_instrument=0.5,
),
FloatValue(
"pid2_prop",
doc="MGC3 PID 2, proportional term",
command_get="MGC3GET 28",
command_set="MGC3SET 28",
pause_instrument=0.5,
),
FloatValue(
"pid2_integral",
doc="MGC3 PID 2, integral term",
command_get="MGC3GET 29",
command_set="MGC3SET 29",
pause_instrument=0.5,
),
FloatValue(
"pid2_deriv",
doc="MGC3 PID 2, derivative term",
command_get="MGC3GET 30",
command_set="MGC3SET 30",
pause_instrument=0.5,
),
FloatValue(
"pid2_maxpow",
doc="MGC3 PID 2, maximum power (W)",
command_get="MGC3GET 31",
command_set="MGC3SET 31",
pause_instrument=0.5,
),
FloatValue(
"pid2_res",
doc="MGC3 PID 2, Heat resistance value (Ohm)",
command_get="MGC3GET 32",
command_set="MGC3SET 32",
pause_instrument=0.5,
),
StringValue(
"pid2_name",
doc="MGC3 PID 2, measurement model name",
command_get="MGC3GET 35",
command_set="MGC3SET 35",
pause_instrument=2,
),
FloatValue(
"pid2_channel",
doc="MGC3 PID 2, measurement channel",
command_get="MGC3GET 36",
command_set="MGC3SET 36",
pause_instrument=0.5,
),
# I commands
FloatValue(
"ch0_i",
doc="MGC3 CH0 change or get current",
command_get="MGC3GET 37",
command_set="MGC3SET 37",
pause_instrument=0.5,
),
FloatValue(
"ch1_i",
doc="MGC3 CH1 change or get current",
command_get="MGC3GET 39",
command_set="MGC3SET 39",
pause_instrument=0.5,
),
FloatValue(
"ch2_i",
doc="MGC3 CH2 change or get current",
command_get="MGC3GET 41",
command_set="MGC3SET 41",
pause_instrument=0.5,
),
# TTL commands
FloatValue(
"ttl_o1",
doc="MGC3 TTL output 1",
command_get="MGC3GET 44",
command_set="MGC3SET 44",
pause_instrument=0.5,
),
FloatValue(
"ttl_o2",
doc="MGC3 TTL output 2",
command_get="MGC3GET 45",
command_set="MGC3SET 45",
pause_instrument=0.5,
),
]
MGC3._build_class_with_features(features)
"""mmr3
============
.. autoclass:: MMR3
:members:
:private-members:
This class implements the MMR3 from the Institut Néel - VERSION 2.4
"""
from ipaddress import ip_address
from fluidlab.interfaces import PhysicalInterfaceType
from fluidlab.instruments.drivers import Driver
from fluidlab.instruments.features import (
QueryCommand,
WriteCommand,
FloatValue,
StringValue,
)
__all__ = ["MMR3"]
def out_port(ip):
"""
Out port is 12000 + last number of ip address
"""
ip = ip_address(ip)
return 12000 + (int(ip) & 0xFF)
class MMR3(Driver):
default_physical_interface = PhysicalInterfaceType.Ethernet
default_inter_params = {
"out_port": out_port,
"in_port": 12000,
"ethernet_protocol": "udp",
}
features = [
# Identification Query
QueryCommand("query_identification", "Identification Query", "*IDN?"),
# # # # # # # # # # # #
# Read-only commands #
# # # # # # # # # # # #
FloatValue("temperature", doc="MMR3 internal temperature", command_get="MMR3GET 2"),
# CH1 commands
FloatValue("r1_meas", doc="MMR3 R1 measurement result", command_get="MMR3GET 3"),
FloatValue("r1_range", doc="MMR3 R1 range computation", command_get="MMR3GET 4"),
FloatValue("r1_convert", doc="MMR3 R1 converted value", command_get="MMR3GET 5"),
FloatValue("r1_status", doc="MMR3 R1 measurement status", command_get="MMR3GET 6"),
FloatValue("r1_offset", doc="MMR3 R1 offset measurement", command_get="MMR3GET 13"),
# CH2 commands
FloatValue("r2_meas", doc="MMR3 R2 measurement result", command_get="MMR3GET 14"),
FloatValue("r2_range", doc="MMR3 R2 range computation", command_get="MMR3GET 15"),
FloatValue("r2_convert", doc="MMR3 R2 converted value", command_get="MMR3GET 16"),
FloatValue("r2_status", doc="MMR3 R2 measurement status", command_get="MMR3GET 17"),
FloatValue("r2_offset", doc="MMR3 R2 offset measurement", command_get="MMR3GET 24"),
# CH3 commands
FloatValue("r3_meas", doc="MMR3 R3 measurement result", command_get="MMR3GET 25"),
FloatValue("r3_range", doc="MMR3 R3 range computation", command_get="MMR3GET 26"),
FloatValue(
"r3_convert", doc="MMR3 MMR3 R3 converted value", command_get="MMR3GET 27"
),
FloatValue("r3_status", doc="MMR3 R3 measurement status", command_get="MMR3GET 28"),
FloatValue("r3_offset", doc="MMR3 R3 offset measurement", command_get="MMR3GET 35"),
# # # # # # # # # #
# R+W commands #
# # # # # # # # # #
FloatValue(
"periode",
doc="MMR3 Modulation period",
command_get="MMR3GET 0",
command_set="MMR3SET 0",
pause_instrument=0.5,
),
FloatValue(
"dtadc",
doc="MMR3 ADC delay",
command_get="MMR3GET 1",
command_set="MMR3SET 1",
pause_instrument=0.5,
),
# CH1 commands
FloatValue(
"r1_average",
doc="MMR3 R1 Amount of points in each measurement",
command_get="MMR3GET 7",
command_set="MMR3SET 7",
pause_instrument=0.5,
),
FloatValue(
"r1_rangemode",
doc="MMR3 R1 change mode",
command_get="MMR3GET 8",
command_set="MMR3SET 8",
pause_instrument=0.5,
),
FloatValue(
"r1_rangemode_i",
doc="MMR3 R1 change mode auto/manual",
command_get="MMR3GET 9",
command_set="MMR3SET 9",
pause_instrument=0.5,
),
FloatValue(
"r1_range_i",
doc="MMR3 R1 change flux range",
command_get="MMR3GET 10",
command_set="MMR3SET 10",
pause_instrument=1,
),
FloatValue(
"r1_range_u",
doc="MMR3 R1 change voltage range",
command_get="MMR3GET 11",
command_set="MMR3SET 11",
pause_instrument=0.5,
),
FloatValue(
"r1_i",
doc="MMR3 R1 change polarization",
command_get="MMR3GET 12",
command_set="MMR3SET 12",
pause_instrument=1,
),
# CH2 commands
FloatValue(
"r2_average",
doc="MMR3 R2 Amount of points in each measurement",
command_get="MMR3GET 18",
command_set="MMR3SET 18",
pause_instrument=0.5,
),
FloatValue(
"r2_rangemode",
doc="MMR3 R2 change mode",
command_get="MMR3GET 19",
command_set="MMR3SET 19",
pause_instrument=0.5,
),
FloatValue(
"r2_rangemode_i",
doc="MMR3 R2 change mode auto/manual",
command_get="MMR3GET 20",
command_set="MMR3SET 20",
pause_instrument=0.5,
),
FloatValue(
"r2_range_i",
doc="MMR3 R2 change flux range",
command_get="MMR3GET 21",
command_set="MMR3SET 21",
pause_instrument=0.5,
),
FloatValue(
"r2_range_u",
doc="MMR3 R2 change voltage range",
command_get="MMR3GET 22",
command_set="MMR3SET 22",
pause_instrument=0.5,
),
FloatValue(
"r2_i",
doc="MMR3 R2 change polarization",
command_get="MMR3GET 23",
command_set="MMR3SET 23",
pause_instrument=0.5,
),
# CH3 commands
FloatValue(
"r3_average",
doc="MMR3 R3 Amount of points in each measurement",
command_get="MMR3GET 29",
command_set="MMR3SET 29",
pause_instrument=0.5,
),
FloatValue(
"r3_rangemode",
doc="MMR3 R3 change mode",
command_get="MMR3GET 30",
command_set="MMR3SET 30",
pause_instrument=0.5,
),
FloatValue(
"r3_rangemode_i",
doc="MMR3 R3 change mode auto/manual",
command_get="MMR3GET 31",
command_set="MMR3SET 31",
pause_instrument=0.5,
),
FloatValue(
"r3_range_i",
doc="MMR3 R3 change flux range",
command_get="MMR3GET 32",
command_set="MMR3SET 32",
pause_instrument=0.5,
),
FloatValue(
"r3_range_u",
doc="MMR3 R3 change voltage range",
command_get="MMR3GET 33",
command_set="MMR3SET 33",
pause_instrument=0.5,
),
FloatValue(
"r3_i",
doc="MMR3 R3 change polarization",
command_get="MMR3GET 34",
command_set="MMR3SET 34",
pause_instrument=0.5,
),
]
MMR3._build_class_with_features(features)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment