Search code examples
nidaqmxdaq-mx

Error using DAQmxCfgDigEdgeStartTrig


I am trying to sample a 8bit input using sample clock and 'start sampling' trigger. Here's how I configure the task:

DAQmxErrChk(DAQmxCreateTask("",&samplHandle));
DAQmxErrChk(DAQmxCreateDIChan(samplHandle,"Dev1/port1/line2:7,Dev1/port2/line0:1","",DAQmx_Val_ChanForAllLines));    // choose my 8 bit DI lines PFI2:PFI9
DAQmxErrChk(DAQmxCfgSampClkTiming(samplHandle,"/Dev1/PFI0",1000000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,length));
DAQmxErrChk(DAQmxCfgDigEdgeStartTrig(samplHandle,"/Dev1/PFI1",DAQmx_Val_Rising));
DAQmxErrChk(DAQmxRegisterEveryNSamplesEvent(samplHandle,DAQmx_Val_Acquired_Into_Buffer,length,0,Callback,this));
DAQmxErrChk(DAQmxTaskControl(samplHandle,DAQmx_Val_Task_Commit));

When I run it in QT Creator it gives me this error:

DAQmx Error: Specified property is not supported by the device or is not applicable to the task. Property: DAQmx_StartTrig_Type

Task Name: _unnamedTask<0>

Status Code: -200452 DAQmx Error: Task specified is invalid or does not exist. Status Code: -200088

Previously, when I used analog input instead of digital, I did not have any problems. Any one has a clue what's wrong with my channel configuration? I am using PCI6259 and BNC2110.


Solution

  • You can use the PCI 6259 to do what you describe, but you need to configure the card a little differently. You would think it would be as straightforward as assigning a start trigger signal and terminal, like you're doing, but M Series devices are not as flexible as the newer X Series devices.

    First, M Series devices do not support start triggers for digital tasks [1]:

    M Series devices do not have an independent DI or DO Start Trigger for digital waveform acquisition or generation.

    Second, M Series devices can only acquire digital waveforms on port 0, and not on port 1 or 2. Before you can update your program, you will need to rewire your external connections and use lines from port 0. Your device, the NI 6259, has 32 lines for digital waveform measurements [2]:

    • Waveform Characteristics (Port 0 Only) -- NI 6254/6259: Port 0 (P0.<0..31>)
    • PFI/Port 1/Port 2 Functionality -- Static digital input, static digital output, timing input, timing output

    Once you switch to port 0, there are two approaches you can take:

    1. Use another subsystem on the card to provide the trigger and clock.
    2. Use "change detection" to acquire a sample whenever any line has a transition.

    Using another subsystem

    M Series devices have analog input and counter/frequency output subsystems, and either one of these can be used to provide a start trigger and sample clock for your digital input measurements [1a]:

    For example, consider the case where you are using AI Sample Clock as the source of DI Sample Clock. To initiate pulses on AI Sample Clock (and therefore on DI Sample Clock), you use AI Start Trigger to trigger the start of an AI operation. The AI Start Trigger causes the M Series device to begin generating AI Sample clock pulses, which in turn generates DI Sample clock pulses.

    If you are using a Counter output as the source of DI Sample Clock, the counter’s start trigger, enables the counter which drives DI Sample Clock.

    NI-DAQmx installs C examples that show how to use the API to configure tasks [3]. There are few that you can mix together to accomplish your design:

    • Continuously Read Digital Channel - External Clock
      • This can be the basis for the digital task settings
    • Continuously Acquire Voltage Samples - External Clock - Digital Start
      • This shows how to configure an analog task for an external sample clock and external digital start trigger, which can be doubled as the sample clock and start trigger for the digital task
    • Continuous Analog Input and Read Digital Channel
      • This is how you can synchronize the analog and digital subsystems
    • Generate Digital Pulse Train - Continuous - Digital Start
      • This is how you would configure a counter task to be the sample clock and start trigger

    Keep in mind that the file names on disk for the examples are abbreviated.

    Using change detection

    M Series devices can detect rising edges, falling edges, or either edge individually on each DIO line. You can configure the task to raise an interrupt whenever a change is detected [1b]:

    The DAQ devices synchronize each DI signal to 80MHzTimebase, and then sends the signal to the change detectors. The circuitry ORs the output of all enabled change detectors from every DI signal. The result of this OR is the Change Detection Event signal.

    As long as your input signals change slowly (100 Hz or less), you can use this technique to acquire the data. If they change must faster, it is unlikely that the program would be able to service the interrupts quickly enough. Because of this constraint, I would recommend trying the first approach.

    The DAQmx C example [3] for this type of measurement is called Read Digital Channel - Change Detection.

    References

    [1a] M Series User Manual :: Digital Waveform Triggering (page 99..100)
    [1b] M Series User Manual :: DI Change Detection (page 104..105)
    http://digital.ni.com/manuals.nsf/websearch/2025C99AB0614F9E8625748000577B9A

    [2] NI 625x Specifications :: Digital I/O/PFI
    http://digital.ni.com/manuals.nsf/websearch/210C73CBF91128B9862572FF0076BE85

    [3] Text Based NI-DAQmx Data Acquisition Examples :: ANSI C
    http://www.ni.com/white-paper/6999/en/#ANSIC