05-17-2018 02:37 PM
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)
					
				
			
			
				
			
			
				Solved! Go to Solution.
05-17-2018 02:46 PM
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
05-17-2018 03:04 PM
OK, that fixed my problem. Thanks for the solution.