aboutsummaryrefslogtreecommitdiff
path: root/qolab/hardware/multimeter/hp_34401.py
blob: 468e9663a8643c60974d4620c308f3a12ba9aeae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from qolab.hardware.basic import BasicInstrument
from qolab.hardware.multimeter import MultimeterSCPI
from qolab.hardware.scpi  import SCPI_PROPERTY
from pyvisa import constants as pyvisa_constants

class HP_34401(MultimeterSCPI):
    """ HP 34401 multimeter (same as Agilent) """
    """
    rm = pyvisa.ResourceManager()
    instr=rm.open_resource('ASRL/dev/ttyUSB0::INSTR')
    """
    def __init__(self, resource, *args, **kwds):
        super().__init__(resource, *args, **kwds)
        self.config['Device model']='HP 34401'
        self.resource.read_termination = '\r\n'
        self.resource.baud_rate = 9600
        self.resource.data_bits = 8
        self.resource.parity = pyvisa_constants.Parity.none
        self.resource.stop_bits = pyvisa_constants.StopBits.one
        self.deviceProperties.update({'Function'})

    Function = SCPI_PROPERTY(scpi_prfx='SENSe:FUNCtion', ptype=str, doc="""
        Current measurement function (Voltmeter DC/AC, Currentmeter DC/AC, etc.
        Important! When assigning, string should be quoted, i.e. use:
            Function=\'"VOLT:DC"\'

        Possible values:
            "VOLTage:DC", same as "VOLT"
            "VOLTage:DC:RATio"
            "VOLTage:AC"
            "CURRent:DC", same as "CURR"
            "CURRent:AC"
            "RESistance" (2-wire ohms)
            "FRESistance" (4-wire ohms)
            "FREQuency"
            "PERiod"
            "CONTinuity"
            "DIODe"
        """
     )

    def toRemote():
        self.write("SYSTem:REMote")

    def toLocal():
        self.write("SYSTem:LOCal")

    Reading = SCPI_PROPERTY(scpi_prfx='SYSTem:REMote\n read', ptype=float, doc='Report current measurement', no_setter=True)

if __name__ == '__main__': 
    import pyvisa
    print("testing")
    rm = pyvisa.ResourceManager()
    print(rm.list_resources())    
    instr=rm.open_resource('ASRL/dev/ttyUSB0::INSTR')
    multimeter = HP_34401(instr)
    print('------ Header start -------------')
    print(str.join('\n', multimeter.getHeader()))
    print('------ Header ends  -------------')