Close

Playing around with cadence measurement

A project log for Poor man's cycling power meter

Open source affordable cycling power meter

maciej-jurczakMaciej Jurczak 11/19/2017 at 21:130 Comments

Finally I got some time to play around with some components that I have bought for this project. 

In order to be able to calculate power one needs a realiable source of crank rotational speed. As the speed may vary over a single crank revolution, for precise measurement it is probably not enough to know only the period of crank rotation (average speed/cadence). It's not clear how often speed sampling should be, but using a MEMS gyroscope seems like a good idea.

But let's start with something simple. The idea is to build a cadence meter that works with my Polar V650 cycling computer.

Components used:

MPU6050 module

MPU6050 comprises 3-axis accelerometer and 3-axis gyro in a single package. For this project only a single axis (at least or now) of MEMS gyro will be used. Z axis was chosen for the purpose of crank revolution measurement as it points perpendiculary to the surface of IC. The measurement of gyro indicates current rotational speed of the IC relatively to Z axis.

GY-521 module I2C interface was connnected drectly to nrf58122 GPIOs. Using nrfSDK TWI driver it was pretty easy to do basic MPU6050 register setup and start reading Z axis angular rate. 

All pieces connected and ready for testing

BLE service implementation was based on an example CSCS (Cycling Speed and Candence Service) provided in nrf SDK. Service configuration was altered to provide cadence only and simulated measurement was replaced with real cadence measurement from gyro.

Part of bluetooth CSC service specification

Simplifying things a bit - BLE CSC service requires to expose crank revolution period expressed in 1/1024ths of second rather than actual cadence. It's up to client to convert it to human-readable RPM value. Revolution period was calculated by sampling gyro speed at 10Hz rate, averaging accumulated samples every second and converting speed in deg/s to single revolution period.

Fixing bugs...

After solving some sampling rate and unit conversion issues it all worked pretty well.

Taped to crank arm, ready for a test ride

Here is link to test ride: strava cadence test ride

Link to code: Gihub commit

Discussions