cagnulein / qdomyos-zwift

Zwift bridge for smart treadmills and bike/cyclette
https://www.qzfitness.com/
GNU General Public License v3.0
369 stars 109 forks source link

[REQ] SmartSpin2K & QZ integration #299

Closed marklogan17 closed 3 years ago

marklogan17 commented 3 years ago

Looking to integrate the two so we can remotely control resistance on bikes with no motorized resistance control. NRF screenshots attached. I have started a discussion on the SmartSpin2K github page asking for suggestions/thoughts. Screenshot_20210505-181402_nRF Connect Screenshot_20210505-181437_nRF Connect Screenshot_20210505-181420_nRF Connect Screenshot_20210505-181446_nRF Connect Screenshot_20210505-181352_nRF Connect Screenshot_20210505-181511_nRF Connect

cagnulein commented 3 years ago

@kadaan is there a way with the current firmware to have access to the current inclination/resistance of SS2K? Or maybe for now i can set my homing point to the current resistance and put it as an offset. What do you think @marklogan17 ?

Of course having the raw control of the motor will be the perfect solution

kadaan commented 3 years ago

@cagnulein No way ATM to get access to current inclination/resistance Don't think that will work because QZ and SS2K don't know what the resistance of the bike is.

cagnulein commented 3 years ago

@kadaan with the offset, SS2K will become just an actuators so it should work. I'm only worried about negative inclines value. It will work for sure with positive ones

kadaan commented 3 years ago

If by "set my homing point to the current resistance" you mean the user indicates in the app what resistance the bike is set to before starting a ride, then yes, that could work.

cagnulein commented 3 years ago

@kadaan yeah but without the user intervention: you know, i know already which is the current resistance. The bike told me it :) So SS2K will work also with the negative incline?

kadaan commented 3 years ago

@cagnulein Yes, negative incline is fine. But, not all bikes tell you the current resistance (ie. Schwinn IC4/IC8)

cagnulein commented 3 years ago

@kadaan not true :D we have an algorithm to calculate the resistance for the schwinn :) it will works with your bike too :)

kadaan commented 3 years ago

@cagnulein Cool. I want to see how accurate it is. Seems unlikely to match the display, but if it does, that's great!!!

kadaan commented 3 years ago

@cagnulein Gave it a very quick try. Seems close when the resistance is at the higher end, 70+. On my bike it is very inaccurate at lower resistances < 50. When the bike is at 0, the resistance display in QZ is 28.

cagnulein commented 3 years ago

@marklogan17 i added the startup offset to the smartspin2k module. could you please try? if something doesn't work, as always, send me the debug log

marklogan17 commented 3 years ago

OK you guys are smarter than me - plus you seem to solve things while I'm sleeping. I know the long term solution is likely to disable the shifters and have the request pass through to QZ. However until that's done I'm not sure how best to handle this. I tried a bunch of things to get this consistently changing 1 resistance level every time a + or - button is hit on QZ however I seemed to run into various edge cases.

What would be ideal is for a simple way of QZ replicating the shifters rather than dealing with the relative nature of the incline. So it would send the number of 'shifter presses' that it needs to replicate. That way the step config in SmartSpin still applies nicely. Sending a 'number' of shifter presses matters because for Schwinn or Peleton or something like that you may need to increase by 10 or 20 resistance levels and you don't want to make 20 calls, waiting for the resistance change between each.

kadaan commented 3 years ago

@marklogan17 The issue is that "api" for controlling the stepper is not in terms of shifter steps, but in incline. Incline is scaled by Incline Multiplier, so you will want to adjust that to try to get one shift per incline submitted by QZ.

marklogan17 commented 3 years ago

@marklogan17 The issue is that "api" for controlling the stepper is not in terms of shifter steps, but in incline. Incline is scaled by Incline Multiplier, so you will want to adjust that to try to get one shift per incline submitted by QZ.

OK, I was not reading the code right where it was taking current position and adding incline*incline multiplier. You caused me to re-read it and now I think we're good.

I've settled on 800 as the shift steps that I need for each level. So @cagnulein what we need is the inclination change you send times the configured multiplier equal 800. So the easiest way is where you are multiplying by 100 and sending, multiply by 200 and then I set the incline multiplier to 4. So 1 resistance level will cause you to send an incline change of 200 (or -200) which SmartSpin multiplies by 4, getting us to the +/-800 that seems to be good for changing one resistance level. Even better, if this is applied to the Peleton usage, you can easily request changes greater than 1 resistance level and it should still work.

I modified QZ to multiply by 200 and did a quick test and it worked really well. We'll still get potentially messed up in cases where the shifters are used and then +/- but I'll figure all those edge cases out so I can tell people what to do/avoid - and more importantly, how to get back in sync.

Longer term we probably need a way to reset inclination to zero so we can resync between apps.

Now to pull the hardware apart and replace the small gear to hopefully get rid of my last binding issue :)

marklogan17 commented 3 years ago

@kadaan any update on the changes in SmartSpin?

kadaan commented 3 years ago

@marklogan17 No, I've been crazy busy on my farm. :(

marklogan17 commented 3 years ago

@marklogan17 No, I've been crazy busy on my farm. :(

Totally understandable! Life comes first :)

cagnulein commented 3 years ago

377

cagnulein commented 3 years ago

i'm closing this one. in case we will open a new one for future requests!