01-16-2018 07:21 AM - edited 01-16-2018 07:24 AM
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,
01-16-2018 07:36 AM
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)
01-16-2018 08:48 AM
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.
01-16-2018 10:11 AM
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 ++;
01-17-2018 12:14 AM
Thanks, you gave me a thought-provoking Impulse !
Problem solved.
01-17-2018 12:41 AM
I am glad I could help
Good luck with your project!