LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring time to get certain number of ticks from Digital output of a sensor

Solved!
Go to solution

Hello Everyone,

I am using speed sensor MX5015 through sbRio-9636 board.My target is to measure the time when the sensor gives 40 rising edge and repeat it. To get this, I put a counter. If the counter is equal to 40, then I am trying to get the timing through Tick count expresss VI (screenshot). But it is not giving me the time till the sensor get 40 rising edge.

Can you please tell me what is the problem with this method? or is there any other method by which I can measure the time?

digital input.PNG

I am new in LabVIEW. so if I did someting really stupid, please forgive me. 🙂

Best Regards

Sazzad

0 Kudos
Message 1 of 6
(3,079 Views)
Solution
Accepted by topic author Legolas-Elf

You've answered your own question.

 


Sazzad wrote:. If the counter is equal to 40, then I am trying to get the timing through Tick count expresss VI (screenshot). But it is not giving me the time till the sensor get 40 rising edge.

 



 Also, you have an infinite while loop once the count equals 40 and the true case run, the loop inside of it will run forever because you have a False wired to the stop terminal.

Message 2 of 6
(3,056 Views)

Hello Knight of NI ,

Thank you for pointing me out the mistake. I change the conditional terminal of while loop to True and it is giving me the time. Smiley Very Happy

But the problem is now the time it is counting is when I start running the program. I want to count the time when the digital input start to giving pulses. In order to do this I gave a case structure so that if digital input give pulses the tick count will start (screenshot below). But this is not working.tick count.PNG

Do you have any suggestion how to solve this problem?

Thank you.

0 Kudos
Message 3 of 6
(3,031 Views)

Hi Sazzad,

 

I change the conditional terminal of while loop to True and it is giving me the time.

I don't think so: right now you should get either zero or just some ticks because you subtract two tick values read immediatly one after the other!

 

Why don't you clean up your blockdiagram to improve its readability?

 

I want to count the time when the digital input start to giving pulses.

Then you need to program this condition! Right now you try to read the loop time when the counter is equal to 40…

When do you want to stop the time counting?

 

Just a suggestion:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(3,025 Views)

Hello GerdW,

Thank you for your suggestion. I followed your suggestion and the block diagram is below. I put a while loop inside because if I put the Tick count only inside the Case structure i am not getting any time. I hope now the readability is better. Smiley Happytick count.PNG

But in this way the time is starting when I run the program. So i am getting the total time for how long the program is running. I think it is because the tick counter outside the big while loop is starting when the program start to run.

I want to get the time when the counter value is between 1 to 40 and then the time will become 0. It will start counting again when the counter is 1.

So where should I put the tick counter so that It only starts when Counter value is 1?

Thanks a lot for your helping and all your good works.

 

 

 

0 Kudos
Message 5 of 6
(2,998 Views)
Solution
Accepted by topic author Legolas-Elf

Hi Elf,

 

I hope now the readability is better.

No. Still lots of bended wires and right-to-left flow…

Just use AutoCleanup!

 

I want to get the time when the counter value is between 1 to 40 and then the time will become 0. It will start counting again when the counter is 1. So where should I put the tick counter so that It only starts when Counter value is 1?

You need to program all this - it mostly is missing in your VI!

- set a start time when your counter == 1

- calculate the duration when your counter == 40

- Why do you want to set the time to zero just after calculating it? Your FPGA will do this within nanoseconds: no chance to read the value from your RT host!

 

Start by drawing an algorithm on a sheet of paper, then do the programming… 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 6
(2,995 Views)