Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple calls to DAQmxWriteDigitalU32

Solved!
Go to solution

I need to write digital lines with a long initial pattern, followed by faster pattern. To accomplish this, I  first set sample clock timing to slow (1 Hz), and write data using DAQmxWriteDigitalU32. Next I change the sample clock timing faster (500 kHz), and write again DAQmxWriteDigitalU32. The problem is that only the first DAQmxWriteDigitalU32 writes data. The secondDAQmxWriteDigitalU32 does not write any data. What could be wrong  here?

 

    # DAQmx Configure Code
    DAQmxCreateTask("taskSrlO",  byref(taskHandleSrlO))
    # DAQmx Create Channel
    DAQmxCreateDOChan(taskHandleSrlO,
            "Dev1/port0/line0:1, Dev1/port0/line2:7",
                    "", DAQmx_Val_ChanForAllLines)
    # DAQmx Timing Setup
    DAQmxCfgSampClkTiming(taskHandleSrlO, "", 1,
                            DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,
                            1+dataSrlO2.size)

    wrtSrlO = c_int(0)
    # DAQmx Write Code
    DAQmxWriteDigitalU32(taskHandleSrlO, 1+dataSrlO2.size, 0, 10.0,
                            DAQmx_Val_GroupByChannel,
                            dataSrlO2, byref(wrtSrlO), None)

    # DAQmx Start Code
    DAQmxStartTask(taskHandleSrlO)


    DAQmxWaitUntilTaskDone( taskHandleSrlO, 10);   
    print("Written1: %d\n" % wrtSrlO.value)

    # DAQmx Timing Setup changing sample frequency
    DAQmxCfgSampClkTiming(taskHandleSrlO, "", 500000.0,
                            DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,
                            1+dataSrlO2.size)
    # DAQmx Write Code
    DAQmxWriteDigitalU32(taskHandleSrlO, 1+dataSrlO2.size, 0, 10.0,
                            DAQmx_Val_GroupByChannel,
                            dataSrlO2, byref(wrtSrlO), None)

    DAQmxWaitUntilTaskDone( taskHandleSrlO, 10e-3);   
    
    # Serial Out End   #####################

    print("Written2: %d\n" % wrtSrlO.value)
0 Kudos
Message 1 of 3
(2,218 Views)
Solution
Accepted by topic author johndoe777777779

The main thing is that you'll need to explicitly stop the task you started before you can reconfigure the timing to a new sample rate.   DAQmxWaitUntilTaskDone will wait until all samples have been generated, but it won't automatically stop the existing task to allow you to reconfigure it.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 3
(2,216 Views)

OK, that fixed my problem. Thanks for the solution.

0 Kudos
Message 3 of 3
(2,205 Views)