hvl_ccb.dev.labjack

Inheritance diagram of hvl_ccb.dev.labjack

Labjack Device for hvl_ccb. Originally developed and tested for LabJack T7-PRO.

Makes use of the LabJack LJM Library Python wrapper. This wrapper needs an installation of the LJM Library for Windows, Mac OS X or Linux. Go to: https://labjack.com/support/software/installers/ljm and https://labjack.com/support/software/examples/ljm/python

class LabJack(com, dev_config=None)[source]

Bases: hvl_ccb.dev.base.SingleCommDevice

LabJack Device.

This class is tested with a LabJack T7-Pro and should also work with T4 and T7 devices communicating through the LJM Library. Other or older hardware versions and variants of LabJack devices are not supported.

class AInRange(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.StrEnumBase

An enumeration.

ONE = 1.0
ONE_HUNDREDTH = 0.01
ONE_TENTH = 0.1
TEN = 10.0
property value: float
class CalMicroAmpere(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.Enum

Pre-defined microampere (uA) values for calibration current source query.

TEN = '10uA'
TWO_HUNDRED = '200uA'
class CjcType(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

CJC slope and offset

internal = (1, 0)
lm34 = (55.56, 255.37)
DIOChannel

alias of hvl_ccb._dev.labjack.TSeriesDIOChannel

class DIOStatus(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: aenum.IntEnum

State of a digital I/O channel.

HIGH = 1
LOW = 0
class DeviceType(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)

Bases: hvl_ccb.utils.enum.AutoNumberNameEnum

LabJack device types.

Can be also looked up by ambigious Product ID (p_id) or by instance name: `python LabJackDeviceType(4) is LabJackDeviceType('T4') `

ANY = 1
T4 = 2
T7 = 3
T7_PRO = 4
classmethod get_by_p_id(p_id: int)Union[hvl_ccb._dev.labjack.DeviceType, List[hvl_ccb._dev.labjack.DeviceType]]

Get LabJack device type instance via LabJack product ID.

Note: Product ID is not unambiguous for LabJack devices.

Parameters

p_id – Product ID of a LabJack device

Returns

Instance or list of instances of LabJackDeviceType

Raises

ValueError – when Product ID is unknown

class TemperatureUnit(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

Temperature unit (to be returned)

C = 1
F = 2
K = 0
class ThermocoupleType(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)[source]

Bases: hvl_ccb.utils.enum.NameEnum

Thermocouple type; NONE means disable thermocouple mode.

C = 30
E = 20
J = 21
K = 22
NONE = 0
PT100 = 40
PT1000 = 42
PT500 = 41
R = 23
S = 25
T = 24
static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns

the type of the standard communication protocol for this device

get_ain(*channels: int)Union[float, Sequence[float]][source]

Read currently measured value (voltage, resistance, …) from one or more of analog inputs.

Parameters

channels – AIN number or numbers (0..254)

Returns

the read value (voltage, resistance, …) as float`or `tuple of them in case multiple channels given

get_cal_current_source(name: Union[str, CalMicroAmpere])float[source]

This function will return the calibration of the chosen current source, this ist not a measurement!

The value was stored during fabrication.

Parameters

name – ‘200uA’ or ‘10uA’ current source

Returns

calibration of the chosen current source in ampere

get_digital_input(address: Union[str, hvl_ccb._dev.labjack.TSeriesDIOChannel])hvl_ccb.dev.labjack.LabJack.DIOStatus[source]

Get the value of a digital input.

allowed names for T7 (Pro): FIO0 - FIO7, EIO0 - EIO 7, CIO0- CIO3, MIO0 - MIO2 :param address: name of the output -> ‘FIO0’ :return: HIGH when address DIO is high, and LOW when address DIO is low

get_product_id()int[source]

This function returns the product ID reported by the connected device.

Attention: returns 7 for both T7 and T7-Pro devices!

Returns

integer product ID of the device

get_product_name(force_query_id=False)str[source]

This function will return the product name based on product ID reported by the device.

Attention: returns “T7” for both T7 and T7-Pro devices!

Parameters

force_query_id – boolean flag to force get_product_id query to device instead of using cached device type from previous queries.

Returns

device name string, compatible with LabJack.DeviceType

get_product_type(force_query_id: bool = False)hvl_ccb._dev.labjack.DeviceType[source]

This function will return the device type based on reported device type and in case of unambiguity based on configuration of device’s communication protocol (e.g. for “T7” and “T7_PRO” devices), or, if not available first matching.

Parameters

force_query_id – boolean flag to force get_product_id query to device instead of using cached device type from previous queries.

Returns

DeviceType instance

Raises

LabJackIdentifierDIOError – when read Product ID is unknown

get_sbus_rh(number: int)float[source]

Read the relative humidity value from a serial SBUS sensor.

Parameters

number – port number (0..22)

Returns

relative humidity in %RH

get_sbus_temp(number: int)float[source]

Read the temperature value from a serial SBUS sensor.

Parameters

number – port number (0..22)

Returns

temperature in Kelvin

get_serial_number()int[source]

Returns the serial number of the connected LabJack.

Returns

Serial number.

read_resistance(channel: int)float[source]

Read resistance from specified channel.

Parameters

channel – channel with resistor

Returns

resistance value with 2 decimal places

read_thermocouple(pos_channel: int)float[source]

Read the temperature of a connected thermocouple.

Parameters

pos_channel – is the AIN number of the positive pin

Returns

temperature in specified unit

set_ain_differential(pos_channel: int, differential: bool)None[source]

Sets an analog input to differential mode or not. T7-specific: For base differential channels, positive must be even channel from 0-12 and negative must be positive+1. For extended channels 16-127, see Mux80 datasheet.

Parameters
  • pos_channel – is the AIN number (0..12)

  • differential – True or False

Raises

LabJackError – if parameters are unsupported

set_ain_range(channel: int, vrange: Union[Real, AInRange])None[source]

Set the range of an analog input port.

Parameters
  • channel – is the AIN number (0..254)

  • vrange – is the voltage range to be set

set_ain_resistance(channel: int, vrange: Union[Real, AInRange], resolution: int)None[source]

Set the specified channel to resistance mode. It utilized the 200uA current source of the LabJack.

Parameters
  • channel – channel that should measure the resistance

  • vrange – voltage range of the channel

  • resolution – resolution index of the channel T4: 0-5, T7: 0-8, T7-Pro 0-12

set_ain_resolution(channel: int, resolution: int)None[source]

Set the resolution index of an analog input port.

Parameters
  • channel – is the AIN number (0..254)

  • resolution – is the resolution index within 0…`get_product_type().ain_max_resolution` range; 0 will set the resolution index to default value.

set_ain_thermocouple(pos_channel: int, thermocouple: Union[None, str, ThermocoupleType], cjc_address: int = 60050, cjc_type: Union[str, CjcType] = <CjcType.internal: (1, 0)>, vrange: Union[Real, AInRange] = <AInRange.ONE_HUNDREDTH: '0.01'>, resolution: int = 10, unit: Union[str, TemperatureUnit] = <TemperatureUnit.K: 0>)None[source]

Set the analog input channel to thermocouple mode.

Parameters
  • pos_channel – is the analog input channel of the positive part of the differential pair

  • thermocouple – None to disable thermocouple mode, or string specifying the thermocouple type

  • cjc_address – modbus register address to read the CJC temperature

  • cjc_type – determines cjc slope and offset, ‘internal’ or ‘lm34’

  • vrange – measurement voltage range

  • resolution – resolution index (T7-Pro: 0-12)

  • unit – is the temperature unit to be returned (‘K’, ‘C’ or ‘F’)

Raises

LabJackError – if parameters are unsupported

set_digital_output(address: str, state: Union[int, DIOStatus])None[source]

Set the value of a digital output.

Parameters
  • address – name of the output -> ‘FIO0’

  • state – state of the output -> DIOStatus instance or corresponding int value

start()None[source]

Start the Device.

stop()None[source]

Stop the Device.

exception LabJackError[source]

Bases: Exception

Errors of the LabJack device.

exception LabJackIdentifierDIOError[source]

Bases: Exception

Error indicating a wrong DIO identifier