LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start timing when no pulse

Hello all,
 
I am in need of help. I've created a VI that can count the no. of pulses when an input is feed into the DAQ card. Attached is the counter.VI i've created.
 
However I also need to find the elapsed time when no pulses (no count) is given in. Meaning, when there's no count, a clock will start timing and stop once the counter begins to count again.
 
 
regards,
aisyah.
0 Kudos
Message 1 of 11
(3,683 Views)
Hello aisyah,

What you want to do sounds relatively straight forward, but there is a caveat.  Since you are using a third party device (the EMANT300 VIs in your program appear to be for a third party device),  I can only help you with doing this in software.  It may be possible to use timestamps on the pulses or something else in hardware to make it more accurate, but that depends on the VIs for your device. The way I tried will only work down to the iteration time of your while loop.

I used a case statement to read whether there are pulses being read (one case=0, the other is "default").  If there are pulses being read (default case), then I pass a new timestamp into the shift register and leave the indicator the value it was:


If there are no pulses being read (case 0), then I subtract the current time with the shift register time (the last time that pulses were being read) and output that (elapsed time from last pulse is shown on indicator):



This way, I get the time elapsed from the last pulse and when I am reading pulses, I get the previous length of the gap.  Another method would be to use the Time Elapsed Express VI (in the timing pallete) and use the Equal to Zero? VI into the reset.  This would reset the express VI if there are pulses, and then run if there are no pulses.

I hope this helps you out, if I did not explain this well enough or you have any other questions, feel free to post back.


Message Edited by Neal M on 11-14-2007 05:20 PM
Neal M.
Applications Engineering       National Instruments        www.ni.com/support
Download All
0 Kudos
Message 2 of 11
(3,661 Views)
hey!!
 
thanks a lot for your suggestion! i would try it out and get back to you if i have any doubts.
thanks a lot.
0 Kudos
Message 3 of 11
(3,647 Views)

Hi Neal M,

I've tried on using the case structure. But it is not working as expected. The attached VI is the improved VI, of which there are additional functions to it that I've included for my project. I've also incorporated your suggestion to my problem. However it is displaying the elapsed time when no inpulse is fed in.

I hope you could identify my mistakes so I could correct them.

Thanks.



Message Edited by aisyah on 11-17-2007 09:04 AM
Download All
0 Kudos
Message 4 of 11
(3,634 Views)

i'm sorry, the attached VI is the wrong VI.

below is the current one of which i'm improving on.

0 Kudos
Message 5 of 11
(3,623 Views)

Hello again aisyah,


If I understand what is going on, the timer is running when you start your VI, but before pulses are read.  This is to be expected with the way the program has been setup since it is actually timing "time 0 pulses have been read" instead of "time between pulses."  I was able to work around this by using a boolean to tell if there have been no pulses previously.  I have attached a VI that demonstrates this.

I hope I explained this well enough, if you have any questions or other problems, post back.
Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 6 of 11
(3,600 Views)

hey,

thanks a lot for the VI. unfortunately i'm only using Labview 8.0. Smiley Very Happy could you attach the PIC instead?

about the input data, the DAQ is receiving HIGH/LOW inputs which is working on the wheel encoder principal. The black/white reflective surface will be detected by the sensor to give the HIGH/LOW inputs. The DAQ will count the input for processing. Therefore, when the DAQ receives/detect no changes of the HIGH/LOW input, i would like the rest time to start counting.

hope this clears your understanding about my problem.

0 Kudos
Message 7 of 11
(3,576 Views)
Hey aisyah,

The VI should work for your application.  The problem we are trying to fix now is to make sure that the timer does not start before there is some movement (i.e. the rest time from when you start the VI to when the "wheel" turns), correct?

Assuming this is right, attached are my pics of the vi that does this (which I had attached before).  Happy programming.
Neal M.
Applications Engineering       National Instruments        www.ni.com/support
Download All
0 Kudos
Message 8 of 11
(3,556 Views)

Hi Neal,

I'm still stuck at building the VI that will start timing when the pulse is reading 0. I've followed your block diagram, but still it won't work. Could youe explain the function of the case structure so I could better understand the form.

 

regards,

aisyah

0 Kudos
Message 9 of 11
(3,452 Views)
Hello aisyah,

No problem, I will step through the program sections and explain what each section is for:


Case Structure:  The case structure looks at whether there are pulses being read.  If there are pulses read that iteration (>0), then it effectively "resets" the initial time (the time in the shift register). If, however, there are no pulses read, then it takes the difference between the inital time and the current time and displays that (in the numeric indicator).

Selector: The selector is to determine whether pulses have ever been read before.  If no pulses have ever been read, then it does not allow the time to be passed to the indicator.  We added this since you did not want to display the elapsed time from when you started the VI till when the very first pulses were read. Once a pulse has been read, we chage the boolean to true and always use the true selection for the rest of the program.

Random Number Generator:  I just use this to simulate whether I read "pulses" by passing either a 0 (no pulses) or a 1 (>0 pulses).


I hope this clears things up.  If my explanation was not understandable, please post back.


Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 10 of 11
(3,434 Views)