Open Davrizio opened 6 years ago
Hi Davrizio, Sorry for the delay. I didnt notice I had an Issue pending. I am updating my treadmill with the latest code and dependency updates at the moment as well. I get frustrated each time I do because Linux developers keep changing locations of key files! I have found the latest BBB image to be very good though, some things changed but the PWM setup is much easier. Try downloading a new BBB image first, I used the debian IOT one since I no longer use the LCD on the BBB (it kind of sucked after getting used to iPhone/android displays).
After install you need to first enable the PWM pin C8_13: echo 1 > /sys/class/pwm/pwmchip6/export
Then you can node ./tread-station.js . This should have worked for you before so I am guessing its an old node version. I am using my latest code with latest BBB and doing the same thing. FYI You can run in any folder, and you dont have to run as root (on latest BBB because they fixed IO permissions).
Once the node service starts, if it detects the PWM chip and pin, it will run in "real" mode and your treadmill should work if you wired it right. If it doesnt detect the PWM pin (if you didnt do the echo 1 thing above) then it will still start but in Simulation mode. The user interface and everything will work but no motion will happen even though it says it is.
To get the interface up, go into the ui folder and do: npm install npm run build npm run serve
You should be able to connect though I am not sure how well that last "npm serve" command will work. Will it only listen on local or remote? What port? I will find out shortly. I've been using apache to serve the files...there is a start apache conf file in the conf folder off root.
The nodejs on the latest BBB is 6.4 and it doesnt support "serve" which requires async-wait stuff. You can either update the nodejs to 8 or later, or use the apache config file. I got apache working no problem.
I just noticed the web interface is trying to connect to localhost which if access the site not on the BBB then it will timeout. So for now use http://
Here is some notes on my latest fresh install of Treadstation on BBB:
Enable/Disable some DT overlays:
Set hostname
Export PWM pin for usage: (this enables P8_13 pin)
Setting up Treadstation
Browse to BBB. For now add ?host= so the websocket connects to BBB as well.
@Davrizio Any update/progress from your side?
Hey Colin! First off, thanks so much for your help! We’ve been away on vacation the past couple of weeks, didn’t even see you had replied! I’ll get to trying it out this week, I’ll let you know how it goes!
On Jul 16, 2018, at 12:33 PM, Colin MacKenzie notifications@github.com wrote:
@Davrizio https://github.com/Davrizio Any update/progress from your side?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/flyingeinstein/tread-station/issues/2#issuecomment-405307353, or mute the thread https://github.com/notifications/unsubscribe-auth/AimtYqxoICmcd6bO58HfUFeIwvPik7OKks5uHMBcgaJpZM4UqFiJ.
Colin:
I've been lurking for a while. I attempted to get this going a year+ ago and gave up. I could drive the PWM after fixing the syntax errors, but I didn't have the foggiest how to get the UI to work. I noticed you'd been active, and with fall approaching, I thought I'd give it a try again. I'm happy to say that, with the instructions above, I'm able to drive the motor from the UI. Wow, your new UI is beautiful.
But where I'm stumped is the inclination. I see references to controlling the inclination throughout the code. And I think the two leftmost scales on the UI are the inclination. But I haven't the foggiest idea which pins and mode you're using on the BBB, and how they're configured. I found references to 8.13, which is the speed pwm. The controller has 3 wires: yellow/orange/violet for down/up/sensor.
BTW, I started with bone-debian-9.5-iot-armhf-2018-08-30-4gb.img and didn't do anything with capes or with the DTS that you've included. Just: echo 1 > /sys/class/pwm/pwmchip6/export config-pin 8.13 pwm
I configured the UI with apache and modified your example to use dist: sudo cat ~/tread-station/conf/web-ui.site | sed 's/client/dist/' > /etc/apache2/sites-available/tread-station.conf I also modified it to use 8080, which was the Apache default.
Your comments say that you changed the UI to use localhost, but I can't get it to work without specifying the host, a.la 192.168.xx.xx:8080/?host=192.168.xx.xx This is a problem, because I can get it to run from a PC, but none of my tablets will connect.
I can post better instructions if Davrizio is still looking for help.
Hi el-Slob, I am glad you got it working (mostly). I am not sure why the automatic host isnt working for you. The treadmill will look for host= parameter and if not, then it will take the host from window.location.hostname. This code is in file ui/client/js/treadmill.js, around lines 25-31. I believe you have apache configured on the same BBB as the treadmill nodejs control script so this should work.
Yes, my last run through installing this I didnt have to do anything but export and config-pin. You shouldnt have to do config-pin anymore either. My last commit to the sys.pwm driver in nodejs/drivers/output/pwm/sys.class.pwm.js should automatically set the PWM mux pin properly. It also says I didnt get it to do the export yet but that is my plan...no messing around with DT at all for the user.
If you are interested in developing you might want to explore around the nodejs/drivers directory. All the features and hardware control implementation is in files there. On startup, all files in that directory are scanned and probed. Each driver file on probe() call can check for hardware, configure it, then put itself on a "bus" so to speak. It's loosely based on DriverTree since I thought that was such a great idea...though I an mad as hell how unstable DT has been. Drivers can have dependencies that load first, such as Nordic PWM derives from standard PWM. Drivers can reference other drivers directly, or communicate via publish/subscribe "bus" which uses the "postal.js" library. Drivers can even communicate to the UI controls and vice-versa across the postal.js bus as I wrote a remote-link across web sockets. All the UI interaction is using the sub/pub postal.js bus.
I'll be honest I dont use the incline on the treadmill. I find it gives me shin splints if I am inclined at all. I added the wires and gave it a brief attempt but I didnt get it working. It didnt work even manually toggling the pin so I think it was a wiring issue, not a code one. I believe the incline UI works with the simulator and it talks to the ControlPanel driver in nodejs. So it should be fairly simple to create a new "pin" output driver that references the ControlPanel driver and subscribes to the control panel's status messages and outputs to a pin (any pin you choose). See the ControlPanel driver code around nodejs/drivers/user/experience/controlpanel.js, line 288. A simple driver example is the screensaver (backlight) control driver at (UI driver) nodejs/drivers/user/experience/screensaver.js and (output driver) nodejs/drivers/output/screensaver/xset|backlight. When you depend on a driver you also get a reference to it, so just depend on ControlPanel.
I feel your frustration at your first attempt. My treadmill BBB keeps dying (SD card failure/lost, lightning, you name it) and every time I needed to rebuild The devs changed DT paths for PWM. Arrg! I'd have to spend hours getting things back up, and often DT overlay compiling. I tried to support all the DT changes going on so the code would recognize PWM being in 3 or 4 different places. Things really changed the last time but I think, ...I hope, it is stable from here on out. I was surprised that after hours digging as usual it was like "oh, everything is already enabled I just need this new config-pin app." lol
I solved my "host" problem. Checked the status of bonjour: systemctl status avahi-daemon And it's running on tread-station.local
These urls work: http://tread-station.local:8080 http://tread-station.local:8080/?host=tread-station.local
FWIW, when I don't specify the host, it tries to connect to localhost, but fails. I tried a bunch of combinations, and none work. xx.xx.xx.xx/?host=localhost xx.xx.xx.xx/?host=127.0.0.1 xx.xx.xx.xx/?host=tread-station
Thanks for the pointers. I need to do some experiments with inclination...
Keep in mind that connecting to localhost means connecting to the computer that the browser is running on. The UI makes a web-socket connection initiated from browser javascript as client. So to use localhost you would need to be running the browser on the BBB. Without host= it should be using the host from the address bar (window.location.host) and if not there must be something in code overriding it. I wish I could run the code right now but my treadmill is buried under stuff from renovating the house but a month ago I was using it and it seemed to work.
Hey there! We have a treadmill with a bad control surface and this setup would revive and improve it! I am having some trouble getting things to load (mostly due to my limited knowledge!)
I have a BBB with the stock linux installed on the eMMC. I have the latest version of npm installed. I have downloaded and moved the tread-station folder to the root of the BBB. I cd into the nodejs folder and run node ./tread-station.js and run into syntax errors. 1st error is- use of const in strict mode. I reran using -harmony and then get unexpected reserved word.
So that is where I figured I was not doing something right!
Is there a guide for dummies that would help me get this going?
Thanks again!