Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: Measuring RPM of axle using Teensy 4.1 and an optical mouse sensor

  1. #1
    Member
    Join Date
    Aug 2019
    Location
    Bucharest, Romania
    Posts
    90

    Measuring RPM of axle using Teensy 4.1 and an optical mouse sensor

    Hello everybody,

    As the title of this thread says, I was wondering if it would be possible to measure the RPM of an axle (and then do the math to find the linear speed) using a optical mouse sensor placed near the axle. The maximum RPM of the axle would be 3000 RPM. Would the mouse sensor be fast enough?
    Has anyone done this? I found some old posts/projects (2013, 2016) on other sites that showed how to interact a PS2 optical mouse with an Arduino. I was wondering if it is possible to use the USB port of the Teensy to do the same?

    Thank you very much.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,452
    You certainly can use a USB mouse with the USB host port on Teensy 4.1, or Teensy 3.6.

    But whether the electronics inside a consumer mouse meant for slow movement are able to reliably track an axle spinning at 3000 rpm is a good question. If the diameter of the axle is small, so the linear motion at the surface is slower, maybe it could work? But who can really say, other than the people who designed the mouse. It's probably going to take some experimentation.

  3. #3
    Member
    Join Date
    Aug 2019
    Location
    Bucharest, Romania
    Posts
    90
    Quote Originally Posted by PaulStoffregen View Post
    You certainly can use a USB mouse with the USB host port on Teensy 4.1, or Teensy 3.6.

    But whether the electronics inside a consumer mouse meant for slow movement are able to reliably track an axle spinning at 3000 rpm is a good question. If the diameter of the axle is small, so the linear motion at the surface is slower, maybe it could work? But who can really say, other than the people who designed the mouse. It's probably going to take some experimentation.
    Thank you Paul.
    The diameter of the axel is 50mm.
    Since I am very new to the Teensy USB software part, is there a way to get the data from the Mouse to be printed on the Serial Monitor?

    Thank you.

    //edit
    I just found out the USBHost_t36 library. Will give it a try. Thank you.

  4. #4
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,101
    No, I very much doubt an optical mouse is anything like fast enough as it has to do computation on the chip
    to correlate optical image movement - and the optical image is supposed to be focussed on a flat plane.

    Your typical mouse movement across a mat would be around 0.5m/s maximum. For a shaft of radius
    25mm at 3000rpm you'd have a curved surface to image travelling at 8m/s. I mean try it, but don't
    be surprized if it flakes out well before 3000rpm.

    Why not use a standard optical shaft encoder? Old style mice used these. Reluctance/Hall sensors are
    also used (less susceptible to dust and vibration).

  5. #5
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,504
    Why not use a standard optical shaft encoder? Old style mice used these. Reluctance/Hall sensors are
    also used (less susceptible to dust and vibration).
    Hm, at 3000rpm? If you use a 100cpr encoder you'll end up with a count rate of 3000*60*100 = 18MHz :-) I'd use a disc with a hole and a (fast) optical switch. Would give 180kHz which seems more feasible.

    Edit: If you don't want to mount something on the axis you might try to paint half of it black and use a reflective optical switch.

    Edit2: Sorry wrong calculation (see below) would give 5kHz with a 100cpr encoder and 50Hz with the optical switch. Both is of course very feasible....

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,452
    Maybe you meant to divide by 60?

  7. #7
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,504
    Ups sorry not my day :-) Embarrassing :-)

  8. #8
    Member
    Join Date
    Aug 2019
    Location
    Bucharest, Romania
    Posts
    90
    Quote Originally Posted by luni View Post
    Hm, at 3000rpm? If you use a 100cpr encoder you'll end up with a count rate of 3000*60*100 = 18MHz :-) I'd use a disc with a hole and a (fast) optical switch. Would give 180kHz which seems more feasible.

    Edit: If you don't want to mount something on the axis you might try to paint half of it black and use a reflective optical switch.

    Edit2: Sorry wrong calculation (see below) would give 5kHz with a 100cpr encoder and 50Hz with the optical switch. Both is of course very feasible....
    Thank you for this information. I will probably go with the reflective optical switch and the paint on the axle. Do you have a recommendation of a good optical switch that would be fast enough?
    I will also give the mouse sensor a go just to see if it works

  9. #9
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,504
    Do you have a recommendation of a good optical switch that would be fast enough?
    That one https://www.adafruit.com/product/3930 should be good, here is a project description which might give you a head start: https://learn.adafruit.com/spinning-...sensor-circuit.

    You might need some experimenting with distance and the coloring of the axis (some black colors are quite transparent in the IR).

    Here a list of other sensors in case you don't like the Adafruit one: https://octopart.com/search?q=reflec...0&sort-dir=asc

  10. #10
    Member
    Join Date
    Aug 2019
    Location
    Bucharest, Romania
    Posts
    90
    Quote Originally Posted by luni View Post
    That one https://www.adafruit.com/product/3930 should be good, here is a project description which might give you a head start: https://learn.adafruit.com/spinning-...sensor-circuit.

    You might need some experimenting with distance and the coloring of the axis (some black colors are quite transparent in the IR).

    Here a list of other sensors in case you don't like the Adafruit one: https://octopart.com/search?q=reflec...0&sort-dir=asc
    Thank you very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •