Need some help with measuring speed on treadmill desk
Don M
Posts: 1,652
I have modified a treadmill to become a stand up desk. I am working on the controls to replace the rather large and clunky panel with a propeller based compact controller.
The existing controller sends a PWM signal down to the motor controller to set the speed. I have been working with the PWM object (PWM_3ctrx_demo) from Tracy Allen and have gotten it to work controlling the speed of the treadmill. Now my next venture is to measure and display the speed. The speed is detected with a reed switch / magnet combo on the shaft driving the walking belt. I have played with several objects (jm_freqin and Motor_Minder) but haven't gotten succesful results from either. I'm currently using Parallax Serial Terminal to set speed and display the speed but the readings are all over the place.
I have attached a couple scope traces from the output of the sensor. The input is pulled high and then pulled low when triggered by the magnet. The slowest speed setting produces a total period of 304.8 mS (3.28 Hz) and the period in which the magnet is sensed is 36 mS while one of the highest settings produces a total period of 43.2 mS (23.15 Hz) with a 4.64 mS sense time.
Does anyone have any good methods for measuring the RPM? I would then take that number and convert it to MPH.
Here are some pictures of the treadmill desk. I built it keeping in mind that I still wanted to be able to fold the desktop down and the track up for storage. I got the treadmill for free from someone in the neighborhood. There was basically nothing mechanically wrong with it.
Any help appreciated. Thanks!
Don M
The existing controller sends a PWM signal down to the motor controller to set the speed. I have been working with the PWM object (PWM_3ctrx_demo) from Tracy Allen and have gotten it to work controlling the speed of the treadmill. Now my next venture is to measure and display the speed. The speed is detected with a reed switch / magnet combo on the shaft driving the walking belt. I have played with several objects (jm_freqin and Motor_Minder) but haven't gotten succesful results from either. I'm currently using Parallax Serial Terminal to set speed and display the speed but the readings are all over the place.
I have attached a couple scope traces from the output of the sensor. The input is pulled high and then pulled low when triggered by the magnet. The slowest speed setting produces a total period of 304.8 mS (3.28 Hz) and the period in which the magnet is sensed is 36 mS while one of the highest settings produces a total period of 43.2 mS (23.15 Hz) with a 4.64 mS sense time.
Does anyone have any good methods for measuring the RPM? I would then take that number and convert it to MPH.
Here are some pictures of the treadmill desk. I built it keeping in mind that I still wanted to be able to fold the desktop down and the track up for storage. I got the treadmill for free from someone in the neighborhood. There was basically nothing mechanically wrong with it.
Any help appreciated. Thanks!
Don M
Comments
I don't think you have enough information. RPM is revolutions per minute. A simple method would be to count the pulses in a timed window, but to convert to RPM you need to know how many counts are in a single revolution. Knowing the diameter of the disc would allow you to convert RPM to MPH.
BTW... my jm_freqin object is very old and I'm updating it right now.
If your front roller is 2.5 inches in diameter, then 2.5 x 3.14 = 7.854 inches of travel for each pulse from the sensor. 1 mile = 5280 feet or 63360 inches, so 63360 / 7.854 = 8067.2 pulses per mile.
Most treadmills are limited to 10 MPh so assuming 10 MPh, that would be 80672 pulses every hour or 1344.53 pulses per minute at max speed or 22.408 pulses per second.
Also something that you need to consider is that most consoles don't just blindly output PWM to control the motor speed; they monitor what is coming from that sensor and adjust the output to maintain the speed under varying conditions.
As far as the timing object goes I would hold out and see what Jon has to offer.
The following equation should give you the frequency scaled by a factor of 100 from the time between two ticks of your "encoder".
I think even at the highest speed with only 4.6ms between ticks, Spin would be fast enough to compute the frequency. You'd want to make sure and use a dedicated cog to read the ticks. Of course if you used PASM, to time the intervals, the accuracy would be improved.
It would probably be a good idea to average the speed over multiple cycles.
To covert the value to revolutions per minute, multiple scaledHz by 60. The RPM would also be scaled by a factor of 100.
To convert these values to distance per time, you'd need to know the diameter of the cylinder or how much the tread moved with one revolution of the cylinder (which should be the same as the circumference of the cylinder).