LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Iteratively counting up from 0 to 4 and counting 4 to 0

Highlighted

@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.


 

 

 

triangle2.png

 

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

Message 11 of 17
(182 Views)
Highlighted

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

triangle_wave.png

 

and then auto-index a For Loop...

Message 12 of 17
(153 Views)
Highlighted

@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
(146 Views)
Highlighted

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
(132 Views)
Highlighted

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

 

CountUp.png

Message 15 of 17
(126 Views)
Highlighted

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:

0 to 4 in subvi.png

 

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
(118 Views)
Highlighted

Just for fun.

Loop0-4.png

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."
Certified-LabVIEW-Developer
Message 17 of 17
(116 Views)