# What is switching frequency

## Forum: Microcontrollers and Digital Electronics Switching frequency of a sensor

hi guys, i am not that well versed in electronics. If I have a sensor that has a switching frequency of 800Hz. Does that mean that it could provide me with a value 800 times a second? ...... e.g. for a rotating object where one pulse is measured per revolution. Would that mean that this sensor could theoretically scan this impulse 800 times per second if the object would rotate accordingly quickly ???? Would be nice of you if you could enlighten me :)

Switching frequency is actually the wrong term for a SENSOR. With sensor I would expect something like sample rate, sampling rate, sampling frequency or something. And then yes, at a sampling rate of 800Hz it would give you a new value a maximum of 800 times per second

Can you also tell me how many Hz such an Arduino Uno R3 on pin 2 can process PWM input as a frequency? The crystal is 16 MHz ..... But can it also process this 800 times per second, for example? My problem is the following ... I want to query the rotational speed / speed of an exercise bike using an inductive proximity switch and calculate / output it with the Arduino. Only when I accelerate a little bit more on the bike then the sensor just doesn't recognize the signal ....... and consequently the Arduino only gives me junk!

Sari wrote:> Can you also tell me how many Hz such an Arduino Uno R3 on pin 2> So> PWM input can process as a frequency ?? >> The crystal is 16 MHz ..... >> But it creates, for example also to process these 800 times per second? He can do that easily. >> My problem is the following .... >> I want to query the rpm / speed of an exercise bike> using an inductive proximity switch and calculate / output it with the Arduino>. No problem. > Only when I accelerate a little bit more on the bike then the> sensor just doesn't recognize the signal ....... and consequently the Arduino> only gives me junk! How did you mount the sensor? Does it record the revolutions of a wheel? Then you would have to give a lot of gas to get it out of step at 800 rpm. Small example calculation: Wheel circumference at 26 "is approx. 2.07 m. At 800 rpm you cover a distance of 1659 m / s. That is approx. 5972 km / h! I find that pretty sporty :-) So I guess that you do the acquisition differently, right? Describe the whole thing in more detail. In any case, 800 acquisitions / s would not be a problem. But you don't need that much for the bike or the home trainer.

: D yes of course! That was just an example with 800 revolutions .. My only problem is that when I turn faster, I simply don't get any signal! As if the sensor just can't do that anymore ... I have attached a metal screw to one of the bike's wheels ... and an inductive sensor on the front side that detects this screw with every turn ..... It works with slower speed of the bike is also quite good .... Only when I accelerate, he just doesn't recognize it anymore

Sari wrote:> I have attached a metal screw to a wheel of the bicycle .....> and an inductive sensor on the front side that detects this screw at> every rotation ..... >> It works when the speed of the wheel is slow quite> good .... only when I accelerate, he just doesn't recognize it anymore. Then I would suggest you first look at the signals from the sensor to see whether they come out of the sensor cleanly at any speed. If this is a sensor with an open collector output, it must have a pull-up resistor at the output. If the impulses are properly applied, then it is probably due to the software. You can put in your source code and the circuit diagram.

Sari wrote:> My problem is the following ... >> I want to query the speed / speed of an exercise bike> using an inductive proximity switch and calculate / output it with the Arduino> Only when I accelerate a little bit more on the bike then recognizes the> sensor just doesn't remember the signal ....... and consequently the Arduino> only gives me scrap! A rough calculation: Your object, which is to be detected, is 10mm in diameter and is arranged on the wheel in such a way that it covers 2000mm with a full wheel rotation (thus it is almost on the rim). At one revolution per second it generates a pulse of 1 / 200s. At four revolutions / s the pulse is only 1 / 800s long. This means that the upper switching frequency has been reached for the sensor. With a 28 "bike that's around 30km / h, if I'm not mistaken. Sari wrote:> I have attached a metal screw to a wheel of the bike ..... Take a larger object, which leaves the sensor on for longer. My tip for frequency / speed with an Arduino UNO R3: http://www.mino-elektronik.de/fmeter/fm_software.htm#bsp7

m.n. wrote:> Take a larger object, which leaves the sensor on longer. Or mount it closer towards the hub, then the peripheral speed is also lower and the impulse is longer. @ m.n .: Thanks for the tip, I didn't pay any attention to the pulse length.

So guys, thanks in advance for the great tips! Can now absorb everything, even at high speed. Now I have one more problem ... I now have to calculate the speed based on this number of revolutions. I wanted to build a timer that reads the revolutions from my variables every second. Then I would actually have revolutions per second. But how can I pull the variable out of my timer interrupt that does something for me every second, now from another interrupt that counts the revolutions?

does your sensor still only emit 8 volts at the output as you wrote in another post? Then you should read the sensor data sheet. The maximum switching frequency of the sensor should also be specified there, but this is only achieved if the sensor supply voltage is in the permitted range ...

the problem has long been fixed. It is now only a matter of calculating the speed. I just can't get the program technically ..... Please help!

By measuring the time between 2 impulses and then calculating according to the well-known formula f = 1 / T.

I have now programmed so far that I can calculate speed and speed ...... I realized the whole thing with a timer that looks every second how many revolutions it has made in that second. Unfortunately I use the same timer1 for speed () and speed (). With the output I only get the speed output. But I would like to have both issued! Do I need a 2 timer or does it work with 1 timer? If so, how does that work :) Enclosed my program! -------------------------------------------------- ------------ #include "TimerOne.h" const int inputPin = 2; const int outputPin = 13; int every_x_seconds = 1; int revolutions_min; const long circumference_cm = 94.24777; double circumference_km = 0.000942477; double speed_sec; double speed_hour; volatile int revolutions; void setup () {pinMode (outputPin, OUTPUT); pinMode (inputPin, INPUT); Serial.begin (9600); Timer1.initialize (every_x_seconds * 1000000); Timer1.attachInterrupt (speed); Timer1.attachInterrupt (speed); attachInterrupt (0, keyPressed, RISING); // 0 is the interrupt for pin 2, keyPressed () is called on every rising edge} void keyPressed () // count up state if at least 50ms have passed since the last edge {revolutions ++; } void speed () {revolutions_min = revolutions * 60; Serial.println ("revolutions / min"); Serial.println (revolutions_min); Revolutions = 0; } void speed () {speed_hour = circumference_km Revolutions 3600; Serial.println ("speed in km / h"); Serial.println (speed_hour); Revolutions = 0; } void loop () {}

### Important rules - read first, then post!

• Use upper and lower case
• Do not insert longer source code in the text, but as a file attachment