# LabVIEW

cancel
Showing results for
Did you mean:

Highlighted

## Re: Iteratively counting up from 0 to 4 and counting 4 to 0

@Armagedon wrote:

Please, enlighten me how I can iteratively count up from 0 to 4 and count down from 4 to 0 with 0.1 sec delay.

state will cycle from 0, 1 ... , 4, 3 , .., 0, 1 ...

Message 11 of 17
(183 Views)
Highlighted

## Re: Iteratively counting up from 0 to 4 and counting 4 to 0

you can also do a "rectified" triangle wave like this:

and then auto-index a For Loop...

Message 12 of 17
(154 Views)
Highlighted

## Re: Iteratively counting up from 0 to 4 and counting 4 to 0

@Armagedon wrote:

Likewise, I will try to change it as it would go to 0 after reaching 4 and then start counting until 4 again.

From this remark I get the feeling OP wants to go 0,1,2,3,4,0,1,2,3,4 AND\OR 4,3,2,1,0,4,3,2,1,0, not 01,2,3,4,3,2,1.

The title implies there is a 4-0 count down, but that could be in parallel of the up counting.

Of course, if you can count up from n=0-4, counting down is simply 4-n...

Message 13 of 17
(147 Views)
Highlighted

## Re: Iteratively counting up from 0 to 4 and counting 4 to 0

OMG. You are so exactly on the point. Yes, I made mistake while writing the title.

What I am looking for was 0,1,2,3,4,0,1,2,3,4,0 and so on.

Message 14 of 17
(133 Views)
Highlighted

## Re: Iteratively counting up from 0 to 4 and counting 4 to 0

Here is another way to do it (delay set to 1 s so you can see it counting).

Message 15 of 17
(127 Views)
Highlighted

## Re: Iteratively counting up from 0 to 4 and counting 4 to 0

Yes, it can be quite simple.

But none of the simple solutions will fit into an existing application, working as a simulation for a real device.

And we can't really suggest a solution for that, as it will depend on the existing structure...

If you have some driver VI that gets called in a loop, you'd could do something like this:

This can be called as often as you like, but should  be called significantly more often then 5 times per second for good results.

Message 16 of 17
(119 Views)
Highlighted

## Re: Iteratively counting up from 0 to 4 and counting 4 to 0

Just for fun.

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Message 17 of 17
(117 Views)