LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

having trouble getting RPM from prox sensor

I've been trying to use a proximity sensor to find the RPM on a dyno, but am having some trouble with the LV coding (I'm new to LV).  Using a cRIO 9012 with NI 9205 module.  The prox sensor basically gives about an 8V signal when a tooth on a gear passes in front of it (theres 15 teeth).  While I can get the counter part going, I can't get anything after that part in the code to work, in order to find the RPM.  I think one problem might be with timing, where the prox sensor will be going at about 500 Hz, so I'm not sure if thats giving the differential function problems?  Is a timing loop even the right thing to use?  Eventually I'd like this to run standalone on the cRIO and write to a USB stick but I know how to do that part.  If anyone could help me solve this or let me know a better way to find the RPMs it would be much appreciated.  I've tried everything I can think of, I couldn't get functions that find the frequency or period to work when I made the signal into a waveform (square wave) even though I thought that would be the simplest method.  Thanks! LV prox.jpg

0 Kudos
Message 1 of 12
(3,074 Views)

hey c ryan!

 

If you are trying to read a signal of 8V highs and close-to-zero lows, you are right in thinking the simplest way would be to read in the signal as a waveform and find its frequency.

 

Is the 9205 the source of the 8V high, and is that the information being passed through the variables AI0 and AI8? If so, it looks like you are passing the data as a single double input. You need an array to make it a waveform, which is probably why the functions you mentioned were not working. When you tried to use them, what error messages did you receive?  

 

In general, is there a reason you are using a proxy server? It is usually much easier to read directly from your device. 

 

~kgarrett

 

District Sales Engineer
0 Kudos
Message 2 of 12
(3,046 Views)

yes the voltage signals are coming thru the 9205, thats what the AI0, AI8 are variables for.  I believe I had tried making it an array before passing it thru a function to find frequency.  I didn't get error messages for those, it just didnt return any data (period=0, frequency= infinity).  

 

How do I go about reading directly from the 9205?  I didn't know I could do it a different way.  Thanks for your help!

0 Kudos
Message 3 of 12
(3,043 Views)

c ryan, 

 

You should take a look at the LabVIEW examples specific to cRIOs (LabVIEW Help > Find Examples > Hardware Input and Output > CompactRIO)? Under the Basic IO folder, there are a few good examples for reading analog input, and there is even an example in the Module Specific folder designed for a 9205. For that latter example, you would need to change your chassis to be the 9111 (add a new chassis, and move the module under that chassis).

After you have the signal, you can just count the number of time the signal is greater than 7V (or some threshold that will be sure to catch the 'highs' indicative of a tooth passing the sensor). Every time this count is a multiple of 15 (15 teeth per revolution), you could log the time. This would give you an effective RPM.

 

~kgarrett

District Sales Engineer
Message 4 of 12
(3,027 Views)

great thanks a lot!  I don't know why I haven't used that "find examples" app, looks like this will definitely be helpful.  Looking at the 9205 example, I'm a bit confused where I would run my calculations... would they go in the second frame of the sequence structure (read/write IO data) and get data from the AI Data terminal?  Also, since I'm using AI0 and AI8 for the connections on the 9205, is that AI channel 0 or would I have to change those wires to different module terminals? 

0 Kudos
Message 5 of 12
(3,025 Views)

as for my second question in that last reply I think I found the answer, leave the wires in the same terminals and use the DIFF setting in the resource parameters box on the front panel of the VI for channel 0.  Now that makes sense 

0 Kudos
Message 6 of 12
(3,024 Views)

hi c ryan, 

 

you are right that the mode needs to be set to DIFF to read off of AI0 with reference to AI8. to add your calculation, you will open the NI 9205 Basic IO (Host).vi and unbundle the Analog Input cluster. 

Analog Input.png

Do this by adding an Unbundle by Name node. Once you have it unbundled, you can add the logic necessary to go from number of 8V highs being read to RPM. Hope this helps. Good luck!

 

~kgarrett

 

District Sales Engineer
0 Kudos
Message 7 of 12
(3,006 Views)

I figured that much oout, now I am having trouble getting the data to output RPM.  I tried the waveform frequency functions again but they didn't work.  I tried the original derivative method in my first code that I posted, and got the same results as before, when I was reading in data wrong.  I've got a counter running, so it adds a count for each tooth, but I'm confused how I use that with getting the time to find the RPM?  I'm pretty lost and have been trying things all day...

could you be pretty explicit in how to do that?  

 

I attached my VI

0 Kudos
Message 8 of 12
(3,003 Views)

I may have just figured it out, just discovered shift registers, which will help with timing

0 Kudos
Message 9 of 12
(2,999 Views)

hi c ryan, 

 

so it iw working now?

 

~kgarrett

 

District Sales Engineer
0 Kudos
Message 10 of 12
(2,983 Views)