LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using an encoder to read RPM

Hey everyone. 

I'm running 2017 (I should probably update)

I have a 100 pulse TTL shaft encoder. Standard stuff, 5v. 

I've check my output with and Oscope and it works fine. 
I've changed my digital I/O card to read input. 

I do NOT know how to actually read the data in a VI. 
I know this is probably first day stuff, but I cannot seem to figure it out. 
I have thermocouples in the VI, DC current readings, but I can't seem to figure this one out. 
When I drag the channel from the project screen it gives me the Green icon and I don't know what to do with it from there. 

 

My end goal is to have two speed sensors, one will be the motor speed of the driver and one and will be the shaft speed of the driven. If the two don't match X amount of times over a period of time, something broke and an alarm will go off. 

 

Anyway, thanks for any tips or help! 

Ryan 

 

0 Kudos
Message 1 of 23
(4,919 Views)

Hi Ryan,

 


@ryan1776 wrote:

I'm running 2017 (I should probably update)

I've changed my digital I/O card to read input. 

I do NOT know how to actually read the data in a VI. 
I know this is probably first day stuff, but I cannot seem to figure it out. 
I have thermocouples in the VI, DC current readings, but I can't seem to figure this one out. 
When I drag the channel from the project screen it gives me the Green icon and I don't know what to do with it from there. 


What have you tried so far?

Which of the example VIs regarding digital inputs or counters have you tried to explore?

Which DAQ device do you use?

What is a "Green icon"?

 

(IMHO LV2017 is still fine, I use it for daily work…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 23
(4,886 Views)

Unless you run on  a LabVIEW FPGA target you can’t do reliably RPM measurement with digital input only. You need a gated counter for that where the gate is controlled by a programmable clock. What hardware do you have?

Modern NI multifunction DAQ devices have almost all one or two counters available which can be used for this. DAQmx counter functionality supports this easily albeit it’s each time a little work to make it work exactly like you want.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 23
(4,879 Views)

I was able to get it to show an indicator light, ON and OFF as I turned the encoder. It won't blink fast when I turn the encoder, but at least it sees a signal. I just created an indicator off the terminal. 

 

Sorry the green icon, is the terminal from the hardware that I should be able to get the signal from. 

terminal.JPG

 I'm using NI 9149 chassis and the 9401 card. 

 

I'll be honest, I just don't know how to go about it. 

I've tried Timing and transition measurements with Frequency, just to get a counter or something. Didn't work. Always gives me an error, "amplitude of the waveform is zero."

 

0 Kudos
Message 4 of 23
(4,843 Views)

I think I'm getting closer. 
It was suggested by a coworker to get the encoder to at least "count" the pulses. 

Under the project menu, I changed the properties of the channel to as follows.

Counter.JPG

 That changed my terminal in the block diagram. 

I created an indicator and was able to increase the number just by turning the encoder. 

 

0 Kudos
Message 5 of 23
(4,832 Views)

The counter is a much better solution as long as the motor only spins in one direction.  If it stops and reverses, you will need to implement the full encoder function in the FPGA to keep track.

 

Now you just need to read the counter at a specific interval and do the math to get the speed.

Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.0, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 6 of 23
(4,814 Views)

So I connected a freq generator. And I'm able to get a counter to work.

Or frequency. 

I'm sorry, but I'm REALLY dumb here.

Someone talk to me like I'm 4. Because I feel that way! 😫

0 Kudos
Message 7 of 23
(4,803 Views)

Hi Ryan,

 

simple math to calculate (rotational) speed from encoder counts:

 

x0 = encoder count at t=t0
x1 = encoder count at t=t1
dx = x1-x0
dt = t1-t0
ppr = pulses per revolution

speed = dx/dt * 1/ppr

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 23
(4,773 Views)

I couldn't get anything to work.

Using it as a straight counter, all it would do is count. I couldn't get it to actually give an RPM. 

(I realize now, I think I need to program it to reset the counter at a given period to make that work-not sure how to do that either)

I went back to frequency and I couldn't get that to work either. 

I then tried Period measurement and I got that to work.

What's the difference to labVIEW between freq and period measurement? 

 

Here's what I have and how I configured the channel. It does work, and shows the correct RPM using a drill, which I verified on another data acquisition system. 

RPM.JPG

My next goal is to compare two rpm inputs and if they don't match one every 10 seconds I need to stop the VI....

What I don't know is, can I constrain LV to only look at whole numbers for that comparison?

Because if it reads out to the 10000th decimal it'll never match.

Maybe it's better to create a envelope, meaning, if the RPM I want to compare to is 2000 rpm, I want a window of +/- 50. 

So if my target RPM hits 2040 the timer is reset, if it his 1965, same thing. 
But if it only gets to 1000 over 10 seconds, it stops. 

 

Can I get two rpm speeds to show on one waveform, or some output like the waveform at once? 

If so, how? 

Thank you everyone!

Ryan

0 Kudos
Message 9 of 23
(4,746 Views)

Hi Ryan,

 

I don't see any shift register. Usually you should use a shift register to store (counter) values of previous iterations for use in next iteration.

 

How do you want to calculate any differences as sketeched in the pseudocode above?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 23
(4,742 Views)