API¶
Instrument¶
The NIDAQmxInstrument
class is the primary method through which most users will
acquire hardware.
- class daqmx.NIDAQmxInstrument(device_name: str = None, serial_number: (<class 'str'>, <class 'int'>) = None, model_number: str = None, loglevel=20)¶
This class will create the tasks and coordinate with the hardware in order to achieve a particular end on an input or output of the DAQ module.
The methods within this object utilize the concepts found in the NI-DAQmx Help menu, such as channels and tasks.
- Parameters
device_name – the device name, often formatted like Dev3
serial_number – the serial number as a hexadecimal value (this is usually what is printed on the label)
model_number – the model number as printed on the label
- property sn¶
Returns the device serial number
- Returns
the device serial number
- property model¶
Returns the device model number
- Returns
the device model number
- property outputs¶
Returns a list of outputs associated with the device.
- Returns
a list of outputs associated with the device.
- property inputs¶
Returns a list of inputs associated with the device
- Returns
a list of inputs associated with the device
Port¶
The Port
class is the class which implements port writes and reads. It
may be used directly or through the instrument.
- class daqmx.Port(device: str, port: str)¶
Represents the port object as defined by DAQmx.
- Parameters
device – the device string as defined by DAQmx (i.e. ‘Dev3’)
port – the port name as defined by DAQmx (i.e. ‘port2’)
- property lines¶
Lists all of the lines attached to the port
- Returns
a list of line names
Analog Input¶
The AnalogInput
class is the class which implements most of the
analog input functionality. It may be used directly or through the instrument.
- class daqmx.AnalogInput(device: str, analog_input: str = None, sample_count: int = 1000, rate: (<class 'int'>, <class 'float'>) = 1000.0, max_voltage: (<class 'int'>, <class 'float'>) = 5.0, min_voltage: (<class 'int'>, <class 'float'>) = 0.0, mode: str = 'differential', timeout: (<class 'int'>, <class 'float'>) = None)¶
Represents an analog input on the DAQmx device.
- Parameters
device – the device string assigned by DAQmx (i.e. ‘Dev3)
analog_input – the analog input name assigned by DAQmx (i.e. “ao0”)
sample_count – the number of samples to take
rate – the frequency at which to sample the input
max_voltage – the maximum expected voltage
min_voltage – the minimum expected voltage
mode – the mode; valid values: differential, pseudo-differential, / singled-ended referenced, singled-ended non-referenced
timeout – the time at which an error will occur if no response / from the instrument is received.
- property value¶
Return a single sample of the analog input
- Returns
a floating-point value representing the voltage
- sample(analog_input: Optional[str] = None)¶
Return a single sample of the analog input
- Returns
a floating-point value representing the voltage
- capture(analog_input: str = None, sample_count: int = None, rate: (<class 'int'>, <class 'float'>) = None, max_voltage: (<class 'int'>, <class 'float'>) = None, min_voltage: (<class 'int'>, <class 'float'>) = None, mode: str = None, timeout: (<class 'int'>, <class 'float'>) = None)¶
Will capture <sample_count> samples at <rate>Hz in the <mode> mode.
- Parameters
analog_input – the analog input name assigned by DAQmx (i.e. “ao0”)
sample_count – the number of samples to take
rate – the frequency at which to sample the input
max_voltage – the maximum expected voltage
min_voltage – the minimum expected voltage
mode – the mode; valid values: differential, pseudo-differential, / singled-ended referenced, singled-ended non-referenced
timeout – the time at which an error will occur if no response / from the instrument is received.
- Returns
a numpy array containing all resulting values
- find_dominant_frequency(analog_input: str = None, sample_count: int = None, rate: (<class 'int'>, <class 'float'>) = None, max_voltage: (<class 'int'>, <class 'float'>) = None, min_voltage: (<class 'int'>, <class 'float'>) = None, mode: str = None, timeout: (<class 'int'>, <class 'float'>) = None)¶
Acquires the fundamental frequency observed within the samples
- Parameters
analog_input – the NI analog input designation (i.e. ‘ai0’)
sample_count – the number of samples to acquired
rate – the sample rate in Hz :param max_voltage: the maximum voltage possible
min_voltage – the minimum voltage range
mode – the voltage mode of operation; choices: ‘differential’, ‘pseudo-differential’, ‘single-ended referenced’, ‘single-ended non-referenced’
timeout – the time at which the function should return if this time has elapsed; set to -1 to make infinite (default)
- Returns
the frequency found to be at the highest amplitude; this is often the fundamental frequency in many domains