LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI different Timers

Hi,

i Need some help to use two different timers in cvi (use with CVICallback).

I have tried several things, but with no really good solution.

 

What i want to do:

1.) I have two timers ( 1rst: 10seconds  2nd: 20seconds)

2.) With a START button i want to start the first timer(only one cycle ->10secons)

3.) If the cycle from the 1rst timer is elapsed, the second timer should be started.(also only one cycle)

4.) If the cycle from the 2nd timer is elapsed, the first one should be started again.(only one cycle).

5.) if i press a STOP button, all timers should be reseted.

6.) If START is pressed again ......Point Nr. 2...

 

It is like a pulse Generator, but i want to start every pulse manually.

 

I have written a code, with Timer CVICallback and Events: EVENT_TIMER_TICK....

Maybe anyone can give me a short example.

Many thanks,

0 Kudos
Message 1 of 6
(3,503 Views)

Would it be feasible for you to use just one timer plus one variable for couting the timer ticks? For me this looks simpler as in your callback you just need to check if your variable is a multiple of three ("second timer" finished) or a multiple of three plus one ("first timer" finished)

0 Kudos
Message 2 of 6
(3,499 Views)

Hi Wolfgang,

Thanks for fast feedback.

This  would be also a good Solution.

Could you send me a Short Code.

(Only code- no Uir...)

Thanks.

 

 

 

0 Kudos
Message 3 of 6
(3,483 Views)

a rough sketch of code:

 

switch ( event )
{
    case EVENT_TIMER_TICK:

        if ( ( ( counter -1 ) % 3 ) == 0 )
        {
        // "first timer" finished;
        }

        if ( ( counter % 3 ) == 0 )
        {
        // "second timer" finished;
        }

        counter ++;

Message 4 of 6
(3,477 Views)

Thanks, you gave me a thought-provoking Impulse !
Problem solved.

0 Kudos
Message 5 of 6
(3,464 Views)

I am glad I could help Smiley Happy

Good luck with your project!

0 Kudos
Message 6 of 6
(3,462 Views)