Author Topic: Effective routine to determine speed using a reed switch  (Read 929 times)

0 Members and 1 Guest are viewing this topic.

Offline XaviPachecoTopic starter

  • Regular Contributor
  • *
  • Posts: 243
  • Country: do
Effective routine to determine speed using a reed switch
« on: August 23, 2018, 02:06:06 pm »
I have an old treadmill which has a reed switch by default to "measure the speed". It's like shown in the attachment.

As you know, reed switches have very poor resolution, i.e, a pulse per revolution. And, at low speeds, this is terrible. But I'm curious about how I can create a code with STM32 to effectively measure the speed without a time-consuming routine. I know there are better sensors with better resolution, but this time I would like to take advantage of the structure of the machine, instead of adding another sensor.

Interrupts services, or what?

I would appreciate any ideas.
 

Offline MasterT

  • Frequent Contributor
  • **
  • Posts: 826
  • Country: ca
Re: Effective routine to determine speed using a reed switch
« Reply #1 on: August 23, 2018, 05:10:47 pm »
I have an old treadmill which has a reed switch by default to "measure the speed". It's like shown in the attachment.

As you know, reed switches have very poor resolution, i.e, a pulse per revolution. And, at low speeds, this is terrible. But I'm curious about how I can create a code with STM32 to effectively measure the speed without a time-consuming routine. I know there are better sensors with better resolution, but this time I would like to take advantage of the structure of the machine, instead of adding another sensor.

Interrupts services, or what?

I would appreciate any ideas.

 To measure high frequencies count unknown frequency pulses at the input during known gate time (1 sec).
 To measure low frequencies count known frequency pulses (from internal timer perhaps) during unknown gate - reed switch.
Micro-controllers have special feature, called ICP - input capture. Dig your stm32 data sheet, than examples code from the google how to use an ICP.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf