-
Need more accuracy?
10/14/2017 at 12:49 • 0 commentsWhen I compare the distances in my CSV file and the ones displayed on the original panel screen, they do not match and I am not very surprised.
Currently I just take for granted that the treadmill runs at the speed it is supposed to, and that acceleration/deceleration is instantaneous, I know it is not true.
On the 6 pins connector between the panel and the treadmill, I strongly suspect there are some rotary encoder signals. This is probably how they read the speed of the engine.
To get the real speed of the treadmill and improve the accuracy, | see 3 solutions :
- add a PCB with a LS7083N and a 12V-to-5V converter
- read the speed at the LCD controller level
- not using any other signal but using a less naive modelisation of the treadmill speed in my arduino code, including the time ittakes to accelerate
I will probably try the 3rd approach first since it doesn't involve any hardware modifications. It won't be as accurate as the 2 other approaches but it's not a big deal if I don't know the precise number of calories I burn each day. After all, the number of calories is already an estimation, and in my case I mostly use those values to track how much exercise I do during the week
On another topic, I added a git repository to the project, and I improved the charts by removing the year from the dates and limiting the display to the last 10 days.
-
Logging my physical activity
10/04/2017 at 09:32 • 0 commentsNow that the treadmill is working and can be controlled from my PC, there is one more feature I need, logging how long I use my treadmill everyday and what distance I walk.
This feature requires modifications both on the Arduino and python code:
- The Arduino should give more information about the status of the treadmill, running or not, and about its speed.
- The Python script should store the time and the speed when the treadmill starts and log everything in a file when it stops.
- A new script should draw a bar chart of the data
Let's not reinvent the wheel and use CSV to store our data. But wait, there is one problem: in what format will we store the date?
I was going to store it in the European format, dd/mm/yy, but what if an American user (imaginary user of course, I'm not sure anybody else than me will use this) wants to import the data in LibreOffice or Excel?Well, according to Stack Overflow, it looks like there is an unambiguous format that works with every locale : yyyy-mm-dd
So even if it doesn't matter for this project, I learned a useful trick next time I need to deal with both sides of the Atlantic.Here is a line of my CSV file:
# date ,hours,minutes,seconds,distance, duration,calories 2017-10-04, 10 , 44 , 42 , 1845 , 23 , 53
Now to draw the chart, I had a look at the web based solutions, but for now I think I'll stick with Python, I don't want to use JS for this project. So here is what it looks like with matplotlib
I could just bind a key to generate this graph and display it with eog, but I'd rather serve it through a web page, so I think it will be the next step.
-
Treadmill as an assistive technology
09/03/2017 at 17:41 • 0 commentsI started this project as an ergonomic improvement for my workstation, but treadmills can also be used in the context of post surgery rehab, like for hip surgery.
Of course, in this case it would be wise to add handles or hand rails and to have a mat around the treadmill so that if the user needs, he can safely leave the treadmill in case of urgency.
-
Buzzer and Power
07/27/2017 at 05:12 • 0 commentsThere was a problem I didn't mention with the control panel, I couldn't control it anymore when the Arduino was not powered.
This could probably have been fixed by adding diodes but as I will need to power the Arduino anyway if I want to use Bluetooth, I just chose the later.So I just soldered a pin on the on an unpopulated part of the PCB that said "5V". I first tried one saying "5V Backlight" but it turned out to be 0V, it is probably activated by the MCU on other models of treadmill.
Then I connected the Vin of my Arduino Nano to this pin. From what I read, 5V is not enough to power the Nano through Vin, you must directly connect it to the 5V Pin (which makes sense but I thought it was an output only pin).Also I unsoldered the buzzer because it was too loud. I soldered pins instead so may be I will add a resistor or feed the signal to the Arduino. It feels a less safe to not have the three warning beeps before the treadmill starts, I will try to find something safe and not annoying.
-
The whole picture
07/20/2017 at 12:13 • 0 commentsI realize I did not put a lot of pictures of the treadmill itself :
-Here is the treadmill mode
-Here is the standing desk mode,
I just put the treadmill away and attach it to the desk with a snap hook. It is relatively safe but if you have kids or pets you'd better not let them in the room when you're not around.
-Here is the normal desk mode
Just lower the desk and take a chair
It was quite important for me to keep a single desk. If you are just using a laptop it's, ok to a treadmill desk plus a regular desk but in my case I didn't want to move all my stuff around each time, plus I didn't have a lot of room for another desk.
-
I've been replaced by a robot!
07/19/2017 at 20:30 • 0 commentsRobots were taking our jobs, now they're taking our pastimes ;-)
I tried to use a robot (Mip) on the treadmill just for fun but it may be useful for those are working on a robot for the Hackaday prize. It can be less tiring than running after your robot, it may really be easier to spot a problem with your robot if you're just standing instead of trying to follow your him. For example I noticed that my Mip was going to much on the right, it was really obvious on a treadmill. -
Distance & Calories
07/18/2017 at 22:25 • 0 commentsI'm working on the display now. It won't require any hardware modification for now.
Distance calculation
I'm going to trust the speed the Arduino thinks it has : I know that the treadmill starts at 0.5 km/h and I know when the speed is modified, at least when it is changed by the Arduino. So every second I can add a certain value to the total distance, depending on the speed.
I'd prefer to avoid using floating point arithmetic in the Arduino code, in the end, it's just a 8 bit mcu!
So I'll count the speed in tenth of kilometers
// speed are in tenth of km/h
unsigned int maxSpeed = 80;
unsigned int minSpeed = 5;
unsigned int currentSpeed = 5; // the initial value is the speed of the treadmill when it just switched on
unsigned int speedStep = 1; // the step it increases/decreases every time we push a buttonand I also need to know if the treadmill is running or not, I'll only update the distance if the treadmill is running
int treadmillRunning = 0; // 1 if the treadmill motor is on, 0 otherwise
Then I'll store the value in an unsigned long, because int are only 16 bits on Arduino, and I'll call the update function every second with a timer :
unsigned long totalDistance = 0;
void countDistance()
{
if (treadmillRunning)
totalDistance += currentSpeed ;
}I'm using this library for timers : http://playground.arduino.cc/Code/Timer
Display
How will I display the data? On Linux desktops I'll use the Freedesktop notifications. For example here is the result with notify-send from the libnotify-bin package
Calories
I found a formula on Shapesense :
CB = [0.0215 x KPH3 - 0.1765 x KPH2 + 0.8710 x KPH + 1.4577] x WKG x T
CB = Calorie burn (in calories)
KPH = Walking speed (in kilometres per hour)
WKG = Weight (in kilograms)
T = Time (in hours)Once I get the distance right, it should be easy. It will be calculated on the PC, not on the Arduino, so you can easily enter your wheight/height parameters in a config file.
-
Status:working
07/16/2017 at 09:41 • 0 commentsI worked on 2 parts : the Arduino code and the integration in my desktop.
The arduino part was easy, I just had to read the serial port and wait for on of the 3 control characters I picked and set the corresponding pin to LOW.
But I met some difficulties with the serial port access from my PC. Initially I though I could avoid writing any "real" code and stick to Bash, I couldn't avoid some python script:
- I tried to send commands to the Arduino with picocom : OK
- I set up the serial port with stty and tried to echo/cat some commands to the serial port /dev/ttyX : failed
- I connected to the Arduino with socat - /dev/ttyUSB0 : OK
- I tried to send commands to the Arduino with echo -n s | socat - /dev/ttyUSB0 : failed
Then I searched the internet and found a page mentionning that to connect to the Arduino, you needed a 3 seconds delay for it to be ready to receive serial data. I had never heard of this "reset on serial connection behaviour" but it seemed to match what I was observing, so I tried the following command :
- echo $(sleep 3 && echo s)| socat - /dev/ttyUSB0 :ok
It worked, but it is not really usable, I don't want to have a 3 seconds delay for every command I send.
So instead I tried to use a pipe or UDP socket :
- socat PIPE:/var/run/pipo.pipe /dev/ttyUSB0,raw :failed
- socat UDP-LISTEN:6666,fork GOPEN:/dev/ttyUSB0 : failed
So I wrote a small python script that listens to UDP packets and send them on the serial port. This will make it easier to run on Windows
As I am using Awesome, I created some shortcuts to control the treadmill by adding the following in /etc/xdg/awesome/rc.lua :
awful.key({ modkey, "Control" }, "Left", function() awful.util.spawn("/usr/local/bin/treadmill-control m") end),
awful.key({ modkey , "Control"}, "Up", function() awful.util.spawn("/usr/local/bin/treadmill-control s") end),
awful.key({ modkey , "Control"}, "Right", function() awful.util.spawn("/usr/local/bin/treadmill-control p") end),treadmill-control is just a very basic script that sends the first parameter on a UDP socket :
#! /bin/sh
if [ $# -ne 1 ] ; then
echo "error $0 needs a single parameter :"
echo "s : start/stop the trheadmill"
echo "p : increase speed"
echo "m : decrease speed"
fi
echo -n $1 | socat - UDP:127.0.0.1:5005 -
Controlling the treadmill with an arduino
07/15/2017 at 09:29 • 0 commentsThe easiest way to control the treadmill is to simulate button presses, the original MCU will take care of changing the speed and stopping/starting the treadmill.
So the Arduino code should look like this :
Loop
{
check serial port for commands
if we receive a valid command, then simulate a key press
}There is only 3 switches on the control panel :
- slower
- start/stop
- faster
The plan is to connect some Arduino pins to those switches, but first we need to check if the switches are connected to the ground or to VCC: They are connected to the ground, so it in the code we must set the pins to HIGH on init and set them to low when we want to simulate a key press.
So we just solder 4 jumper cables on the panel board, 3 for the switches and one for the ground and we will connect them to the Arduino.
So far it is working!
I tried to set pin connected to 'faster' to LOW for 500ms and it simulated 2 key presses. I lowered the timing to 250 ms and now it is reliable!
I will quickly upload the code here. -
What is this chip?
07/13/2017 at 05:39 • 0 commentsMy treadmill desk setup is done, now I have to control it with my computer. Time to do some reverse engineering to see how the treadmill works.
When I opened it I saw a chip I can not identify :
Here is what is engraved on the chip :
HT48R066B
B435U0093G1There was also a label on it saying : TC5376A-V2.00-B OTP
Any idea what this chip could be ?
EDIT: well, I found, it's a Holtek, I misread the T and thought it was a I