How to count rotational speed(preferred method) of a wheel using Pyboard

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
abraju
Posts: 4
Joined: Fri Mar 20, 2015 3:33 pm

How to count rotational speed(preferred method) of a wheel using Pyboard

Post by abraju » Fri Mar 20, 2015 3:40 pm

Hi,
I brought Pyboard a couple of days back. I am trying to use Pyboard for the first time. I would like to count the rotational speed of a wheel in terms of revolutions per min. I would like to know the preferred method/easiest method to count. Thanks in advance.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: How to count rotational speed(preferred method) of a wheel using Pyboard

Post by dhylands » Sat Mar 21, 2015 12:49 am

Hey abraju, It depends on whether your wheel will only ever be going in one direction or in both directions.

For both directions, you'll use something called a quadrature encoder. There is hardware support for quadrature decoding.

For a single direction you can use a single line and count pulses. I believe that there is hardware support for this as well. Depending on the speed of the wheel and the number of pulses per revolution, it may be possible to do this in software.

Can you provide more details?
i.e. single or bi-directional, number of pulses per revolution, max RPM required?

abraju
Posts: 4
Joined: Fri Mar 20, 2015 3:33 pm

Re: How to count rotational speed(preferred method) of a wheel using Pyboard

Post by abraju » Sat Mar 21, 2015 5:32 pm

Dear Dhylands, thanks for your reply.
Well, I require measuring speed in one direction. Motor shaft does not have quadrature pulse encoder, except a slotted wheel. I would have used pulse frequency to voltage converter and then use ADC for measurement. But I wanted to count pulses and interested in details of micro-python software utilities available and procedure which will make this task easy.
Thank you in advance.

abraju
Posts: 4
Joined: Fri Mar 20, 2015 3:33 pm

How to count rotational speed(preferred method) of a wheel using Pyboard

Post by abraju » Sun Mar 22, 2015 2:08 pm

Hello,
Thanks a lot for your reply Mr. Dave Hylands.
Well, my requirements are as under:
Measurement of speed is required in one direction only
There are about 8/10 pulses for one revolution
Maximum rpm is about say 3000 rpm.
Since I am new to Pyboard, I wanted to know what available features/commands of micro-python and hardware pins available can be effectively used for this task to be carried out easily. Can you give me some hints?
Thanks in advance.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: How to count rotational speed(preferred method) of a wheel using Pyboard

Post by dhylands » Mon Mar 23, 2015 1:35 am

So, 3000 RPM = 50 RPS (revs/second).

10 pulses/rev * 50 revs/second = 500 pulses/second. So that's a low enough rate that you can do it entirely in SW using the EXTI module. The EXTI module causes an interrupt to be generated for each rising/falling edge.

Depending on how clean the signal is, you may need to do either external debouncing or SW debouncing. See the following links for excellent background on what debouncing is and why and when its needed:

http://www.embedded.com/showArticle.jht ... D=18400810
http://www.embedded.com/showArticle.jht ... D=18902552
http://www.embedded.com/showArticle.jht ... D=22100235

Here's a link to the ExtInt documentation: http://docs.micropython.org/en/latest/l ... xtInt.html
You can also use a timer and the input capture mode to measure the width if a pulese, or the time between pulses.
This example measures the width of a pulse:
https://github.com/dhylands/upy-example ... ic_test.py

abraju
Posts: 4
Joined: Fri Mar 20, 2015 3:33 pm

Re: How to count rotational speed(preferred method) of a wheel using Pyboard

Post by abraju » Tue Mar 24, 2015 5:17 pm

Thanks a lot Dave Hylands for speedy reply. I will work on the hints and inputs given by you for measuring the speed.
Thanks once again.

ayadmk
Posts: 1
Joined: Fri Sep 04, 2020 4:31 pm

Re: How to count rotational speed(preferred method) of a wheel using Pyboard

Post by ayadmk » Sun Jan 16, 2022 5:48 pm

I am sorry, but if I have bidirectional movement with quadrature encoder 500 PPR and maximum motor speed 3000 rpm, I have RPI 4B 4GB.
What is the solution, please?

Post Reply