主要内容

calldaqlib

Control device configuration and properties using task-handle-based NI-DAQmx library functions

Since R2026a

    Description

    calldaqlib(daqObj,configFunction,param1,...,paramN) configures the DataAcquisition object daqObj using the NI-DAQmx function specified in configFunction and the required function parameters specified in param1,...,paramN. For information on the NI-DAQmx function names and their required input parameters, see NI-DAQmx C Reference. Exclude the task handle from the list of parameters because the daqObj owns the task handle.

    example

    calldaqlib(daqObj,setterFunction,param1,...,paramN,propValue) sets the channel property for the DataAcquisition object daqObj to propValue using the NI-DAQmx setter function specified in setterFunction. Some NI-DAQmx functions might require additional parameters, such as channel, device, or attribute information. Refer to NI-DAQmx C Reference to identify the required input parameters of the NI-DAQmx function and specify them in param1,...,paramN.

    propValues = calldaqlib(daqObj,getterFunction,param1,...,paramN) retrieves the values of the channel property using the NI-DAQmx getter function specified in getterFunction. The function returns the values as a dictionary.

    calldaqlib(daqObj,resetFunction,param1,...,paramN) resets the channel property to its default value using the NI-DAQmx reset function specified in resetFunction.

    To transition the configuration code for your data acquisition device from C to MATLAB®, see Code Transition Help.

    example

    Examples

    collapse all

    Create a DataAcquisition object for the NI PCI-6251 device and add analog input channels.

    dq = daq("ni");
    addinput(dq, "Dev1", 0:2, "Voltage");

    Configure analog triggering on the device.

    calldaqlib(dq, "DAQmxCfgAnlgEdgeStartTrig", 'Dev1/ai0', "DAQmx_Val_RisingSlope", 4.0);

    Set the hysterisis value of the analog edge start trigger.

    calldaqlib(dq, "DAQmxSetAnlgEdgeStartTrigHyst", 5);

    Get the hysterisis value of the analog edge start trigger.

    actualTrigHyst = calldaqlib(dq, "DAQmxGetAnlgEdgeStartTrigHyst")
    actualTrigHyst =
    
      dictionary (string ⟼ double) with 3 entries:
    
        "Dev1_ai0" ⟼ 5
        "Dev1_ai1" ⟼ 5
        "Dev1_ai2" ⟼ 5

    Reset the hysterisis value of the analog edge start trigger.

    calldaqlib(dq, "DAQmxResetAnlgEdgeStartTrigHyst");

    Verify if the hysterisis value of the analog edge start trigger is reset to its default value.

    actualTrigHyst = calldaqlib(dq, "DAQmxGetAnlgEdgeStartTrigHyst")
    actualTrigHyst =
    
      dictionary (string ⟼ double) with 3 entries:
    
        "Dev1_ai0" ⟼ 0
        "Dev1_ai1" ⟼ 0
        "Dev1_ai2" ⟼ 0

    Create a DataAcquisition object for the NI USB-6351 device and add input lines at port 0.

    dq = daq("ni");
    addinput(dq,"Dev4","port0/line0:2","Digital");

    Get the minimum pulse width for the digital filter.

    currentPulseWidth = calldaqlib(dq, "DAQmxGetDIDigFltrMinPulseWidth",'Dev4/port0/line0:2')
    currentPulseWidth =
    
      dictionary (string ⟼ double) with 3 entries:
    
        "Dev4_port0/line0" ⟼ 0
        "Dev4_port0/line1" ⟼ 0
        "Dev4_port0/line2" ⟼ 0

    Set the minimum pulse width for the digital filter.

    calldaqlib(dq, "DAQmxSetDIDigFltrMinPulseWidth",'Dev4/port0/line0:2', 1);

    Verify if the minimum pulse width for the digital filter is reset to the specified value.

    currentPulseWidth = calldaqlib(dq, "DAQmxGetDIDigFltrMinPulseWidth",'Dev4/port0/line0:2')
    currentPulseWidth =
    
      dictionary (string ⟼ double) with 3 entries:
    
        "Dev4_port0/line0" ⟼ 1
        "Dev4_port0/line1" ⟼ 1
        "Dev4_port0/line2" ⟼ 1

    Input Arguments

    collapse all

    Data acquisition interface, specified as a DataAcquisition object created using the daq function.

    Example: daqObj = daq()

    Name of a configure function from the NI-DAQmx C Reference, specified as a character vector or string.

    Example: "DAQmxCfgAnlgEdgeStartTrig"

    Data Types: char | string

    Input parameter(s) required to modify a channel property, specified as a comma-separated list of input arguments. The input parameters that you can specify depend on the specified NI-DAQmx function. For information on the NI-DAQmx function names and their required input parameters, see NI-DAQmx C Reference.

    Example: calldaqlib(dq, "DAQmxCfgAnlgEdgeStartTrig", 'Dev1/ai0', "DAQmx_Val_RisingSlope", 4.0); the required input parameters for the NIDAQmx function DAQmxCfgAnlgEdgeStartTrig are 'Dev1/ai0', "DAQmx_Val_RisingSlope" and 4.0.

    Name of a setter function from the NI-DAQmx C Reference, specified as a character vector or string.

    Example: "DAQmxSetAnlgEdgeStartTrigHyst"

    Data Types: char | string

    Value of the channel property, specified as a scalar.

    Example: 30.0

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string | struct

    Name of a getter function from the NI-DAQmx C Reference, specified as a character vector or string.

    Example: "DAQmxGetAnlgEdgeStartTrigHyst"

    Data Types: char | string

    Name of a reset function from the NI-DAQmx C Reference, specified as a character vector or string.

    Example: "DAQmxResetAnlgEdgeStartTrigHyst"

    Data Types: char | string

    Output Arguments

    collapse all

    Values of the channel property, returned as a dictionary.

    More About

    collapse all

    Version History

    Introduced in R2026a