12-22-2021 01:54 PM
Hey,
I am currently working (but I think this is an overstatement as I am facing a big problem at the very beginning) with calculating RPM for a project with DC motor - this is an example from the NI website - Motor Adapter for NI myRIO demo. The DC motor has encoder built-in.
I am using The Motor Adapter for NI myRIO, DC Motor/Gearbox (1:19 Gear Ratio), and of course myRIO.
I am trying to determine the rotational speed of the DC motor - in order to do this I am trying to go with steps:
1)Determine the number of shaft encoder counts for one revolution of the gearbox shaft output
2)Determine the gearbox output shaft angle in degrees.
3)Determine the RPM/RPS of the gearbox output shaft.
And I think I am a bit stuck - I found the gearbox ratio - 1:19 according to digilent website.
Then measuring "by hand" I found the number of encoder counts for one revolution of the sensor magnet - 12.
Then I am completely stuck. I do not know how to translate these numbers into the rest. Can anyone help me?
Solved! Go to Solution.
12-22-2021 03:42 PM
Hi senek,
@senek323 wrote:
Then I am completely stuck. I do not know how to translate these numbers into the rest. Can anyone help me?
You already know the encoder count. And you know the time your loop needs to iterate.
And you can easily determine the difference of the current encoder count to the count of one (or multiple) iteration(s) before by using a shift register.
The difference of those encoder counts divided by the time between them is your speed value: delta(count)/delta(time).
The other factors (12, 19) are just trivial math afterwards (aka scaling)…
12-22-2021 03:58 PM
I do not have a myRIO so I do not have any of the hardware specific drivers. That being said, from what I can see inside there is a loop with a simple timer. This isn't the greatest method but velocity =dX/dT. so (change in counts)/(Change in time) divide that by 12 to get revolutions per second. If the timer you use is a millisecond timer you will need to convert to seconds (or minutes). Divide by another 19 to get the output velocity of the shaft coming from the gearbox. note there are missing and greyed out vis.
Changing the mS timer to a metronome may be an improvement and note that your first cycle and any time you reset the counter will deliver a wrong RPS reading for that loop iteration.
I should have cleaned up the wiring more, but it is a quick example.