Arduino Forum

Using Arduino => Sensors => Topic started by: varangupta on Jul 19, 2014, 06:53 pm

Title: [SOLVED]frequency measurment
Post by: varangupta on Jul 19, 2014, 06:53 pm
i am using a encoder which generate a square wave of frequency less than equal to 4khz .
how can i measure the frequency of the wave without using interrupt .

is there any IC which can measure the frequency can output it as analog ouput
Title: Re: frequency measurment
Post by: Peter_n on Jul 19, 2014, 06:56 pm
Which encoder is it ?
Search for : arduino frequency counter
Converting it to analog seems not right, why would you do that ?
Is there a special reason that you don't want to do this with the Arduino ? Are you running out of timers ?
Title: Re: frequency measurment
Post by: varangupta on Jul 19, 2014, 07:18 pm
it is a rotary encoder of resolution 512 PPR rotating at max. of 450 rpm .

as i am using spi device with arduino it disables interrupt therefore i do not want to use interrupt
and also as i only want velocity ( which will be proportional to frequency ) i want to remove load from arduino
Title: Re: frequency measurment
Post by: Peter_n on Jul 19, 2014, 07:56 pm
Does SPI disable interrupt ? Who told you that  ]:)
Which Arduino board are you using ?

The microcontroller on the Arduino board (often a ATmega328p) has a number of hardware devices inside. There are for example timers that can also count. The ATmeg328p has three counters, and one is used by the Arduino software. So you still have a 16-bit and a 8-bit counter. Using a timer, measuring the frequency is possible with only one interrupt at the end of a measurement.

I think I misinterpreted your question. You don't want to measure the frequency of a single signal, but you need to capture both signals of a rotary encoder.
Because of the two signals, often interrupts are used:
http://playground.arduino.cc/Main/RotaryEncoders
And you would like an external chip to do that ?

There are rotary encoder modules, some of those have a SPI or I2C interface.
https://www.ghielectronics.com/catalog/product/457
Title: Re: frequency measurment
Post by: varangupta on Jul 19, 2014, 08:07 pm
i use ps2 controller to controller motor speed.

and in ps2 library while sending and recieving bytes cli() is used
Title: Re: frequency measurment
Post by: Christo on Jul 20, 2014, 07:38 pm
If you want to measure speed but not direction of the encoder then you could use LM2907/LM2917 frequency to voltage converter IC and use an analog pin to read the output.
Title: Re: frequency measurment
Post by: varangupta on Jul 20, 2014, 08:22 pm

If you want to measure speed but not direction of the encoder then you could use LM2907/LM2917 frequency to voltage converter IC and use an analog pin to read the output.


thanks that helped