LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

resetting counters

My application needs me to count after an external switch is triggered, and then count after another external switch is triggered. It is somewhat an oscillating table with two switches on either end. The way I have it set up is one switch will input a value of -1, and the other 1. So I have a case structure with the code in each case representing each count. It works fine except I need to reset the count each time. I've tried shift registers, but it still seems to just pick up count where it left off. Any help would be appreciated.

0 Kudos
Message 1 of 4
(2,246 Views)

I'm having a hard time understanding what you're trying to do here.

 

You've got two while loops at the beginning of your program which are going to slam CPU while looking at value of Control x.

It seems the purpose of these loops is to record the first time the +1 switch triggers.  The loops checking for 0 doesn't really serve a purpose other than to record the time when the program started.

 

After the first +1 switch trigger, the main loop starts to execute which also bangs CPU.  If the -1 Switch triggers or nothing happens, the millisecond timer value is updated with the difference in time from when the first +1 switch triggered and millisecond timer 2 is reset.  If the +1 switch triggers, the millisecond timer 2 value is updated with the time difference from the start of the program and millisecond timer 1 is reset.

 

Can you clarify which parts of the described behavior are incorrect?

0 Kudos
Message 2 of 4
(2,239 Views)

tavwtby,

   I'm having a little trouble understanding what you're trying to do. Mind clarifying a bit? And if you simply wish to reset the count after a trigger is hit then why not just use another case structure which resets x to zero when the trigger is hit?

 

--Ryan

0 Kudos
Message 3 of 4
(2,238 Views)

I actually posted the vi after I was fooling around a bit and forgot to go back to my original design. I was actually able to get what I needed by using two elapsed timing vi's and setting the time target to a high number and having the switches equal to the value to reset them. I wired an indicator to the elasped time output to count. Sorry for the confusion, and thanks for the reply.

0 Kudos
Message 4 of 4
(2,220 Views)