Reference
Public API to describe and run NI-DAQmx tasks from any Python code.
It never imports Qt nor the PyMoDAQ GUI. See the documentation for the stability promise.
System
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.NIDAQSystem[source]
Bases:
objectA view of the NI hardware, read from the driver once and kept until
refresh().Without the NI-DAQmx driver there is simply no device. Everything returned is made of plain strings, numbers and tuples. A device or a kind of channel that does not exist is a
ValueError; a property the device does not have (for instance the maximum rate of the analog outputs of a card without any) isNoneor an empty list.- ai_max_rate(device, multi_channel=True)[source]
Maximum sampling rate (Hz) of the analog inputs, for several channels or for a single one.
- ai_measurement_types(device)[source]
Kinds of measure of the analog inputs, as lower case names (
voltage,temperature_rtd…).
- all_channels(kind: ChannelKind) List[str][source]
Names of the channels of the given
kindon all the devices, device after device.
- ao_max_rate(device)[source]
Maximum update rate (Hz) of the analog outputs;
Noneif the device has none.
- channels(device: str, kind: ChannelKind) List[str][source]
Names of the channels of
device(such as'Dev1') of the givenkind(a ChannelKind or its value: ai, ao, ci, co, di (lines) or do (lines)).
- refresh()[source]
Forget what was read: the next call asks the driver again (a card may have been plugged in).
Tasks
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.TaskConfig(channels: Tuple[pymodaq_plugins_daqmx.hardware.national_instruments.api.channels.AIVoltage | pymodaq_plugins_daqmx.hardware.national_instruments.api.channels.AICurrent | pymodaq_plugins_daqmx.hardware.national_instruments.api.channels.AIThermocouple | pymodaq_plugins_daqmx.hardware.national_instruments.api.channels.AIRtd | pymodaq_plugins_daqmx.hardware.national_instruments.api.channels.AOVoltage | pymodaq_plugins_daqmx.hardware.national_instruments.api.channels.AOCurrent | pymodaq_plugins_daqmx.hardware.national_instruments.api.channels.CICountEdges | pymodaq_plugins_daqmx.hardware.national_instruments.api.channels.COPulseFreq | pymodaq_plugins_daqmx.hardware.national_instruments.api.channels.DigitalIn | pymodaq_plugins_daqmx.hardware.national_instruments.api.channels.DigitalOut, ...], timing: pymodaq_plugins_daqmx.hardware.national_instruments.api.timing.ClockSettings | pymodaq_plugins_daqmx.hardware.national_instruments.api.timing.ImplicitTiming | pymodaq_plugins_daqmx.hardware.national_instruments.api.timing.ChangeDetectionSettings | None = None, trigger: pymodaq_plugins_daqmx.hardware.national_instruments.api.triggers.DigitalEdgeTrigger | pymodaq_plugins_daqmx.hardware.national_instruments.api.triggers.AnalogEdgeTrigger | None = None)[source]
Bases:
object- __init__(channels: Tuple[AIVoltage | AICurrent | AIThermocouple | AIRtd | AOVoltage | AOCurrent | CICountEdges | COPulseFreq | DigitalIn | DigitalOut, ...], timing: ClockSettings | ImplicitTiming | ChangeDetectionSettings | None = None, trigger: DigitalEdgeTrigger | AnalogEdgeTrigger | None = None) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.AnalogInputTask(config: TaskConfig)[source]
Bases:
_Task
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.TaskListener[source]
Bases:
objectWhat a task can tell: derive from it and register the object with
task.add_listener.Both methods are called from driver threads, never from the thread that started the task, one thread per call and without any order between them. Do only what is thread-safe here, or hand the event over to the thread that should handle it (see
QtTaskBridge).
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.AnalogOutputTask(config: TaskConfig)[source]
Bases:
_Task
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.CounterInputTask(config: TaskConfig)[source]
Bases:
_Task
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.CounterOutputTask(config: TaskConfig)[source]
Bases:
_TaskGenerates pulses:
start()it,close()it to stop.
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.DigitalTask(config: TaskConfig)[source]
Bases:
_TaskReads digital input lines or drives digital output lines (not both in one task).
- __init__(config: TaskConfig)[source]
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.TaskGroup(*tasks: _Task)[source]
Bases:
objectTasks that run together, such as a task waiting for a clock and the counter that generates it.
One task cannot mix subsystems (analog in, analog out, digital, counters): to acquire and generate at the same time, use one task per subsystem, synchronised by a shared clock or trigger (
ClockSettings.source,DigitalEdgeTrigger). The group starts them in the order given, so put first the tasks that wait for a signal and last the one that produces it, and stops and closes them in the reverse order.If a task cannot start, the ones already started are stopped and the error is raised. All the tasks are closed even if one of them cannot be, then the first error is raised.
Channels
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.AIVoltage(name: str, min_val: float = -10.0, max_val: float = 10.0, terminal_config: TerminalConfiguration = TerminalConfiguration.DEFAULT)[source]
Bases:
objectAnalog input measuring a voltage on a physical channel such as
Dev1/ai0.- __init__(name: str, min_val: float = -10.0, max_val: float = 10.0, terminal_config: TerminalConfiguration = TerminalConfiguration.DEFAULT) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.AICurrent(name: str, min_val: float = -0.02, max_val: float = 0.02, terminal_config: TerminalConfiguration = TerminalConfiguration.DEFAULT)[source]
Bases:
objectAnalog input measuring a current, in amperes.
- __init__(name: str, min_val: float = -0.02, max_val: float = 0.02, terminal_config: TerminalConfiguration = TerminalConfiguration.DEFAULT) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.AIThermocouple(name: str, thermocouple_type: ThermocoupleType = ThermocoupleType.K, units: TemperatureUnits = TemperatureUnits.DEG_C, min_val: float = 0.0, max_val: float = 100.0)[source]
Bases:
objectAnalog input measuring a temperature with a thermocouple (no terminal configuration).
- __init__(name: str, thermocouple_type: ThermocoupleType = ThermocoupleType.K, units: TemperatureUnits = TemperatureUnits.DEG_C, min_val: float = 0.0, max_val: float = 100.0) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.AIRtd(name: str, rtd_type: RTDType = RTDType.PT_3851, resistance_config: ResistanceConfiguration = ResistanceConfiguration.THREE_WIRE, excitation_current: float = 0.0025, r_0: float = 100.0, units: TemperatureUnits = TemperatureUnits.DEG_C, min_val: float = 0.0, max_val: float = 100.0)[source]
Bases:
objectAnalog input measuring a temperature with a resistance temperature detector.
- __init__(name: str, rtd_type: RTDType = RTDType.PT_3851, resistance_config: ResistanceConfiguration = ResistanceConfiguration.THREE_WIRE, excitation_current: float = 0.0025, r_0: float = 100.0, units: TemperatureUnits = TemperatureUnits.DEG_C, min_val: float = 0.0, max_val: float = 100.0) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.AOVoltage(name: str, min_val: float = -10.0, max_val: float = 10.0)[source]
Bases:
objectAnalog output generating a voltage on a physical channel such as
Dev2/ao0.- __init__(name: str, min_val: float = -10.0, max_val: float = 10.0) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.AOCurrent(name: str, min_val: float = 0.0, max_val: float = 0.02)[source]
Bases:
objectAnalog output generating a current, in amperes.
- __init__(name: str, min_val: float = 0.0, max_val: float = 0.02) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.CICountEdges(name: str, edge: Edge = Edge.RISING, initial_count: int = 0, direction: CountDirection = CountDirection.COUNT_UP)[source]
Bases:
objectCounter input counting the edges of a signal, starting from
initial_count.- __init__(name: str, edge: Edge = Edge.RISING, initial_count: int = 0, direction: CountDirection = CountDirection.COUNT_UP) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.COPulseFreq(name: str, frequency: float, duty_cycle: float = 0.5, idle_state: Level = Level.LOW, initial_delay: float = 0.0)[source]
Bases:
objectCounter output generating a pulse train of the given frequency (Hz) and duty cycle (0 to 1, excluded).
- __init__(name: str, frequency: float, duty_cycle: float = 0.5, idle_state: Level = Level.LOW, initial_delay: float = 0.0) None
Timing and triggers
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.ClockSettings(rate: float, samples: int | None = None, source: str = '', edge: Edge = Edge.RISING)[source]
Bases:
objectAcquire
samplessamples per channel atrateHz, or until stopped ifsamplesis None.sourceis a terminal such as/Dev1/PFI1to use an external clock; empty means the onboard clock. A continuous acquisition (nosamples) is read throughon_samples_ready(start(notify_every=n)), with a driver buffer holding at least one second of data.- __init__(rate: float, samples: int | None = None, source: str = '', edge: Edge = Edge.RISING) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.ImplicitTiming(samples: int | None = None)[source]
Bases:
objectNo sample clock: the pace is given by the task itself, not by the onboard clock.
Use it for counter output: the counter itself generates the pulse train (continuous, or
samplespulses). For a counter input that is read on demand, give no timing at all (timing=None): each read returns the count at the moment of the call. To count at a regular pace, useClockSettingswith asource.- __init__(samples: int | None = None) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.ChangeDetectionSettings(rising_lines: Tuple[str, ...] = (), falling_lines: Tuple[str, ...] = (), samples: int | None = None)[source]
Bases:
objectSample a digital input task on transitions of the chosen lines, instead of on a clock.
Example:
TaskConfig((DigitalIn('Dev1/port0/line0'),), timing=ChangeDetectionSettings(rising_lines=('Dev1/port0/line0',))), run with aDigitalTask. Continuous unlesssamplesis given.- __init__(rising_lines: Tuple[str, ...] = (), falling_lines: Tuple[str, ...] = (), samples: int | None = None) None
- pymodaq_plugins_daqmx.hardware.national_instruments.api.counter_output_terminal(counter: str) str[source]
The terminal where a counter output sends its pulses, such as
/Dev1/Ctr1InternalOutputforDev1/ctr1: give it assourceof aClockSettingsto clock another task with these pulses.
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.DigitalEdgeTrigger(source: str, edge: Edge = Edge.RISING)[source]
Bases:
objectStart on an edge of a digital terminal such as
/Dev1/PFI0.- __init__(source: str, edge: Edge = Edge.RISING) None
- class pymodaq_plugins_daqmx.hardware.national_instruments.api.AnalogEdgeTrigger(source: str, level: float, slope: Slope = Slope.RISING)[source]
Bases:
objectStart when the analog signal
source(a channel such asDev1/ai0) crosseslevel.- __init__(source: str, level: float, slope: Slope = Slope.RISING) None