Blog post

Who Are You Calling a Dumbbell?!

Projects
By Nick Bild
Who Are You Calling a Dumbbell?!

By and large, people are quite interested in keeping tabs on their health and wellbeing, as is evidenced by the global fitness tracker market size, which ballooned to over $36 billion USD as of 2020. Despite their popularity, most fitness trackers are not particularly good at keeping track of their wearers’ specific physical activities. Engineer Alex Jagger was not satisfied with a device that was little more than a glorified step counter, so he set out to build his own, smarter solution with a little help from tinyML and Edge Impulse.

Jagger was interested in a way to monitor his weight training routine over time, so he built a prototype smart dumbbell. While the concept of a smart dumbbell may sound paradoxical at first, rest assured that this device breaks no laws of physics and Jagger has not set off a chain reaction that will unravel the very fabric of the space-time continuum and destroy the entire universe. What he has done is attach a Microchip SAMD21 Machine Learning Evaluation Kit, and a six-axis Bosch inertial measurement unit (IMU), to a standard dumbbell. While the onboard SAMD21G18 Arm Cortex-M0+ microcontroller may not be a number-crunching beast with a 48MHz clock speed and 9kB of RAM, the energy-efficiency, low cost, and small size made it the perfect tool for the job.

SAMD21 ML Evaluation Kit

With the hardware sorted out, Jagger turned to Edge Impulse to help design and train a machine learning model that is capable of recognizing the different types of exercises being performed with the dumbbell. MPLAB X IDE was used to capture IMU measurements as three different exercises were performed — bicep curls, lateral raises, and overhead presses. After collecting several minutes of data for each exercise, a convenient utility within MPLAB X was used that can directly transfer that data to your Edge Impulse project.

Hopping over to Edge Impulse Studio at this point, Jagger designed a sophisticated machine learning pipeline to classify the IMU measurements with a few clicks. The first block in the impulse uses a sliding window to slice the input time series data into samples appropriate for later stages of the analysis. This data was next processed by a spectral analysis block that performs scaling, filtering, and spectral power analysis, in addition to feature extraction.

Acquiring data 

After all preprocessing, two learning blocks were employed — a neural network and a K-means anomaly detector. The neural network was used to classify IMU data into one of the three recognizable exercises, along with a measure of the model’s confidence in that prediction. The anomaly detector recognizes when an exercise is performed in an unusual way, which can indicate that bad form is being used, or that the motion is being performed too fast. This allows for real-time feedback during your workout, blurring the line between fitness tracker and personal trainer.

Creating an impulse

Using the same data transfer method in MPLAB X IDE that was used to collect training data, it is possible to continuously stream data to Edge Impulse, where it can be classified in real-time on the “Live classification” tab. In this way, Jagger was able to run through a workout with the device, and assess how well his model was performing at the same time.  It is also possible to check the accuracy of the model by using a pre-recorded test dataset and the “Model testing” tool.

Live classification

Having validated the design, the model was then deployed to the SAMD21 Machine Learning Evaluation Kit. The EON Compiler is capable of dramatically reducing the memory requirements of a machine learning model without sacrificing model accuracy. These optimizations proved to be critical in working with such a resource-constrained device. The files produced by Edge Impulse can be dropped into an MPLAB X project, then loaded directly onto the target device for onboard classifications.

Jagger notes that both the SAMD21 Machine Learning Evaluation Kit and Edge Impulse support a wide range of sensors, so without too much effort, it would be possible to customize a device such as this to your specific needs. Well done, Jagger, you have definitely found a smart way to make a dumbbell.


Want to see Edge Impulse in action? Schedule a demo today.

Comments

Subscribe

Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter