ptx2 / gymnasticon

Make obsolete and/or proprietary exercise bikes work with popular cycling training apps like Zwift, TrainerRoad, Rouvy and more.

Home Page:https://ptx2.net/posts/unbricking-a-bike-with-a-raspberry-pi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Supporting a Keiser M3

ajs123 opened this issue · comments

I have a Keiser M3 which is very close to the M3i only without Bluetooth. I am considering adding support for it, which would involve

  • bringing the flywheel speed sensor (switch closure) to GPIO pins and timing the intervals between rotations
  • doing something with the resistance sensor, which is a potentiometer attached to the resistance magnet assembly. This could be an added A/D converter or more likely add a circuit so the pot controls the frequency of another pulse train like the flywheel

Would there be any fundamental flaws (or serious challenges) to this approach? The pedal to flywheel ratio is 8.75. Getting cadence from flywheel pulses would require measuring the pulse interval with about 1ms resolution. Or pulses might be counter over a brief period.

Thanks for any comments!

@ajs123 there are loads of m3 users looking for ways to upgrade their bikes for Bluetooth. I bought one of these when they were available on Amazon.co.Uk (up till Xmas 2021) now only available in spain which is a shame as it’s working great on my old 2012 m3.
https://www.amazon.co.uk/gp/aw/d/B01MPZLUG1/ref=ppx_yo_mob_b_inactive_ship_o0_img?ie=UTF8&psc=1

commented

Hi @ajs123,

That sounds very doable!

The pigpio library should work for the counting (it can give timestamped pin change events with sub 5-microsecond accuracy). Note that the Pi GPIOs are 3.3v. Here's an example using the pigpio JavaScript bindings: https://github.com/fivdi/pigpio#determine-the-width-of-a-pulse-with-alerts

There are off-the-shelf ways to add an ADC to the Pi if you wanted to go that way. Search for ADC "HATs" on Digikey, Mouser, Pimoroni, DFRobot, Tindie, Adafruit. Here's a JavaScript library for using MCP SPI ADCs on the Pi: https://github.com/fivdi/mcp-spi-adc

BTW have you already poked around the display/computer PCB? I'm wondering if you could get the power/cadence/resistance data out from there somehow e.g. a hidden uart debug interface, or if the display comms could be sniffed?

Came accross this today - may give you some more info m3 setup.

https://www.bikeforums.net/training-nutrition/519130-kaiser-m3-true-wattage.html

Here's a quote from a Keiser Rep on how they calculate power taken from another forum (https://www.innercycling.com/f/showth...=8542&page=2):

"John,
First and foremost the M3 is not a ergometer nor is it priced like one. Power is an estimate. The price and our maximum usage (group exercise) dictate that it is not for testing and it cannot be calibrated. Though we do have some people that have used it with an IMET test when a bike is more preferential than a treadmill. One thing not mentioned below is magnet strength, they are consistent and do not weaken over the life of the bike.
To answer the question:

Watts are calculated from the gear setting. A potentiometer is attached to the magnet holder (the round cone shaped disc at the end of the shifter cable). As the shifter is moved, the cable rotates the magnet holder. A potentiometer is rotated by the rotation of the magnet holder, thus feeding information to the computer on the position of the magnet holder. The rotation of the potentiometer is broken down into 24 gear settings. A dynamometer was used to test and develop a table of wattage at various gear settings and speeds. The speed of the crank is determined by a magnet attached to the large pulley on the right crank arm and a magnetic switch attached to the circuit board in the magnet holder assembly. Each time the magnet on the pulley passes by the magnetic switch, a signal is sent to the computer to compute the RPM's of the crank arm. Power equals force times velocity. The force is determined by the magnet position and the speed by the crank speed. The lookup table is programmed into the computer and the computer simply looks at the gear setting and speed and goes to the lookup table to find and display the Watts for those two settings.
Darrin Pelkey
VP Sales & Marketing at Keiser
The Power in Human Performance"

commented

Hey @ajs123 sorry for the slow reply here.

I went through a similar decision when starting this project. The reason I chose the Pi is because it's versatile (lots of I/O options), widely available, and relatively straight forward to setup for a non-tech user.

My gut says microcontroller is probably easier, particularly because of the battery requirement. I'd love to see this pulled off with a Pi though :-)

Interested to know which way you end up going. Sounds like a very fun project.

@ajs123 Thats fantastic news - you need to be sharing this with your fellow American M3 users! .

That things tiny - the dpcycling box fits in the frame under the plastic casing - dont know where you've wired it up to - if its the rear you could probably do the same?
Screenshot 2021-04-26 at 09 45 57

@ajs123 Would love to see your Adafruit board code if you'd set up another repository.

This is cool.

Somewhat related... I've been dreaming of having an actuator to control a second magnet set in response to terrain changes. I think an associated potentiometer wired in series with the pot on the existing magnet system could be made to work somehow. Maybe this is something for the future.

Maybe the smartspin project unit could be modified to do the adjusting, or maybe there is some more clever way in line with what you're doing here.
https://github.com/doudar/SmartSpin2k

@nealjane, where did you find the Keiser graph on power estimates that you posted? I've made use of it and want to properly cite it if I can.

I think I've figured out how to calibrate the M3 using Keiser's calibration tool. I'll post details over at KBikeBLE when I have a chance. I can describe it here as well if there's interest.

Thanks!

@ajs123 it was just posted on the keiser m3i Facebook group - so no idea where it originates from.

Keiser tool is £25 here in Uk - so I modelled my own version recently (doing the tooless version appears to not work and will mess up the gear vs effort reqd)

m3/M3i dated after 2009 (v4 software Calibration tool)- I sell on eBay - search K2pi keiser tool

Calibrating older than sept 2009 M3 differs and needs a different tool! (V1 software) See here-
https://youtu.be/R1CSYF7tZeg
So I modelled a ‘best guess’ tool version for that one too (magnet set to edge of wheel rather than 10mm in on the more recent tool)

Up to 2009 m3 (v1 software calibration tool) - https://home.mycloud.com/action/share/b9560447-cc6d-4255-999f-a6b75f79a4a9

Thanks, @nealjane. Thanks @nealjane. Here's what I've found on a 2009 M3:

  • Used https://apps.automeris.io/wpd/ to digitize the chart, taking (resistance, power) values at the "bottom" of gear 1, the boundaries between gears, and the "top" of gear 24. 
  • Switched back and forth between a Keiser computer that had been calibrated to the bike and my computer, to relate my ADC readings from the pot to the x-axis on the graph.
  • At each spot, pedaled at 90 rpm and got a power reading from the Keiser computer. This simply verifies that the chart accurately shows the Keiser power estimate.
  • I also got ADC readings for the the magnet assembly at its low-end stop (cable unhooked or adjusted to allow the assembly to hit the stop), with the cal tool, and at brake pad contact. The cal tool is obviously key in Keiser's procedure for their 4.06 software. The other positions are probably not (see below).

Findings:

  • If the x-axis on the chart is re-labeled with 0 as the lefthand edge of gear 1 and 100 as the righthand edge of gear 24, the cal tool position is 40%. I'm in the process of updating KBikeBLE to use this scale.
  • The cal tool is also 40% if the mechanical stop on the magnet holder is -5 and brake pad contact is 110. This could be bike-dependent, and also dependent upon whether the brake pads wear at all. I neither imagine that brake pads get used much, nor expect that Keiser depends upon them being precisely uniform.

Further thoughts

  • I'd started out thinking that calibration requires two points to define the line relating ADC values to magnet position. Keiser can't use the low end position because their calibration procedure doesn't require that the shift lever allow the magnet assembly to travel all the way to the bottom. They could use brake pad contact, but that wouldn't seem to be super reliable.
  • While the magnet position potentiometer is +/- 10%, as long as it's being used as a voltage divider, any other resistances in the circuit are low enough, and the rotational range of the pot is consistent from unit to unit, the change in reading per degree of magnet movement should be consistent as well. This seems like a lot of "ifs" but I can see them all being true. If so, the slope of the line relating ADC readings to the x-axis (I'm calling it Resistance in %) will be consistent from unit to unit.
  • That leaves the intercept or offset. This is clearly dependent upon the potentiometer and gear position when the magnet cover is assembled.
  • Putting all of this together, Keiser's software would
    • After one crank revolution after waking up, look for the largest magnet position. This should be contact with the cal tool. It provides a measurement of the offset.
    • After one more crank revolution, look for the lowest and highest values. They should merely be consistent with somewhere around the bottom of gear 1 and brake pad contact. It's a "sanity check" on the cal tool reading.
    • Registering a new calibration only under very specific conditions including the 6 full swings after the second crank rotation and within 30 seconds guards against any user doing it unintentionally.
  • The YouTube videos showing calibration without a tool have you set the gearshift lever to the vertical position. This is pretty close to where it would be at the cal tool position, so the unit passes the "sanity check" but is calibrated to the lever position rather than the magnet position.

Regarding replication of Keiser's power estimates, I've verified (reasonably well) that it works to multiply Keiser's curve by a factor that depends upon the cadence. That factor is pretty close to linear with RPM from 60 to 110, though I'm using a quadratic which does a tiny bit better in that range and comes nicely down to zero at 0. Keiser's curve is nicely captured by a quadratic only from gears 2 through 20 or 21. Capturing the whole thing with an equation requires a 4th order polynomial. Though the nrf52840 I'm using has hardware floating point, I'm planning to switch to a lookup table with interpolation. The same table can be used to replicate Keiser's unevenly spaced gears for those who want that. Others may prefer the more evenly spaced gears obtained by a curve fit. Personally, I use the %resistance display.

I need to package up and share my data...