How to synchronize two timer/counter tasks?

Hi,
I'm programming DAQmx through the nicaiu.dll with Matlab. I'm trying to start two different tasks, each controlling ctr0 and ctr1, respectively. Both timer/counter tasks should start on a common trigger, in my case /Dev/PFI0. Having searched the forum, I do understand that both tasks can't be triggered off PFI0. Instead, I probably need to trigger one of my tasks on a signal that turns on whenever the first task starts. My question is; What signal can inform my ctr1 task that my ctr0 has started? I basically want these two tasks synchronized, but not pulse by pulse since the pulse trains are quite different.
Trying to trigger both off PFI0 results in a resource conflict. Triggering ctr1 on ctr0gate doesnt work either.
Also, I need ctr1 to trigger on when the ctr0 tasks starts, i.e. not when the first ctr0 pulse appaers!
Thanks,
Per

Thanks Ryan.
I made some changes to my code now and it appears I CAN trigger both counters off PFIO (on an E-Series board). I only recently converted all my Traditional code into DAQmx, and got lost in my tracks. I was trying to generate finite pulse trains on both counters, and had used Finite timing on the counters to generate finite retriggerable pulse trains, without knowing that tied up the second counter. I solved this now using Pause Triggers instead. In the case where I generate single retriggerable pulses I still use a Start Trigger, and I can now Start BOTH counters using DAQmxCfgDigEdgeStartTrig and listening to PFIO with both counters (each counter running off a separate task).
Sorry, I got things confused, and your solution isnt required anymore. Similarly to your solution, though, I have always used a (real) analog output routed externally to the PFI0 pin on my E-Series board as the synchronizing trigger. However, if I could avoid the external wiring it would be nice, so I will explore your solution a bit more
I am not familiar with the concept of a 'dummy' task/channel. Can you point me to more documentation on this?
I already use the analog inputs on this board from another app. Will creating a dummy AI tie up all analog inputs, so I can't then access my physical analog inputs from other applications (on the same board)?
 - Per

Similar Messages

  • How to synchronize two fpga DIO?

    Hi!
    I am using two FPGA 7962R (flexrio) with each 6581 terminal board in PXIe-1082 chassis. My problem is how to synchronize two 7962R digital output with PXIe-1082 chassis backplane signal Dstar* or Clk10 or DAQ signal.
    Actually I tried the synchronization with one DAQ counter clock (confering 'Gen Dig Pulse Train-Finite_NI. vi') , and get the signal PXI-Trig0 by source terminal and target terminal connection, but that one does not work properly. Especially, one trigger signal in HOST to set the starting point of each FPGA (7962R), make error by depending on the trigger signal value(Hz value and Timed loop clock in FPGA vi). It was very tricky and not reliable. (I am attaching figure files as explaining the situation)
    My aim is simply to use two FPGA 7962R Digital output as one FPGA, for controling X-axis, Y-axis with each FPGA, while able to change each FPGA (X-axis, Y axis) digital output value. Because the synchronization is not correct, X,Y axis control with Two FPGA currently is out of target if I use simply while-loop design in HOST and timed-loop design in FPGA vi. What is correct design to synchronize the two FPGA 7962R without using PFI line, only with PXIe-1082 chassis backplane signal and able to change the digital output value? Please let me know any idea for HOST vi, FPGA vi programming.
    Many Thanks
    Attachments:
    host1.png ‏47 KB
    fpga1.png ‏131 KB

    Posted response to this in the following thread:
    http://forums.ni.com/t5/Real-Time-Measurement-and/synchronization-two-fpga-7962r-digital-output/m-p/...
    Patrick H | National Instruments | Software Engineer

  • How to synchronize two database in ur java program

    Hi All
    How to synchronize two data base of mysql using java programing language?
    If somebody has any idea that will help me a lot.
    Thanks and regards
    Srikant

    Of corse I have an idea, but not good!
    If you know the database stucture then copy data from one to another.
    Open 2 connections: one to source and one to dest.
    And:
    String sql = "SELCET * from mytable1";// from source
    string sql2;
    Statement st1 = connSrc.createStatement();
    Statement st2 = connDest.createStatement();
    ResultSet rs = st1.executeQuerry(sql);
    while(rs.next()){
    sql2 = "INSERT INTO mytable1 ('field1', 'filed2') VALUES ("+
    "'"+rs.get(filed1")+"',"+
    "'"+rs.get(filed2')+"'"+
    st2.executeUpdate(sql2);
    // the destination was cleared before this: DELETE FROM mytable1 WHERE 1
    This is a mysql sample without processing the errors.
    Szabi

  • How to sync two time capsules?

    I have two time capsules on my network and want to set them to automatically sync files between them for redundancy.  How do I do this?

    In theory, you could have another application like Carbon Copy Cloner or SuperDuper backup Time Capsule 1 to Time Capsule 2, but the same risks apply.. I haven't tried this....and won't....but maybe another user has.
    Agree with Bob.. what you can do and what you should do are different. It is possible to use CCC and put the two TC in sync. The result will still be only as good as the quality of the first disk. That is a very slow way to backup.. TC is not designed as a NAS so it has no internal ability to sync files. It is purely designed as a target for Time Machine.
    If you do use CCC all packets are copied via the computer.. over the network.. so if you use wireless expect to never finish.. before the next TM backup starts and CCC will still be syncing.. ie you will have created an endless loop. Don't do it.

  • How to Synchronize two methods or more methods

    HI All,
    As a java starter in learning Synchronization. how simply can I Synchronize two methods
    for example I have the following.
    public class Process {          
    public static void main(String args[]){
    process1();
    process2();    
    private void process1(){
    private void process2(){
    }

    A-KADRI wrote:
    HI All,
    As a java starter in learning Synchronization. how simply can I Synchronize two methods
    for example I have the following.
    public class Process {          
    public static void main(String args[]){
    process1();
    process2();    
    private void process1(){
    private void process2(){
    You're being really ambiguous. You could "synchronize" those methods by adding the synchronized keyword to their method signature, in which case they will implicitly lock on the object they belong to. That's what most people will think you mean when you say synchronized. Is that what you meant? Or did you mean what BDLH was thinking in that you wanted to lock something, then do 1,2,3,4, then unlock it? That's something different. Be specific!

  • How to create a time counter

    Hello expertsl,
    I have a new challenge on board.
    I have a form that is automatically popped up. Now on the form, i need to insert a timer that as soon as it pops out, the timer starts and then i have to enter some data in the form and as soon as i press the save button, the timer records the time count and then stores it in a table.
    Any suggestion are the most welcome...
    Thank you

    As Hoek said, this is not a Forms forum.
    However, the problem is not really unique to Forms and a timer itself is not needed.
    A timer is a kernel object that fires at specific intervals and each time around executes a callback routine. This allows one to update or process at specific intervals.
    You do not need a timer as you are interested in time elapsed - which means that on the creation of the form you need to get the current time. When the save button is clicked you again get the current time. The data that you are interested in is the time difference between these two.
    Remember that timers are expensive objects to create ito kernel resources. Some operating systems limit the total number of timers that can be created. In general, it is not a good idea to create a timer unless it is the best technical solution for the problem. And you do not need a timer determine a time elapse. You simply need code in the constructor of the form and code in the save events of the form. Nothing more.

  • How to synchronize the time from an internal ip adress (MS ISA Server)

    How I can synchronize the time of eMac client from an internal Time Server (Microsoft ISA Server).
    I have setting the DHCP time parameter but it does not work in the e Mac but only in Windows clients (2000 and XP).
    My Firewall does not allow the eMac client to synchronize from the external time server.
    Sorry for my english.
    Best regards,
    Stefano

    Yes but selection allow to select only Apple Time Server: in my case Apple Europe (time.euro.apple.com).
    The possibility does't exist to set up an other server outside of those proposals.
    If you know like modifying the values proposals and adding a fixed IP for example, it makes to know me.
    Sorry for my english and Thank you for your post
    Stefano

  • How to synchronize the time in NI 1776 smart camera

    Hi,
    i'm using 2 NI 1776 Smart camera together, how can i synchronize the time with host pc?
     i had follow this thread to setup the NTP at host PC
     http://digital.ni.com/public.nsf/allkb/FFC39254D02C652A86257A620074FB49
    and then follow another thread to setup the NI-TimeSync 1.2
    http://digital.ni.com/public.nsf/allkb/402F0F07F851768486257A1B0063EE88
    but i encouter some error when installing NI-TimeSync at Smart Camera (refer to s3.png)
    i'm using window 7 with LabView 2011 SP1 and VBAI 2011 SP1
    anyone know how to solve this problem?
    Attachments:
    s1.png ‏122 KB
    s2.png ‏107 KB
    s3.png ‏25 KB

    VBAI 2011 is based on LabVIEW 2010.
    So you will either have to use LabVIEW 2010 + LabVIEW Realtime 2010 in combination with VBAI 2011 SP1,
    or you use LabVIEW 2011 + LabVIEW Realtime 2011 in combination with VBAI 2012.
    And here is a KB which explains how to synchronize 177x SmartCams to a timeserver.
    Christian

  • How to create a time counter without using Sleep()?

    I want to create a time counter that would count from 120 minutes and down. I thought about using Sleep() but I have found out that Sleep() is not accurate (so maybe the countdown would take 122 minutes instead of 120 minutes!). What other alternatives do
    I have?
    Note that I want to count 1 second at a time, because I want to show the countdown progress to the user in seconds.

    The next experiment still uses Sleep and waits for approximately 12 seconds, displaying the time each second. However it is probably too overcomplicated compared to time polling:
    const
    int SECONDS_TO_WAIT =
    12;
    ULARGE_INTEGER ul_end;
    FILETIME ft;
    GetSystemTimeAsFileTime( &ft );
    ul_end.LowPart = ft.dwLowDateTime;
    ul_end.HighPart = ft.dwHighDateTime;
    ul_end.QuadPart += 10LL *
    1000 *
    1000 * SECONDS_TO_WAIT;
    for( ;; )
    FILETIME ft;
    GetSystemTimeAsFileTime( &ft );
    ULARGE_INTEGER ul;
    ul.LowPart = ft.dwLowDateTime;
    ul.HighPart = ft.dwHighDateTime;
    if( ul.QuadPart >= ul_end.QuadPart )
    break;
    SYSTEMTIME st;
    FileTimeToSystemTime( &ft, &st );
    Sleep( 1000 - st.wMilliseconds );
    GetSystemTime( &st );
    if( st.wMilliseconds >
    500 )
    FILETIME ft;
    SystemTimeToFileTime( &st, &ft );
    ULARGE_INTEGER ul;
    ul.LowPart = ft.dwLowDateTime;
    ul.HighPart = ft.dwHighDateTime;
    ul.QuadPart += 10LL *
    1000 *
    1000;
    ft.dwLowDateTime = ul.LowPart;
    ft.dwHighDateTime = ul.HighPart;
    FileTimeToSystemTime( &ft, &st );
    // show the time
    SystemTimeToTzSpecificLocalTime( NULL, &st, &st );
    printf( "%02i:%02i:%02i\n", st.wHour, st.wMinute, st.wSecond

  • How to start two or more tasks at the same time?

    Hi all,
      I have few tasks setup to send analog and digital output to different channel with buffer and given sampling rate. I need to precisely control the timing of samples output to each channel. But if I start the task in labwindows
        DAQmxStartTask(taskHandle1)
        DAQmxStartTask(taskHandle2)
        DAQmxStartTask(taskHandle3)
    they actually not start at the same time since they are exectued in sequence. I wonder how much time delay will be if I start each task in sequence. Also, is it possible to have 2 or more tasks started at the same time?
    p.s. I think it will be easier if I could bind different channels to a single virtual channel but I don't think it is possible to create a signle virtual channel with analog channel and digitial channel.

    RobertoBozzolo wrote:
    I had success in doing something similar on the input side by sharing the same sample clock across the tasks with:
    DAQmxCfgSampClkTiming (DigitalTaskHandle, "/Dev1/ai/SampleClock", 1000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 1000);
    In my application I had the power to have the same acquisition speed on all tasks, so that the sample clock could be same on all of them.
    The conceptual framework is this one (pay attention to the step order):
    Setup your AO task
    Setup your DO task
    Set the DO task to share the AO sample clock with the instruction given above
    Start the DO task (IMPORTANT: it must precede the AO task start, so that DO task is started but does not generate samples)
    Start the AO task
    If you have different sample speed on the tasks, I suppose an alternative is to use a start trigger sharing some digital signal among them. I have seen examples that use a separate counter output as a start trigger.
    Thanks a lot. It gives me a good information, I think that will help. I am encountering another sitution, if task1 is analog output with continuous samples with rate 100000 samples/second and task2 and task3 are a single digital sample (i.e. write only 1 sample to one digital line). In task1, I write continuous samples and there will be a spike (of 2.2V) at the time 1.2ms after the task started. And I want to write to the digital channels (task2 and task3) at 0.2ms before the spike was set in task1. In this case, there is only one sample written to DO task, so how does it work to use the sample clock source?
    In your last suggestion, we could use tirgger but how does it help? Is there any example I can follow? Thanks.

  • How to synchronize two PCI-6602 via RTSI for semi-period counting of four signals?

    Hello,
    I try to measure 4 PWM signals. For that, I created 4 tasks (newest DAQmx), each with semi-period measuring one signal.
    I want to use DMA so I have two 6602 for each two signals.
    The task aquire a finite number of samples.
    This works fine when starting the tasks subsequently.
    Now I want to start the tasks via a trigger on the RTSI bus.
    But I have no idea how to get this done.
    I use the MX drivers for the first time an find it very difficult to get through the help files.
    I looked at many examples but did not find a solution.
    Most of the time my experiments end with an error message saying that the property is not applicable to this task, or s.th.similar.
    Ans sometimes, when there seems to be a trigger defined, the task will not wait for the trigger and time out.
    Is the anybody who can help me out of this?
    Maybe a little sample program?
    I program in CVI.
    Many Thanks
    Michael.

    This topic is discussed here:
    http://forums.ni.com/ni/board/message?board.id=250&message.id=13383&requireLogin=False
    Hope this helps!

  • How to synchronized two Timer Task ?

    I need to execute 2 job
    job1 every sec
    job2 every min
    when one task is executing other task should wait
    so i created 2 timer
    timer1 will execute secjob every sec
    timer2 will execute minjob every min
    and one job object with synchronized execute method
    please see the code for further detail
    problem:
    before completion of secjob , minjob started excuting
    job Fired Fri Oct 10 20:45:16 IST 2008 by Timer-0 ID :7.....
    job Fired Fri Oct 10 20:45:21 IST 2008 by Timer-0 ID :7.....
    job Fired Fri Oct 10 20:45:26 IST 2008 by Timer-0 ID :7....{color:#ff0000}*job Fired Fri Oct 10 20:45:31 IST 2008 by Timer-1 ID :8*{color}*.*
    {color:#ff0000}*...*{color}
    job Fired Fri Oct 10 20:45:34 IST 2008 by Timer-0 ID :7.....
    job Fired Fri Oct 10 20:45:39 IST 2008 by Timer-0 ID :7.....
    public class Fire {
        static void secJob(Job job)  {
             Timer timer = new Timer();
             int delay = 0;  
             int period = 1000*1; 
             SecJob secJob = new SecJob(job);
             timer.schedule(secJob, delay, period);        
        static void minJob(Job job) {
             Timer timer = new Timer();
             int delay = 0;  
             int period = 1000*60; 
             MinJob minJob = new MinJob(job);
             timer.schedule(minJob, delay, period);
        public static void main(String[] args) {       
            final Job job = new Job();
            secJob(job);
            minJob(job);
    public class SecJob extends TimerTask{
        Job job;
        public SecJob(Job job) {
            this.job = job;
        public void run() {
            job.execute(SecJob.class);
    public class MinJob extends TimerTask{
        Job job;
        public MinJob(Job job) {
            this.job = job;
        public void run() {
            job.execute(MinJob.class);   
    public class Job {
        private void sleep(long count,PrintStream out) {
            try {
                for (int i = 0; i < count; i++) {
                    Thread.sleep(1000*1);
                    out.print(".");
                out.println();
            } catch (InterruptedException e) {
                e.printStackTrace();
        public synchronized void execute(Class c) {
            Thread t = Thread.currentThread();
            if(c == MinJob.class ) {
                System.err.print("job Fired "+new Date()+" by "+t.getName()+" ID :"+t.getId());
                sleep(3,System.err);
            }else if(c == SecJob.class ) {
                System.out.print("job Fired "+new Date()+" by "+t.getName()+" ID :"+t.getId());
                sleep(5,System.out);

    I'd only use one timer and write a dispatcher task that stores the time at which job2 is executed. If the last time is more than one minute past, execute job1, reset the time tracking field, and execute job2.

  • How to synchronize two NI9215 DAQmx cards?

    Hi there,
    I'm using two NI9215 DAQmx cards (4ch simultaneous sampling analog inputs) in a chassis type cDAQ-9174.
    Since I need to aquire 8 channels simultaneously I've two NI9215 cards.
    My question is how do I configure these cards to be synchonized?
    I'm using LabVIEW2009 SP1 Dev. Suite
    Thanks for answers!
    Solved!
    Go to Solution.

    One of the beautiful things about CompactDAQ is that you can put multiple modules of the same time (Analog, Digital, etc.) into the same task and they are automatically synchronized.  So, to synchronize the two modules, create one Analog Input task and reference the channels as "cDAQ1Mod1/ai0:3, cDAQ1Mod2/ai0:3".  This will automatically synchronize the two modules together.
    Seth B.
    Staff Test Engineer | National Instruments
    Certified LabVIEW Developer
    Certified TestStand Developer
    “Engineers like to solve problems. If there are no problems handily available, they will create their own problems.”- Scott Adams

  • How to synchronize two USB webcams (each at 30fps) for a combined 60fps video? Three for 90fps?

    Hello All,
    Multiple-Camera Lab Application: How-To?
    Exploring a loose-synchronization for cameras, low resolution, B&amp;W=gray video capture, that may require up to 200fps, laboratory application.
    Frames would be recorded serially, from 1_frame/10msec at 100fps to 1_frame/5msec at 200fps.
    Consecutive frame-to-frame intervals do not need to be fixed at 10msec, they may vary a lot +/-50%, are non-critical.
    Video recording may last up to 1_minute maximum real time (no sound recording needed at any time).
    Specs say a generic USB2.0 webcam can record up to 30fps.
    And USB2.0 is a half-duplex serial protocol.
    Using two or more webcams in parallel, focused on the same scene, may yield a composite video capture at multiples of 30fps.And much lower price than a single dedicated high speed camera.
    Ultimately all frames have to be assembled -in sequence- into one big video recording.
    Any comments, any ideas? Did anyone try this?
    Thank you,
    Dan

    Hi,
    Sorry I am not much help about this. Creative webcams aren't built to work that way.

  • How to synchronize two Event Dispatcher threads?

    I have two applications running in the same jvm. The flow should go like--
    a) First application (A1) has a swing window containing componets like buttons, text boxes etc.
    b) On click of this button, Event Dispatcher thread (T1) , calls the other application (A2).
    c) The second application A2, creates a swing window using EventQueue.invokeLater method and in the mean time Thread T1 should wait for this new A2 window to get some results from the database.
    Is it possible to stop thead T1 in between without freezing the GUI components of application A2.
    Thanks

    I think what tjacobs01 is getting at, is that there is only one Event Dispatcher Thread per JVM. So your question does not make sense. If there really is two EDT threads, then you are dealing with inter-process communication (since there would be two JVM processes, one for each application).
    It sounds like there is only one JVM, one EDT and two instances of a java.awt.Window. You probably think of the window == an application. In that case, you can probably solve your problem by executing the DB access (the long-running task) in the doInBackground() method of a SwingWorker.
    http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html

Maybe you are looking for