Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQ] make Treadmill with simulated buttons smart #525

Open
december-soul opened this issue Dec 22, 2021 · 183 comments
Open

[REQ] make Treadmill with simulated buttons smart #525

december-soul opened this issue Dec 22, 2021 · 183 comments
Assignees
Milestone

Comments

@december-soul
Copy link

I have a simple treadmill that is not smart.
However, the buttons to increase the speed and incline are very easily accessible so that you could simulate them with a raspi.
I think you could do it this way:
After switching on the treadmill, the speed and incline are set to 0.
Each press of a button increases the speed by 0,1 km/h.
Therefore you could control the treadmill with a Raspi. It only has to remember how many times it has pressed the "button".

Regardless, I would then take the power from my Stryd and the HR from my chest strap. But I can also link that directly to Zwift.

Where do I start best and are there already approaches?
Feel free to close this issue or rename it.

@december-soul december-soul added the enhancement New feature or request label Dec 22, 2021
@cagnulein
Copy link
Owner

cagnulein commented Dec 22, 2021 via email

@december-soul
Copy link
Author

My idea was more in the direction that the treadmill is controlled not that I can measure the values.

So only that my treadmill is controlled by Zwift.
If my training plan says "10 min @ 7:00, 30 min @ 5:30, 10 min @ 7:30", then the treadmill should adjust to the speed.
The real values are then measured with the Stryd.
Additionally, the incline can be adjusted to the track incline of Zwift.

So the Raspi should "push" the buttons itself. Since I can get to the connector of the buttons, I could give a signal to the cable via the GPIOs of the Raspi. With this the Raspi can control the treadmill.

Do I see that correctly that this would have to be built into the treadmill bridge? So as a new TreadmillClient?

If I look at the treadmill bridge from ProH4Ck it is written in C#.
Is this used by ProH4Ck or where do I have to look. Don't quite get through the code yet.

@december-soul
Copy link
Author

or is it easier to take a Raspi that simulates a FTMS client on one side and then only controls the buttons?
That would probably be more flixibler

@cagnulein
Copy link
Owner

hah got it now! It's a really nice job! Yes i think it will be very easy to do!
We should create a new treadmill.cpp file replacing the bluetooth commands to change incline and speed with the gpio of the raspberry!
Do you want to try to do it? Or you need a hand for the code? @december-soul

My idea so is to have:

  • gpiotreadmil.cpp with the ability to manipulate 4 pins
  • stryd connected as a power sensor (and also used for speed and cadence, already did in this way)

What do you think?

@december-soul
Copy link
Author

I need to understand the structure of the whole project. I am still new here.

C++ would not be the problem, maybe I need some help to find the right point.

And I don't know yet when I will find time to implement the whole thing. Just busy with other projects

@cagnulein
Copy link
Owner

ok, no problem, i can give you a hand! @december-soul just put all together, the raspi, the current master branch of QZ, the stryd to QZ and the connection with gpio.
When you're able to do so, i will write you the code on a separate branch and then we will merge it to master.
I have the idea clear for this.

Just remind a thing: Zwift doesn't control ANY treadmill. With a workaround it can control the inclination, but not the speed.
So probably your "master", i mean the one who schedule the speed and incline, it could be a train program inside QZ.

@hb9odk
Copy link

hb9odk commented Jan 5, 2022

Hi everyone,
I have a rebook GT50 without bluetooth and by Roberto's advice I installed a raspberry pi zero w2 connecting it to the various buttons of the treadmill. The Keys have been connected to the GPIO of the raspberry. Now Roberto will have to do the miracle by defining the gpio that I assigned to the keys in the program QZ! for Raspebby.
Greetings Manuel
tm1

@hb9odk
Copy link

hb9odk commented Jan 5, 2022

For the power supply I had to look up the voltage that powers the console. I installed a step-down converter to get 5V to drive the raspberry
2
.

@hb9odk
Copy link

hb9odk commented Jan 5, 2022

Here are the connections I used to connect the GPIOs to the treadmill.
conessioni

@december-soul
Copy link
Author

cool
that is exactly what I have in mind right now.
Just today my SD card for the Raspi arrived.
Let's see if I can get everything set up today after the workout.

Have you already tested if the activation of the GPIOs is recognized as a keystroke?
It depends on the voltage. I have not yet tested it and am just thinking about I have to make a transistor circuit.

@hb9odk
Copy link

hb9odk commented Jan 5, 2022

Yes I tested the GPIOs without voltage but only as a pass-through. Everything works.

@cagnulein
Copy link
Owner

Cool guys! I will create a new branch tomorrow for this!

@cagnulein
Copy link
Owner

i started the branch here https://github.com/cagnulein/qdomyos-zwift/tree/treadmill-gpio
i hope to finish this tomorrow or anyway for the end of the week

@cagnulein
Copy link
Owner

@hb9odk @december-soul how does the electronical stuff went? Were you be able to command it through the gpios? i will try to ultimate the branch today/tomorrow

@december-soul
Copy link
Author

december-soul commented Jan 10, 2022

I have the Raspi ready set up and the branch built (as far as it goes, compile error).

With the GPIOs I have now decided to use relays to decouple the systems. comes with the control but on the same out with. Then I do not have to worry about electronics from the treadmill.

We need a few parameters

  • Time how long the GPIO has to be on for the treadmill to recognize it as a button press.
  • Time how long the GPIO must be switched off before it can be switched on the next time.
  • Speed step size, how much km/h will the treadmill speed up/slow down when controlling it (default 0,1 km/h)
  • Slope step size, how much percent the slope will be bigger/smaller when controlling it (default 1%)
  • initial speed (default 1km/h)
  • max speed (default MAX_INT)
  • initial slope (default 0%)
  • max slope (default MAX_INT)

for the GPIO handling on the RasPi i use libpigpio, for the GPIOs we must disgust.
I use my old Rasberry Pi B+ which have other GPIOs then the PI Zero that hb9odk use.

  • inc speed GPIO (default ? 17)

  • dec speed GPIO (default ? 18)

  • inc slope GPIO (default ? 22)

  • dec slope GPIO (default ? 23)

  • nice to have: speed correction factor. My treadmill has a drift of 3% in the speed.

@cagnulein
Copy link
Owner

thanks @december-soul i will try to continue the work tomorrow adding also these parameters (as const in the header files for now)

@december-soul
Copy link
Author

No need to hurry.
I'm busy for the next few days and if I keep going, I'll have my little C tool to work with for now.

cagnulein pushed a commit that referenced this issue Jan 11, 2022
@cagnulein
Copy link
Owner

@december-soul @hb9odk finished the very first implementation.
In the file gpiotreadmill..h you can find the GPIO pins and some settings (for now as const). I used the @hb9odk pins.

You need to have the wiringPi library and headers on the raspberry.

Also you need to start the qdomyos with -gpiotreadmill argument

Append a debug log if something will not work.

Let me know

@december-soul
Copy link
Author

Nice, i have updated my parameter suggestions above. ^^

wiringPi was nice but I read that the developer threw down and removed the libs. No idea if this is still supported now.
I have, in my test program, used libpigpio.
But I will see if I get along with your implementation.

@cagnulein
Copy link
Owner

@december-soul wiringpi works well and it's mantained by another group of people, but if you want you can change the calls of the wiringpi to libpigpio. the job is very easy to do. I mean, now that you have the template, you can try to develop it more by yourself, what do you think?

@december-soul
Copy link
Author

i will try.
But it will take a few days.
Maybe @hb9odk can do something with the code too.

when briefly skimming the code, I wondered if
#ifdef Q_OS_ANDROID and
#ifdef Q_OS_IOS can be out, since both have no GPIOs.

@cagnulein
Copy link
Owner

@december-soul yes when will finish it, we will have to add some ifdefs

@december-soul
Copy link
Author

I have found some time to tinker.
qdomyos-zwift starts with
sudo ./qdomyos-zwift -gpiotreadmill

I can already control speed and inclination when I press the button. (at least the relays next to me click)

at the moment i run it under Ubuntu on my laptop, there the development is a bit easier. BT is switched on. (I forgot that the raspi has no BT and my USB-BT dongle comes tomorrow).

But where I'm at the moment, Zwift doesn't find anything. qdomyos-zwift is still a bit new for me, so sorry for the stupid questions:
How is the treadmill announced via BT? What name does it get? Do I have to implement something in the gpiotreadmill.cpp?

I put this empty method in the gpiotreadmill.cpp. Do I have to fill it with life? Is this for the BT connection in Zwift direction or to the (not existing) treadmill direction?
void gpiotreadmill::deviceDiscovered(const QBluetoothDeviceInfo &device) {}

Do you have any other way to contact you than here via gitlab? Seems a bit too cumbersome for me for these general questions.

@melidron
Copy link

melidron commented Nov 12, 2024

I terminated everything... should I try format and reinstall everything tomorrow with your new guide?

@cagnulein
Copy link
Owner

cagnulein commented Nov 12, 2024 via email

@melidron
Copy link

melidron commented Nov 12, 2024

been told thatrpi4 board use logic level at 3,3 volt to sence but the treadmill IR hall sensoor exports 5 volt same with control... do I need any converters or you know something about it? the gpios accept 3,3volts max and my motor board pins for Fast and Slow give 5 volts

@cagnulein
Copy link
Owner

cagnulein commented Nov 13, 2024 via email

@cagnulein
Copy link
Owner

@melidron I don't understand: you already tested and it works? Did you change the source code?

@melidron
Copy link

melidron commented Nov 13, 2024

@calgulein dont know what source code is? I just followed the steps of https://github.com/cagnulein/qdomyos-zwift/blob/master/docs/10_Installation.md to install raspberry operating system and then QDOMYOS-ZWIFT installation nothing else till not... And then you told me to stop the Test step because it went forever to finish... ou told me you will send me a source code that will make things easier for me today... Dont know anything else

@cagnulein
Copy link
Owner

So I don't understand your last message. You sent pictures and code. Were you just quoting an old message?

@melidron
Copy link

melidron commented Nov 13, 2024

So I don't understand your last message. You sent pictures and code. Were you just quoting an old message?

how u do it and reply only to my message without see all the other posts before? what is the right button? I press Quote Reply and it pastes all other previous messages... How I do question to a specific person only? Sorry If I created a mess

@cagnulein
Copy link
Owner

you have to add the @ in the textbox here to mention the user. please don't spam this thread with github general questions. thanks. you can find a github manual in the github website. thanks

@cagnulein
Copy link
Owner

@melidron just for reference, i'm working from this morning to your case here #873 it's not ready yet.

@cagnulein
Copy link
Owner

@melidron Download this on the raspberry https://github.com/cagnulein/qdomyos-zwift/actions/runs/11815625355/artifacts/2181652541

And replace it on the qdomyos-zwift folder where you already run yesterday

Let me know

@cagnulein
Copy link
Owner

Sorry wrong link, hold on

@cagnulein
Copy link
Owner

@melidron Binary is finally ready https://github.com/cagnulein/qdomyos-zwift/actions/runs/11819648403/artifacts/2182850712

Do what I said in my previous comment

Let me know

@melidron
Copy link

melidron commented Nov 13, 2024

@cagnulein I will test in a few hours because I have my daughter here...How I will install it? What I must do? Is it better to format the sd card and start over install X64 raspberry OS and then what u will tell me to do?
Yesterday I ended copied and pasted this to install it:

sudo apt install git libqt5bluetooth5 libqt5widgets5 libqt5positioning5 libqt5xml5 qtconnectivity5-dev qtpositioning5-dev libqt5charts5-dev libqt5charts5 qt5-assistant libqt5networkauth5-dev libqt5websockets5-dev qtmultimedia5-dev libqt5multimediawidgets5 libqt5multimedia5-plugins libqt5multimedia5 qtlocation5-dev qtquickcontrols2-5-dev libqt5texttospeech5-dev libqt5texttospeech5 g++ make git clone https://github.com/cagnulein/qdomyos-zwift.git cd qdomyos-zwift git submodule update --init src/smtpclient/ git submodule update --init src/qmdnsengine/ git submodule update --init tst/googletest/ cd src qmake qdomyos-zwift.pro make

@cagnulein
Copy link
Owner

@melidron Download it And replace it on the qdomyos-zwift folder where you already run yesterday

Let me know

@melidron
Copy link

@cagnulein I have formated the sdcard and will do everything from start to avoid more mistakes

@cagnulein
Copy link
Owner

cagnulein commented Nov 13, 2024 via email

@melidron
Copy link

melidron commented Nov 13, 2024

@cagnulein I thought I had installed something wrong... I wanted to be sure...tomorrow I will have it install if I got it right...thank you for all the trouble I made u go for me since morning

@melidron
Copy link

@cagnulein what exactly did u had to change from your project to
make fit with my parts?

@cagnulein
Copy link
Owner

Nothing, I just created an automation to give you a pre build binary so you don't have to do by yourself :)

@melidron
Copy link

@cagnulein still dont understand it but I trust you like anything :)

@melidron
Copy link

@cagnulein because <i dont understand what I need to replace to make your binary get installed, ca you guide me a little on that too?
Yestarday I was copy and pasted the following part of code on the terminal and waited about 45 minutes to get installed...

sudo apt install git libqt5bluetooth5 libqt5widgets5 libqt5positioning5 libqt5xml5 qtconnectivity5-dev qtpositioning5-dev libqt5charts5-dev libqt5charts5 qt5-assistant libqt5networkauth5-dev libqt5websockets5-dev qtmultimedia5-dev libqt5multimediawidgets5 libqt5multimedia5-plugins libqt5multimedia5 qtlocation5-dev qtquickcontrols2-5-dev libqt5texttospeech5-dev libqt5texttospeech5 g++ make
git clone https://github.com/cagnulein/qdomyos-zwift.git
cd qdomyos-zwift
git submodule update --init src/smtpclient/
git submodule update --init src/qmdnsengine/
git submodule update --init tst/googletest/
cd src
qmake qdomyos-zwift.pro
make

Do I must do the same again now or I must to change something now for your binary you gave me?
or after installation I must change something?

@cagnulein
Copy link
Owner

cagnulein commented Nov 13, 2024 via email

@melidron
Copy link

@cagnulein so I will paste the upper code without the last "make" command right?

@cagnulein
Copy link
Owner

cagnulein commented Nov 13, 2024 via email

@melidron
Copy link

@cagnulein what I dont understand is that... if the upper code is about to install qdomyos-zwift , why I must install it manually again from the binary you ve send me? And what are the steps to install it what the 45 minutes of the upper code finnish the installation?

@melidron
Copy link

@cagnulein the installation finished very fast and say in the end " Cannot find file qdomyos-zwift.pro "

Now what?

@melidron
Copy link

@cagnulein I was pasted the upper code without the last 2 lines...
qmake qdomyos-zwift.pro
make
and after a while it gave me this...

iris@raspberrypi: ∼/qdomyos-zwift/src $

now what?

@melidron
Copy link

@hb9odk can you please help me how to connect raspberry pi 4 pins with 8ch relay pins and the my motor control pins (I dont have a working console control board)? what about the voltage pins the ground and the jumbers the relay has on it? Do I need any voltage shifters to connect motor control Hall sensor (5v) with gpio of rpi4 (3,3V)?
Thanks in advanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants