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,530 Views)
Solution
Accepted by 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

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 3
(2,528 Views)

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

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