ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Step counter

How can I simply create a step counter which count from 0 to 9 after I give an input with a switch impulse? (in C its only a IF - THEN structure and in the THEN Part it's x = x+1)
0 Kudos
Message 1 of 12
(5,537 Views)
I have included a VI (in LV 6.0) which will help you if i have understood you correctly. Basically i have wired a switch to change a CASE structure which contains an indicator. This indicator is enclosed in a For loop (to run 10 times) and upon each iteration the numeric is updated.

I hope this helps you..

Kim
0 Kudos
Message 2 of 12
(5,537 Views)
There are various ways to do this in LabView. Probably the most flexible is with an Event Structure. Probably the simplest is to read the switch in a loop and to increment a counter any time the switch value changes: use shift registers for the switch value (so you can detect when it changes) and for the counter.
See the attached LabView 6.1 example.
0 Kudos
Message 3 of 12
(5,537 Views)
Sorry, after seeing Kim's answer, maybe I misread the question. Kim's case looks fine (a LabView case structure can be used an the equivalent of an if statement).
0 Kudos
Message 4 of 12
(5,537 Views)
Your example, you've send me is nearly that, what I nee. But there is a problem. I wanna use it as a push-button and with each push (only at the time you press the button) the counter should increment +1.
0 Kudos
Message 5 of 12
(5,537 Views)
OK, i've updated the example VI to include a shift register and changed the mechanical action of the push button to 'latch when released' so will reset and the loop will run through again after each press.

Kim
Message 6 of 12
(5,537 Views)
Thank you very much for your help. That is excatly what I need.
0 Kudos
Message 7 of 12
(5,537 Views)
Always great to help..

*smiles*
0 Kudos
Message 8 of 12
(5,537 Views)

Hi,

I am going to piggyback this thread because it is half of what I'm trying to do.  In addition to the step counter, I am trying to figure out a way to have the counter reset to 1 instead of terminating the while loop.  So the counter would go ...7, 8, 9, 1, 2, 3...etc.  And the while loop can simply be terminated with a control.

 

If anyone has any thoughts I'd really appreciate it.

 

Thanks in advance.

 

Mike

0 Kudos
Message 9 of 12
(5,007 Views)
Message Edited by Ravens Fan on 03-11-2009 11:20 PM
Message 10 of 12
(4,994 Views)