 # High speed encoder, data acquisition, save data

Hi,

I have a quadrature encoder which generates 400 pulses per one rotation.
I'm trying to use this encoder to measure the angle of rotation of a motor.
The speed of the motor varies from 500 rpm to 2000 rpm.

At max speed of the motor, I need to capture 13,000 pulses per one second.

I need to count the number of pulses and save the number of pulses against a time stamp.

What is the method I can use to store my data at such a rate.??

The arduino DUE embeds 2 hardware quadrature decoders for speed and position measurements.

In this thread, reply #55, you can find an example sketch successfully tested with a 1024 ppr quadrature encoder (4 * 1024 edges per rotation) at 3500 RPM (~ 238000 edges per second):

BTW, 400 *4 *2000/60 = ~54000 (and not 13000) !

Hi,

I have a quadrature encoder which generates 400 pulses per one rotation.
I'm trying to use this encoder to measure the angle of rotation of a motor.
The speed of the motor varies from 500 rpm to 2000 rpm.

At max speed of the motor, I need to capture 13,000 pulses per one second.

I need to count the number of pulses and save the number of pulses against a time stamp.

What is the method I can use to store my data at such a rate.??

2000 rpm * 400 = 800.000 / 60 = 13.333 IRQ/sec (==> 15K IRQ/sec with a safety margin
500 * 400 = 200.000 ==> 3400 IRQ/sec

You can reduce the number of pulses by only take the rising edge of one pin.
That reduces the amount of interrupts to handle by a factor 4

500 - 2000 RPM would be about 1000 - 4000 IRQ/sec which could be handled quite well by a Arduino.

Question:
How many times per second do you want to update the RPM value.
How many significant digits do you want.

one update per second with one decimal (e.g. 678.4) should very well be possible even with an UNO.

Storing the information 1x per second on an SD card should be no problem.

Check the example codes of the SD library.

For timestamps you need an RTC, there are different chips with different accuracies.
E.g. DS1307 is cheap, ds3231 is more accurate. Libraries are quite similar.

When an accurate resolution is needed, it is advisable for the counter to count the leading and trailing edges of the quadrature encoder’s pulse train from one channel, which doubles (x2) the number of pulses per revolution. Counting both leading and trailing edges of both channels of a quadrature encoder will quadruple (x4) the number of pulses per revolution.

ard_newbie:
The arduino DUE embeds 2 hardware quadrature decoders for speed and position measurements.

In this thread, reply #55, you can find an example sketch successfully tested with a 1024 ppr quadrature encoder (4 * 1024 edges per rotation) at 3500 RPM (~ 238000 edges per second):

http://forum.arduino.cc/index.php?topic=140205.45

What I want is to save the data I'm obtaining. I need to record the number of pulses with a timestamp so that I can get the angular position of the motor.

So basically, I need to save the number of pulses against time for every pulse.

which means I will have to save data at least at a rate of 13kHz. (13,000 information per one second)

( @ard_newbie, Thank you. I checked what you suggested. And I'm sorry, I meant 400 ppr in the quadrature mode. (100 ppr x 4))

What is the type number of the decoder?