Shop OBEX P1 Docs P2 Docs Learn Events
Need some help with measuring speed on treadmill desk — Parallax Forums

Need some help with measuring speed on treadmill desk

Don MDon M Posts: 1,652
edited 2015-01-02 00:01 in Propeller 1
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.

RPM 01.JPG
TEK0008.JPG


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.

treadmill_desk.jpg
treadmill_control.jpg
treadmill_folded.jpg


Any help appreciated. Thanks!

Don M
640 x 480 - 93K
640 x 480 - 95K
1024 x 576 - 198K
1024 x 576 - 152K
1024 x 576 - 170K

Comments

  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-01-01 11:01
    Does anyone have any good methods for measuring the RPM?

    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.
  • bte2bte2 Posts: 154
    edited 2015-01-01 16:42
    *most* treadmills have just one magnet on the shaft so the reed switch = 1 pulse per rev. The signal from the reed switch is wired straight through to the console- it doesn't do anything on the motor controller (except maybe flash an LED but that's rare). Take the diameter of the front roller in whatever units you want, and multiply that number x 3.14 to get belt travel per pulse.

    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.
  • bte2bte2 Posts: 154
    edited 2015-01-01 16:45
    Not trying to sound like your dad, but be careful- treadmills can bite real real hard.
  • bte2bte2 Posts: 154
    edited 2015-01-01 16:51
    As far as incline motors go, there are two techniques they use- absolute and incremental. Absolute uses a potentiometer so you might need an ADC if you want it to work by itself (like a programmable running course), and incremental runs the incline motor against the stop until the pulses stop coming from that sensor, then keeps count of those pulses to know how much it is inclined. A lot of them recalibrate when you first plug them in.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-02 00:01
    If you're only getting three readings a second, I think you'll want to measure the time between readings rather than counting ticks over some time interval.

    The following equation should give you the frequency scaled by a factor of 100 from the time between two ticks of your "encoder".
      scaledHz := 2_000_000_000 / (interval >> 2)
    

    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).
Sign In or Register to comment.