LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using an events count and a difference of counts, how can I set up a cyclometer function?

Hi,

 

First of all I have very little experience with LabView and I'm currently trying to develop a cyclometer as follows:

There are 4 magnets in a wheel. A reed swtich is attached to the frame which activates when a magnet passes by, therefore 1 revolution = 4 counts.

 

I have a Count Digital Events code and a Difference of counts (both attached below) but I'm getting confused on how to integrate or use both to create a cyclometer function. I want to be able to calculate the distance traveled, velocity with moving average, velocity without moving average and average velocity(overall).

 

So far I think I got the total distance figured out:

Using the Count Digital Events code, I count a number of counts, the divide by 4 ( because there are 4 magnets). This gives me 1 revolution. Then the tire has a circumference of 2*pi*r, therefore the total distance is: (number of counts/4)*(2*pi*r).

 

My next step was to calculate the velocity. My idea is that if I set the Count Digital Events code to run the loop every second, I will get a measurement of counts per second, which then I can convert to velocity and rev/min.  However I have attempted to do this but I can't figure out a way to make the Count Digital Events code do this, or even if this is the correct approach to calculate the velocity.

 

Once I get the instantaneous velocity and distance figured out I will go onto figuring out how to do the velocity with moving average and average velocity overall. Also, I believe I should use the Difference of Counts code but I'm not sure how it would be helpful.

 

Thank you for your help and time!

 

Alex



Download All
0 Kudos
Message 1 of 3
(2,089 Views)

I'm thinking it might be easier to have the counter measure frequency at a 100Hz rate (depending on your desired speeds, that number was kind of just made up).  Divide the frequency by 4 (4 sensors), and your velocity is 2*pi*r*f/4 = pi*r*f/2.  Distance is then simply x1 = x0 + v1*t where t is 1/sample rate.  It is also simple to keep the velocity in an array to calculate a moving average and straight average.

 

If you need help figuring out the counter setup, I can provide more help tomorrow when I have all of my resources (LabVIEW, DAQmx, previously used code) available.


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
0 Kudos
Message 2 of 3
(2,075 Views)

Hey crossrulz,

 

Thanks for your help. The thing is that I'm not sure if you can set the code to measure at a frequency of 100Hz, I'm guessing I would have to modify what I already have. If you have a chance and open the Event Count code, there is a clock, like a motronome which says 100 I think for now. Because LabView only takes milliseconds I thought that you could set that to 1000ms which would be 1 second. Attached is a photograph of the code for that part, but I'll try and submit better print screens later when I have acces to LabView. However what you are suggesting sounds like a better approach + it sets up well everything to continue with the other calculations, but could you explain me if you have some time on how to do this with your approach?

 

Thanks a lot!

0 Kudos
Message 3 of 3
(2,068 Views)