Proform Bike. Now comes with ERG setting.
I've been riding the bike for a few weeks now with the Seeed Studios Xiao ESP32C3 sending Bluetooth power and cadence data to Zwift. And Zwift also sending grade data back to the bike allowing the bike to simulate grades from the virtual world. It all works pretty well, but...
One setting that seems to be used a lot is ERG mode, where the Zwift (or other software) "takes control" of your trainer and no matter what cadence you pedal, it adjusts the resistance so you get a constant power output. Now, you can almost simulate that yourself by following along with the workout and when it says 120 watts at 85 rpm you adjust your pedaling and gears to match those numbers. But it is a pain, so I've been working on getting ERG mode working on the Proform.
Today I finally figured out the problem(s) I was having and got ERG mode working on the bike. New code is posted here: https://github.com/kevinmott09/proformBLE
My approach was to receive target power (watts) from Zwift and using the current cadence, calculate all possible values of power output for every resistance level on the Proform. (there are only 128 after all, so the ESP probably calculates it in...? ...one millisecond?). We then take the closest resistance level and set the bike to that resistance. Cadence is only reported every 500 milliseconds so we only calculate and set a new resistance two times per second.*
Unfortunately, the ESP would just stop reporting Cadence almost as soon as the ERG mode was turned on... and why? Debugging is a pain, because the only way I've found is by adding Serial.print statements to the code and then monitoring in the Arduino IDE serial monitor. But today I was inspired and hooked up two Arduinos to read the communications on the RS485 lines. It turns out that my code was causing a resistance level to be sent the same time a cadence value was being received. The collision of the two commands created a nonsense transmission. And I don't think my code properly waited for the response message from the bike, causing further messaging problems. Probably obvious to better coders than me, but there you go. So after a fix of the collisions, ERG mode seems to work remarkably well. Yay!
Here is a screen capture of a workout using the erg mode. It was a ramped start, two higher wattage efforts followed by ramped efforts for 15 minutes. I'm pretty pleased with the stability -- it varies by 2-3 watts at lower cadences and might jump by 10 watts at higher. If you can consistently pedal, it might stay flatter. The drop in wattage early on is when I stopped to turn on my fan!
*Interestingly, cycling at 60 rpm, the single magnet on the bike crank only passes the sensor once per second so there is really no point in updating cadence more frequently. Unless we added more magnets to the crank... I wonder what is the maximum cadence value that the lower control board would transmit before it "broke" the messaging system?
No comments:
Post a Comment