LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pulse counting in a timed loop

Solved!
Go to solution

Hey, GerdW

Yeah, so i am using a myrio, with a USB connection. Hmmmmm so is there anything i can do to show the number of counts in 100ms, if each square wave pulse is 5us (5us on 5 us off)? need to know if it is actually picking them all up. i need to post process the number of counts to get temperature and i will really like to know the temperature real time rather than storing the data and looking at it later. I also need to implement actions in the code based off the temperature. Any suggestions??

 

Does it help that i only want the total number of counts in 100ms. As a side note does labview enable anyway of storing a value after a period of time?

 

Sorry my VI was built off a example so i just left the sequence frame in.

And your quite right not sure why i left the timer in.

 

My most recent investigation is attached, using FPGA, the LED part was to see if there was more counts then being shown and the number of counts is consistent with the counter display so i definitely agree with you. Does this mean the Myrio has a different number on the board compared to the computer. I am quite confused on this as i assumed the Myrio was counting and just tell the computer the number it had, so i would understand if the number jumped due yo slow update but dont quite understand what to do here to solve anything. 

 

0 Kudos
Message 11 of 17
(1,161 Views)

Hey everyone,

To start off my apologies i am very new to labview.

 

(Using a LMT01 temperature sensor) I need to count the number of pulses in 100ms in a pulse train, each pulse is 5us on and then 5us off (square wave) i need the total number in 100ms to post process into a temperature. I'm having issues with counting the pulses. 

 

I have a counter (see attached) but it is only picking up the start of each pulse train (the timer is at 5 seconds so i could work out if this was the case.). I am using the FPGA of the Myrio, and looking at the interface on the computer, (USB connection) is this part of my issue? Regarding update speed? Currently i am counting 500 pulses in 5 seconds which translates to the start of each pulse train. Could this be an issue with a built in de-bouncer in labview?

 

So, 

How can i count pulses in a micro second range?

and

How can i store a number to be used in a maths script?

 

Kindest Regards,

Aaron Page

0 Kudos
Message 12 of 17
(1,187 Views)

Zip up all of your code and post that.  The project file is next to worthless since it just points to other files.

 

But at the top of my head, you need to use a Single Cycle Timed Loop (SCTL) to look at the digital line.  In the SCTL, each cycle will take 25ns (40MHz clock).  So each time you detect a rising edge (previous read was FALSE and current read is TRUE), increment your counter.  You can add some more logic in there to command to start looking and only run for 100ms.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 13 of 17
(1,173 Views)

My apologies, i have reattached a zip file including all files of my most recent approach. 

 

So sorry just to see if i understand you right, i would need a single cycle timed loop (which is just running the timed loop structure once right) to look at the myrio input read on (digital line), then using a shift register to pass the number out of the single loop. This would all need to be inside a while loop i assume? 

 

Is it okay just to use a Boolean compare to compare the signal with a reference and use this output on a select to decide whether to add one or not. ( as done in my current approach), or should i find a way to compare future events with past events?

 

I will look into trying to make this. Once i have my counts (so say this works) how can i display this total count value and update it with a new value, such that i am just displaying the final count number and not the incrementation.

 

0 Kudos
Message 14 of 17
(1,152 Views)

@AaronPage wrote:

So sorry just to see if i understand you right, i would need a single cycle timed loop (which is just running the timed loop structure once right) to look at the myrio input read on (digital line)


No.  This loop should run on the FPGA and never stop.  Inside the loop you can do the comparisons and keep the count.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 15 of 17
(1,135 Views)

Hi,

So i have done what you have said and i now count all the pulses. 

 

How can i reset the count in the FPGA? (i was using the expresstime in the normal coding but doesnt appear to be in the FPGA) Is there any way of saying no new counts in 5 ms reset?

 

How can i take the number at the end of the pulse train? and put this into a maths script?

 

Thank you so much for your help!

0 Kudos
Message 16 of 17
(1,131 Views)

AaronPage wrote:

How can i reset the count in the FPGA? (i was using the expresstime in the normal coding but doesnt appear to be in the FPGA) Is there any way of saying no new counts in 5 ms reset?


You know how much time a single loop is.  So just use a counter (number that gets stored in a shift register and incremented each iteration) and when that count reaches your ms, set it back to 0 (I recommend the Select function there).  Also, when you reset your counter is when you update the frequency indicator.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 17 of 17
(1,112 Views)