The project started with my contest idea to use the Hexiwear as a gym assistant. The scope of the project was scaled down a bit from the initial proposal.
Here I will show how to use the Hexiwear for tracking Dumbbells rep sets. The project makes use of the built-in IMU, heart rate sensor, flash storage, vibration motors and graphic display to offer preset routines for keeping track of Dumbbell sets.
What is thisThe application is about using the Hexiwear in a gym environment in order to keep track of dumbbell sets and quantify the number of reps for each session.
To accomplish this we have to:
a) Allow the user to select the preset number of reps
b) have the user start the routine by pressing a button
c) The Hexiwear will have to acquire and analyze the data online and notify the user by activating the haptic feedback motors once the number of reps is achieved
d) Optionally show the user heart rate while he is performing the sets and log this
Data analysisTo figure out how to count the reps I had to do some data analysis. I modified the IMU example to stream a steady stream of data every 100ms. The data were output to a terminal and saved as a log file. (attached at the bottom). With the Hexiwear strapped to my wrist I took a dumbbell and performed a couple of reps.
The next stetp was to import the data in Matlab. After plotting the individual and group vectors I found out that the best visualization occurs when the data are plotted on a log scale. (log-y axis).
The IMU is composed of the accelerator, gyroscope and magnetometer 3D vectors. In addition to this I also computed the root mean square of each sensor by calculating the square root of the sum of each three axis for each sensor.
From the plot above one can easily see that the gyroscope RMS data shows the clearest visualization of the arm swing during the set. From this one can easily count the reps by performing a peak search algorithm on the RMS data array of the gyroscope data. The above set contains 20 reps.
The next step was to write the program which implements this algorithm.
AlgorithmThe algorithm makes use of mbed OS features.
a) The Gyroscope data is acquired every 100ms.
b) The rms value of all three axes is computed and stored on an array.
c) Once the array is full the log of all values is taken.
d) Then a peak detection algorithm is applied.
e) If the number of peaks is less than the preset value online data analysis continues. If more than preset values the Hexiwear activates the haptic feedback motors to notify the user that the rep set is complete.
void acquireDataTask(void)
{
while(true)
{
gyro.acquire_gyro_data_dps(gyro_data);
gyro_rms = sqrt(((gyro_data[0]*gyro_data[0])+(gyro_data[1]*gyro_data[1])+(gyro_data[2]*gyro_data[2]))/3);
}
}
void onlineAnalysisTask(void)
{
for(int i=0;i<LEN_ARRAY;i++)
{
gyrDataRMS[i] = log(gyrDataRMS[i]);
}
}
FirmwareThe firmware is composed of the following modules:
IMU
The IMU code uses the FXOS8700 accelerometer and magnetometer and the FXAS21002 gyroscope. These are MEMS (micro-electro-mechanical systems) sensors.
Memory
The memory is a 8MB W25Q64FV NOR flash memory. The data are saved as raw text in each page since implementing a file system would take too long.
Haptic feedback
The haptic motors are controlled via the GPIO pins of the KF64.
Buttons
The capacitive pads are controlled via the KW40Z BLE co-processor on board of the Hexiwear. This processor communicates with the main processor via serial.
Main application
The user selects one of the pre-set reps. The number of reps is found by implementing a peak counter algorithm. The data is saved on flash-memory.
Once the preset number of reps is hit the user is alerted via the vibration motors.
Conclusion
This project shows that it is feasible to use the Hexiwear as a gym tracker device for moderately simple exercises. Obviously there are a lot of features one can expand from this point onward.
Comments