Hamster Wheel Tachometer

4,370

23

16

Introduction: Hamster Wheel Tachometer

About three years ago, the nephews got their first pet, a hamster named Nugget. Curiosity about Nugget's exercise routine started a project that has long out lasted Nugget (RIP). This Instructable outlines a functional exercise wheel optical tachometer. The Hamster Wheel Tachometer (HWT) displays the hamster's highest speed (RPM) and the total number of revolutions. Nugget's human family wanted something simple to install and use, but did not want more screen time for the kids. Given rodents' chewy way of interacting with the world, I thought self-contained battery power would be good. The HWT will run for about 10 days on a charge. It can record up to 120 RPM depending on the wheel diameter.

Step 1: Parts List

Adafruit #2771 Feather 32u4 Basic Proto (with supplemental wiring- see Step 4: Assemble Electronics)

Adafruit #3130 0.54" Quad Alphanumeric FeatherWing Display - Red

Adafruit #2886 Header Kit for Feather - 12-pin and 16-pin Female Header Set

Adafruit #805 Breadboard-friendly SPDT Slide Switch

Adafruit #3898 Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh

Vishay TSS4038 IR Sensor Module 2.5-5.5v 38kHz

Vishay TSAL4400 Infrared Emitter T-1 pkg

Resistor, 470, 1/4w

Switch, push button, SPST, momentary on, 0.25" panel mount (Jameco P/N 26623 or equivalent)

(4) 2.5mm nylon machine screws with nuts (or 4-40 machine screw - see Step 6: Assemble the HWT)

Hamster Wheel Tachometer enclosure - 3D printed. (Public TinkerCad file)

Hamster Wheel Tachometer bezel - 3D printed. (Public TinkerCad file)

Hamster Wheel Tachometer Sensor housing - 3D printed. (Public TinkerCad file)

Display contrast filter. There are three options:

  1. (54mm x 34mm x 3.1mm) 1/8" Transparent Grey Smoked Polycarbonate (estreetplastics or equivalent).
  2. No contrast filter
  3. 3D print a filter using thin translucent PLA and this Public TinkerCad file.

Dark matter: some stick-on non-IR reflective material. I used stick-on black felt from a crafts store. Creatology Peel and Stick Black polyester felt or equivalent. See also Step 7: Calibration - Notes on Dark Area.

Note: Within reason, you may substitute parts. I tend to support Adafruit because of their quality and support of the maker community. Oh and I love gold-flashed solder pads.

Step 2: Theory of Operation

The HWT uses infrared light (IR) to count revolutions of a rotating exercise wheel. Most plastic exercise wheels reflect IR light rather well, too well. Even plastic wheels that are translucent in visible light may reflect sufficient IR to trigger IR sensors. The user creates a dark area on the wheel using black stick-on felt (see Step 7: Calibration - Notes on the Dark Area). When a reflective to dark transition is detected by the HWT, one revolution is tallied.

The HWT uses a Vishay IR Sensor Module and IR LED emitter. In a typical application, the Vishay TSS4038 IR Sensor Module is used for presence detection - is something there (reflecting IR) or something is not there. That is not exactly what the HWT is doing here. The plastic exercise wheel is always there. We are fooling the sensor by adding an IR dark area to make the wheel 'disappear' in IR light. In addition, the HWT makes use of the Vishay TSS4038 IR Sensor Module's design to provide a variable range operating distance. Step 3: Code section and code listing has more information. The basic premise is outlined in Application Note Vishay’s TSSP4056 Sensor for Fast Proximity Sensing.

The Adafruit Feather has an Atmel MEGA32U4 microcontroller and a thru-hole prototyping area.

Soldered in the prototyping area is a Vishay TSAL4400 IR LED which creates bursts of 38 kHz IR signals (under the control of the 32U4 microcontroller).

Also soldered in the prototyping area is a Vishay TSS4038 IR Sensor Module for Reflective Sensor, Light Barrier, and Fast Proximity Applications.

This IR sensor module produces a signal if a burst of 38kHz IR light is received for a certain amount of time.

The 32U4 microcontroller generates a 38kHz burst every 32mS. The 32mS rate determines the maximum exercise wheel RPM that can be measured. The 32U4 also monitors the IR sensor module. With sufficient IR reflection from the hamster wheel, each burst should cause the IR sensor module to respond. A dark area of the wheel yields no IR sensor response which the 32U4 notes. When the hamster wheel has moved so there is sufficient IR reflection, the 32U4 code notes the change and tallies this as one revolution of the wheel (light to dark transition= 1 revolution).

Approximately every minute, the 32U4 checks if the revolutions in the last minute has exceeded that previous highest RPM count and updates this 'personal best' score if needed. The number of RPM in the last minute is also added to the total number of wheel revolutions.

A push button is used to display the number of revolutions (see Step 9:Normal Mode section) and used in calibrate the HWT (see the Step 7: Calibration Mode section).

An ON-OFF slide switch controls power to the HWT and has a role in the calibration (see Step 7: Calibration section).

If the exercise wheel diameter is known the total distance run is calculated as (Diameter * Total wheel revolutions * π).

Step 3: Code

I am assuming the user knows their way around the Arduino IDE and Adafruit Feather 32U4 board. I used the standard Arduino IDE (1.8.13) with the RocketScream Low Power Library. I endeavored to comment the code profusely and perhaps accurately.

I have not documented quirks and interactions of the Arduino IDE and the Adafruit Feather 32U4 system. For example, the 32U4 handles the USB communication with the Arduino loader. Getting the host PC running the Arduino IDE to find the Feather 32U4 USB connection can be troublesome. There are on-line forum threads detailing problems and fixes.

Particular to the RocketScream Low Power library, the Feather 32U4 USB operations are disrupted. Thus to download code from the Arduino IDE to the 32U4, the user may have to press the Feather 32U4 reset button until the IDE finds a USB serial port. This is so much easier to do before you assemble the HWT.

Step 4: Assemble Electronics

  1. Assemble Adafruit #2771
    1. If lowest power drain is desired, cut the trace between R7 and the Red LED. This disables the Feather LED.
    2. Install the Adafruit #2886 Header Kit on the #2771 Feather per their tutorial. Note there are several options for header styles. The HWT 3D printed enclosure is sized for this header.
    3. Install the optical components on the #2771 Feather. Refer to the pictures and the schematic.
      • Vishay TSS4038 IR Sensor Module
      • Vishay TSAL4400 Infrared Emitter
      • Resistor, 470, 1/4w
      • Hamster Wheel Tachometer Sensor enclosure - 3D printed. (Public TinkerCad file)
  2. Solder the display push button switch to the Feather 32U4 printed circuit board assembly (PCBA) per the schematic.
  3. Assemble the Adafruit #3130 0.54" Quad Alphanumeric FeatherWing Display per their tutorial.
  4. Assemble the power switch / battery assembly per the images and the schematic. Note: the switch leads close to the switch need to be free of solder for the switch to fit properly in the HWT enclosure.
    • Adafruit #3898 LiPo Battery.
    • Adafruit #805 SPDT Slide Switch.
    • Hookup wire.

    Note: Feel free to wire as you wish. This is just how I assembled the HWT for this Instructable. Other prototypes had wires placed slightly differently. As long as your wiring conforms to the schematic and the Vishay sensor and LED housing pokes out the bottom of the HWT enclosure, you are good.

Step 5: 3-D Printed Parts

The HWT housing consists of three 3D printed pieces:

  1. Hamster Wheel Tachometer enclosure - (Public TinkerCad file)
  2. Hamster Wheel Tachometer bezel - (Public TinkerCad file)
  3. Hamster Wheel Tachometer Sensor housing - (Public TinkerCad file)

The HWT housing, HWT display bezel and HWT sensor housing were created in Tinkercad and are public files. A person can down load copies and modify as wanted. I am sure the design can be optimized. These are printed on a MakerGear M2 using Simplify3D control. Adafruit has a tutorial for a 3D Printed Case for Adafruit Feather. I found those 3D printer settings to be a good starting point for my M2 MakerGear printer.

If needed a display contrast filter can be 3D printed using thin translucent PLA and this Public TinkerCad file.

Step 6: Assemble the HWT

  1. Connect the battery/switch assembly to the Feather #2771 PCBA. It is much easier to do this now than when the Feather #2771 is bolted into the HWT enclosure.
  2. Seat the slide switch into its location in the HWT enclosure.
  3. Route the wires out of the way as you place the Feather PCBA into the enclosure.
  4. The sensor housing should stick out the back of the HWT enclosure.
  5. The 2.5mm nuts are difficult to attach to the 2.5mm screws. You may wish to use 4-40 machine screws as described in the Adafruit tutorial.
  6. Press the #3130 display PCBA into the Feather #2771 PCBA. Watch for bent or misaligned pins.
  7. Attach the switch to the display bezel.
  8. Snap the display bezel into the HWT enclosure.

Step 7: Calibration

In Calibrate mode, the display continuously shows the output from the IR sensor. Calibration assists in verifying:

  1. The hamster wheel is reflecting sufficient IR light.
  2. The dark area is absorbing IR light.
  3. The range settings are correct for the distance to the exercise wheel.
  • To enter Calibrate mode:
    1. Turn off the HWT using the Power slide switch.
    2. Press and hold the Display button.
    3. Turn on the HWT using the Power slide switch.
    4. The HWT enters Calibrate mode and displays CAL.
    5. Release the Display button. The HWT now displays a letter representing the range setting (L, M or S) and the sensor reading. Note the sensor reading is not the actual distance from wheel to HWT. It is a measure of the quality of reflection.
  • How to check wheel IR reflections:

    With an adequate reflection, the sensor display should read around 28. If the wheel is too far away from the HWT there is insufficient reflection and the sensor display will go blank. If so move the wheel closer to the HWT. Rotate the wheel; the readings will fluctuate as the wheel turns. A range of 22 to 29 is normal. The sensor reading should not blank. The range letter (L,M or S) will always be displayed.

  • How to check dark area response:

    An area that absorbs IR (dark area) will cause the sensor reading to go blank. Rotate the wheel so the dark area is presented to the HWT. The display should go blank meaning no reflection. If numbers are displayed, the dark area is too close to the HWT OR the dark material used doesn't absorb sufficient IR light.

    Notes on the Dark Area

    Anything that absorbs IR light will work, e.g. flat black paint or flat black tape. A flat or matte finish is important! A shiny black material might be very reflective in IR light. The dark area can be on the circumference or the flat side of the exercise wheel. Which you choose depends on where you mount the HWT.

    The dark area needs to be of sufficient size that the IR sensor will see only the dark area, not adjacent reflective plastic. The IR emitter projects a cone of IR light. The cone size is proportional to the distance between the HWT and the wheel. A one-to-one ratio works. If the HWT is 3 inches from the wheel, the dark area should be 2-3 inches across. Sorry for the Imperial units.

    The image shows the TSAL4400 IR LED illuminating a target from 3 inches away. The image was taken with a NOIR Raspberry Pi camera.

    Material Selection Hint: Once I had assembled a HWT, I used it as an IR Reflectance meter (that is what it is). During development, I took the HWT to pet stores, hardware stores and fabric stores. Many items were 'tested'. I examined plastic exercise wheels, the dark materials and the effects on distance from the materials. Doing this I got a sense of the performance and limitations of the HWT. This allowed me to properly locate the plastic wheel in the cage and chose the correct range setting in Calibration mode. Yes, more than once, I did have to explain what I was doing to puzzled store staff.

  • How to change range:
    1. In Calibrate mode, the first display character is the range setting (L,M,S):
      • (L)ong range = 1.5 to 5"
      • (M)edium range = 1.3 to 3.5"
      • (S)hort range = 0.5 to 2" (capital S looks like a number 5)

      Note: These ranges depend on target materials and are very approximate.

    2. To change the range press the Display button. The first display character will change to show the new range.
    3. To keep this new range press and hold the Display button for 4 seconds. The display will show Savd for two seconds when the action is complete.

    Note: The HWT will remember the range settings after reset and even if the battery goes dead.

  • Success? If the exercise wheel reflects (display is around 28) and the dark area absorbs (display blanks) you are done. Power cycle the HWT to resume Normal mode (see Step 9: Normal Mode section). Otherwise, change the distance between the HWT and wheel or change the HWT range until you are successful.

Note: Where the HWT is installed on the cage and the calibration of the HWT are related. You may not be able to put the wheel where you want in the cage because that cage location is not in the range of the HWT. The wheel material and the dark area material (black felt) you have chosen also becomes a factor.

Step 8: Installation on Cage

  1. Calibrate the HWT and use the Calibration process to inform where you will place the exercise wheel and where the HWT is installed on the cage.
  2. The HWT can be tied to the side of the cage using the HWT case's mounting holes. I used plastic-coated wire bread ties. Wire ties work also.
  3. With the HWT installed and the exercise wheel placed, verify the exercise wheel reflects IR light and the dark area absorbs IR.
  4. If needed, changing the range is described in the Calibration section. A range of distances can be user selected in the HWT. There are three overlapping ranges:
    • (L)ong range = 1.5 to 5"
    • (M)edium range = 1.3 to 3.5"
    • (S)hort range = 0.5 to 2"
  5. The HWT Sensor housing (IR emitter/sensor) must not be obscured by the cage wire. You may have to spread the cage wire slightly to allow the assembly to poke through the cage wires.
  6. Verify the HWT records the exercise wheel revolutions correctly (see Step 9: Normal Operation mode).

Step 9: Normal Operation Mode

  1. In Normal mode, the HWT counts revolutions of the exercise wheel.
  2. To enter Normal mode, turn on the HWT using the Power slide switch.
  3. The display will show nu41 for one second then display the range setting for one second.
    • Ra=L long range
    • Ra=M medium range
    • Ra=S short range (capital S looks like a number 5)
  4. During Normal operation a single display LED segment will flash very briefly every minute.
  5. Every minute, the count for that minute is compared to the maximum count (the hamster's personal best) from previous minutes. The maximum count is updated if needed. Each minute the count is added to a total count.
  6. Press and release the Display button to see the wheel counts. The display shows the following:
    • Now= followed by the number of wheel revolutions since the last minute check. Note: this number will be added to the total after the next one minute tick.
    • Max= followed by the highest number of revolutions. Nugget's personal best since the power was cycled last.
    • Tot= followed by the total number of revolutions since the last power cycle.

Power cycling (power slide switch off-on) the HWT will zero all counts. There is no getting those numbers back.

The HWT should run for about ten days on a charge and then the LiPo cell will do an auto-shutdown. To avoid loss of exercise wheel counts, recharge before the auto-shutdown of the LiPo cell.

Step 10: LiPo Cell Notes:

  1. LiPo cells store a lot of energy using volatile chemicals. Just because cell phones and laptops use them doesn't they shouldn't be treated with caution and respect.
  2. The HWT uses a rechargeable Lithium Polymer (LiPo) 3.7v cell. The top of the Adafruit LiPo cells are wrapped with an amber plastic. This covers an integral charge / discharge safety circuit on a small PCBA. The red and black cell leads with the JST connector are actually soldered to the PCBA. It is very nice safety feature having the monitoring circuit between the LiPo and the outside world.
  3. The HWT will lose power if the LiPo integral charge / discharge safety circuit decides that the LiPo cell is too low. Exercise wheel counts will be lost!
  4. If the HWT seems 'dead' it probably needs a cell recharge. Connect the HWT using a micro USB cable to a standard USB power source.
  5. When charging a yellow LED will be visible in the HWT plastic enclosure.
  6. The LiPo will be fully charged in about 4 - 5 hours.
  7. The LiPo cell protection circuitry will not allow the LiPo to overcharge, but disconnect the micro-USB cable when the yellow LED goes off.
  8. As described in the Adafruit #3898 documentation, I had originally intended for the LiPo cell to fit between the Feather #2771 PCBA and the #3130 display PCBA. I found that my wiring in the Feather #2771 prototype area was too tall for the LiPo cell to fit without denting the LiPo cell. That made me nervous. I resorted to placing the battery on its side next to the PCBAs.
  9. Those red and black wires of the LiPo integral charge / discharge safety circuit do not like being flexed. In the course of development I have broken more than one set of wires. To provide more strain relief, I designed and 3D printed a strain relief. That is the gray block on top of the LiPo cell. It is not needed, but here it is (Public TinkerCad file).

Step 11: Development History:

Over the three year life of the Nugget project several versions resulted:

1.xProof of concept and data gathering platform.

Nugget's range of performance was characterized (max RPM, totals, times of activity). In his prime, Nugget was achieved 100 RPM and was able to run 0.3 miles a night. Spreadsheet of data calculations for various wheels attached. Attached also is a file with actual Nugget RPM records stored on the SD card.

2.x Sensors and hardware explored.

Established the microcontroller and displays:

  • Adafruit #2771 Feather 32U4
  • Adafruit #3130 14 segment LED display Featherwing.

This combo was chosen for low power consumption (32U4 sleep modes), battery management (built-in LiPo charger) and cost (LEDs inexpensive and lower power than LCD+backlight).

3.xSensor work:

This series also investigated alternative sensors such as using a stepper motor as an encoder similar to this Instructable. Feasible but for low signal strength at low RPM. A little more work would turn this into a viable solution, but it is not a simple retrofit with the existing hamster environment. Abandoned.

4.1 The hardware/software solution described in this Instructable.

5.x More Sensor work:

Examined Sharp GP2Y0D810Z0F Digital Distance Sensor with Pololu Carrier while still using Adafruit #2771 Feather 32U4 and Adafruit #3130 14 segment LED display Featherwing. Worked well. Made code trivial. Used more power than the Vishay TSSP4038 solution. Abandoned.

6.x The future?

  • Replace some of the HWT enclosure mounting bosses for the Adafruit #2771 Feather with mounting posts.
  • Replace the on/off switch with a push button switch connected to Feather reset.
  • The ATSAMD21 Cortex M0 microcontroller, such as found on the Adafruit #2772 Feather M0 Basic Proto, has many attractive features. I would look at this closely on another revision.
  • Vishay has a new IR sensor module, the TSSP94038. It has lower current needs and a more defined response.
Battery Powered Contest

Runner Up in the
Battery Powered Contest

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Paint Challenge

      Paint Challenge
    • Reclaimed Materials Contest

      Reclaimed Materials Contest

    16 Comments

    0
    smooth_jamie
    smooth_jamie

    11 months ago

    I must admit I intially only clicked because of that cute little hamster on the picture! Tidy project mate!

    0
    bill96
    bill96

    Reply 11 months ago

    Thank you! I am not above using cute little mammals to get a click. (:- )

    0
    seawarrior181
    seawarrior181

    Question 11 months ago on Introduction

    Is there video of the hamster using the wheel? I'd love to see that.

    0
    bill96
    bill96

    Reply 11 months ago

    I checked... no Nugget on the wheel. (:- ( He was a shy boy. How about a hedgehog? A friend of mine was talking about using a HWT for her hedgehogs. I guess one likes the wheel, the others not so much.

    0
    bill96
    bill96

    Reply 11 months ago

    Well, that was the problem. Nugget was shy. He'd only run in the middle of the night - hence the monitor. I'll ask the hamster 'mom' if shy was any wheel vids. There are tons of Nugget running around.

    0
    seawarrior181
    seawarrior181

    Reply 11 months ago

    Well now you have an excuse to set up a motion activated ESP32-CAM. Another project! :)

    0
    BerenV
    BerenV

    11 months ago

    Hey, nice project! I enjoyed reading it and it was well documented. For the stiff battery wire problem you mentioned, I’d suggest trying some silicone hookup wire. It’s not that hard to solder a new pair of red and black wires onto the battery protection board (and you can replace the Kapton tape covering the top of the battery when you’re done). Silicon wire comes in various gauges and is much more flexible than your typical hookup wire. I recently got some and have been super happy with it compared to the solid core type with the hard coating I had been using before.

    I wonder if you could save the wheel counts to EEPROM as well every so often so they would be kept even through power loss... I guess it has a limited number of write cycles so you’d have to implement a method of using different locations to spread out wear and it would quickly become much more complicated. Anyway, I’m sure it’s doable although it might be a little overkill for this project!

    I liked your use of the alphanumeric displays, you don’t see those as often anymore. I think LCDs do tend to be more low power than LED displays though (if you don’t use a backlight).

    0
    bill96
    bill96

    Reply 11 months ago

    Thanks! It is funny all the design decisions a person makes. The silicone wire sounds nice. I think the LiPo vendor's wire would be fine if I did not mess with it so much. I will look around for that wire.

    I was tempted by the EEPROM, but as you pointed out, the write count management was more than I wanted to mess with. Then the issue of menus to access the data and no reliable time stamp. The "end user" (the human - not Nugget) preferred that the child would have to write down data. You are right - overkill, but there is always the next revision! I did use the EEPROM to save the range setting as the calibration is a very low repetition event.

    I spent waaay too much time on this project, but it was fun. I looked a lot at displays. LCD are the way to go except for the back light as you said. I looked at reflective LCD, but didn't see anything to appealing from vendors on this continent. Now ePaper that would be fun, luckily for my wallet, Nugget passed on before I got that ridiculous. Cheers, Bill

    0
    jdh2550
    jdh2550

    11 months ago

    Thanks for making me actually laugh out loud. If I had a hamster you can bet I'd want to know the RPM of his work out!

    0
    bill96
    bill96

    Reply 11 months ago

    I was rather surprised at his speed and endurance. Nugget was a beast!

    0
    ElectroFrank
    ElectroFrank

    Reply 11 months ago

    In all fairness, I think we must ensure that the display is placed where the hamster can clearly see it whilst exercising.

    0
    bill96
    bill96

    Reply 11 months ago

    Of course! Remote display... my next project (:- )

    0
    seawarrior181
    seawarrior181

    11 months ago on Step 11

    Well done! Nicely documented and a super idea! Made me smile. Thanks for sharing.

    0
    bill96
    bill96

    Reply 11 months ago

    My pleasure!
    I made lots of jokes about this is how I make my first million dollars. (:- )

    0
    seamster
    seamster

    11 months ago

    This kind of project just makes me happy : )

    Very nicely done, thank you for sharing all the details!

    0
    bill96
    bill96

    Reply 11 months ago

    Thank you! And a nephew got a science project out of it! He kept track of Nugget's totals and personal bests then made a bunch of graphs.