Hello dear friends,
I want to read pulse from a 5000 pulse per rev direct drive encoder with an ardoino mega 2560 , but when speed goes upper than 240 rpm , arduino can not count pulses.
If you are interrupting on both pulse edges (rising AND falling) on both channels (A and B), you are getting 2 * 2 * 5000 = 20000 PPR * 4 RPS = 80000 PPS. Is that within the library's capability?
edgemoron:
If you are interrupting on both pulse edges (rising AND falling) on both channels (A and B), you are getting 2 * 2 * 5000 = 20000 PPR * 4 RPS = 80000 PPS. Is that within the library's capability?
You are right .
I don't know. Do you know a library support that ?
cattledog:
What are you doing that requires that kind of resolution at 4 rps?
An encoder can be read with 1,2, or 4 counts per pulse. The interrupt overhead can be reduced accordingly.
I have a machine and use in it.
I found only this library usefully, others did not work good.
Is there any way to reduce 4x resolution to 1x in this library ?
Is there any way to reduce 4x resolution to 1x in this library ?
Not that I see. If you put one pin on an interrupt pin and the other on one which does not support an external interrupt the library will read the encoder at 2x resolution.
You may also wish to experiment with the addition of this line to speed things up.
#define ENCODER_OPTIMIZE_INTERRUPTS
This quote is from the encoder.h library example "Speed Test"
// This optional setting causes Encoder to use more optimized code,
// but the downside is a conflict if any other part of your sketch
// or any other library you're using requires attachInterrupt().
// It must be defined before Encoder.h is included.
//#define ENCODER_OPTIMIZE_INTERRUPTS