Help with creating a gauge to display MPH for a treadmill

Hello,
I am new to Node-RED and programming in general so please bear with me. I am trying to replace a broken treadmill console Raspberry Pi 4 Model B and a touch screen. I would like to display and control everything in the node-Red-dashboard. I already have a few things working such as incline/decline and speed control.

I am needing some help with creating a speedometer gauge to display the belt speed in MPH. I have been able to view the speed pulses from the treadmill's tachometer line on my oscilloscope and manually calculate RPM based on the pulses and some physical measurements I have made. For testing purposes I am feeding the tachometer pulses into the GPIO Pin 4 through a two resistor voltage divider to reduce the voltage to 3.3 volts. Using a crude python script running on the PI I am able to detect the falling edge of the pulses so I am confident that electrically everything is working correctly.

I have been searching the Internet looking for something like this and have not been successful.
I am not sure how to create a flow to read the pulses and display the results in MPH as a round gauge.
Any advice or thoughts would be much appreciated.

Thanks,
Dave

1 Like

What is the frequency of the pulses ? As the RPi is not a real time operating system it may not be able to accurately read and report on the pulses (as well as do everything esle you have in mind) in real time.

You may be better off using an external device such as an arduino or an ESP32 to capture this info and send that to the PI

I assume you want to do all this in realtime so i would start with something simple in the native NR dashboard - there are plenty of gauge modules etc in there.

Craig

Hi Craig,

Thanks for the reply. I have done a lot of searching on this topic and that comes up a lot. Given that it's a treadmill the speed will fluctuate between steps. It slows down slightly when you step on it and then speeds up slightly during the time while both feet are in the air so it has some undershoot and overshoot. It doesn't need to be real time but responsive. That's why I think average belt speed is fine. I am actually using my arduino to simulate the pulses coming from the tachometer.

I am not as worried about the electronics at this point as much as I am creating the flow to display the MPH on the dashboard. During this initial design phase I am not concerned with the gauge style yet. Just accurately reading from the GPIO and displaying the information. I have been playing around with node-RED and have some gauges displayed, just not getting data into the gauges.

As far as the frequency, it will vary with speed. The treadmill has a single magnet imbedded in the drive wheel so with each revolution of the wheel I get one pulse.

The drive wheel is approximately 2.59 CM which gives a 16.3 CM circumference. The magnet is approximately 1.3 CM or about 8% of the length of the circumference.

Since the original console is broken, I could only get two speeds to work.
At 4 MPH, the total period is about 88 milliseconds or 11.3 Hz
At 10 MPH the total period is about 38 milliseconds or 26.3 Hz

The speed reading on the console still works, so these speeds are according to the readout on the console. I am sure these are programmed values in the console and not derived from the tachometer signal. In any event its good enough for a home treadmill.

For testing purposes I have found some some python scripts on the raspberry pi forum that are interrupt driven. The are accurate enough to show me that the electronics are working and that I am getting usable signals into the R PI and that my calculations are in the ball park.

Any advice creating the flow would be helpful.

Dave

OK well not sure how far you are along with the python side - but this will give you a good basis

https://www.raspberrypi.org/forums/viewtopic.php?t=118230

And this looks interesting (but i have not used it)

Craig

Thanks for sharing this with me Craig.

There are a few scripts on this page that I have been experimenting with and work OK.
https://www.raspberrypi.org/forums/viewtopic.php?t=151465

I am really wanting to use node-RED-dashboard because all of this will be running on an RPI with a touch screen. Plus I am trying to learn node-RED.

Thanks,
Dave

The simplest way will be to install the node-red-node-daemon node and use it (with -u) parameter to call your python script. This should give you whatever comes out of your python, which we can then clean up and send to the dashboard gauge..