Quantcast
Channel: Digital I/O topics
Viewing all articles
Browse latest Browse all 2167

multiple write operations in a task synchronized with trigger

$
0
0

My goal is to write digital patterns, first a long lasting setup pattern is written, and then a faster burst of pattern is written. I also need to synchronize this task with other actions (for example, clock generation). For the synchronization, I use the trigger functionality. Thus I have two write actions in one task, and this task is synchronized to a trigger. However, with the trigger task and the write task, only the first write call DAQmxWriteDigitalU32 works, and the second write call is ineffectual. Does the second write call need to another rising trigger?

 

    # 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+dataSrlO.size)

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

    #Start output at trigger, the trigger in in taskHandle1
    DAQmxCfgDigEdgeStartTrig( taskHandleSrlO, "/Dev1/PFI14", DAQmx_Val_Rising);

    # DAQmx Start Code
    DAQmxStartTask(taskHandleSrlO)


    # DAQmx Configure Code
    DAQmxCreateTask("",  byref( taskHandle1));
    DAQmxCreateCOPulseChanTime( taskHandle1, "Dev1/ctr2", "",
                                DAQmx_Val_Seconds, DAQmx_Val_Low,
                                0.001,0.50e-3,1.00e-6);

    DAQmxStartTask(taskHandle1)

    # DAQmx Wait Code
    #DAQmxWaitUntilTaskDone(taskHandle1,10.0);

    # DAQmx Clear Code
    #DAQmxClearTask(taskHandle1);

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

    DAQmxStopTask(taskHandleSrlO)
    # DAQmx Timing Setup (frequency = 50)
    DAQmxCfgSampClkTiming(taskHandleSrlO, "", 50.0,
                            DAQmx_Val_Rising, DAQmx_Val_FiniteSamps,
                            1+dataSrlO2.size)

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

    print("before Written2: %d\n" % wrtSrlO.value)
    DAQmxWaitUntilTaskDone( taskHandleSrlO, 50e-0);   
    print("before Written2: %d\n" % wrtSrlO.value)

 

 


Viewing all articles
Browse latest Browse all 2167

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>