Encoder 1000 ppr

Hola, quisiera saber si el arduino es capaz de leer un encoder de 1000 pulsos por revolucion a 1200 revoluciones por minutos. muchas gracias por su respuesta.

20 Rev / sec x 1000 Quadrature Pulses / Rev x 4 Interrupts / Quadrature Pulse = 80,000 Interrupts / sec. I'd think about a Teensy 4.0.

1 Like

The Arduino DUE embeddes 2 quadrature decoders, providing 2 sets of registers to measure either position or speed. These decoders can count up to 42 million edges/s.

There are numerous example sketches such as those (see reply #86 and #88):

1 Like

Hi, @Aldaiir15
What is the application?

Tom... :grinning: :+1: :coffee: :australia:

1 Like

Interesting. How do these built-in quadrature decoders handle contact bounce?

You select yourself what is supposed to be EMI with TC_BMR_MAXFILT() number, e.g. in the example code at reply #86:

TC_BMR_MAXFILT(1); // Pulses with a period shorter than MAXFILT+1 peripheral clock cycles are discarded

1 Like

Estoy usando Teensy 3.5 y a velocidades de 150 Metros por minutos me funciona bien pero cuando aumentó la velocidad este deja de contar o se va a 0, creen que sea problema del digitalRead()? He visto que dicen que es muy lento para cálculos rápidos.

Hvernig líður það að vera neyddur til að nota Google Translate til að skilja færsluna?
Teensy 4.0 er með vélbúnaðarborð !! Og ætti að vera nógu hratt

I am using Teensy 3.5 and at speeds of 150 Meters per minute it works fine
but when I increased the speed it stops counting or goes to 0, do you think it
is a problem with digitalRead ()? I have seen that they say it is too slow for
quick calculations.

How does it feel to be forced to use Google Translate to understand the post?
Teensy 4.0 has a hardware board !! And should be fast enough

Tom.... :astonished: :astonished: :astonished: :astonished: :astonished:

Yes teensy 3.5 is too fast so I don't know what is the problem
Here is my code I'm using
#include <LiquidCrystal_I2C.h>
#include<Wire.h>

#define CHA 25
#define CHB 28
#define BTN 24

volatile long int ticks = 0;
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int LEDR = 33;
const int LEDA = 34;
void setup() {

Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(2, 1);
lcd.print("BIENVENIDOS");
delay(2500);
pinMode(CHA, INPUT_PULLUP);
pinMode(CHB, INPUT_PULLUP);
pinMode(BTN, INPUT);
attachInterrupt(digitalPinToInterrupt(CHA), conteo, CHANGE);
attachInterrupt(digitalPinToInterrupt(BTN), imprimir, RISING);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Metros Contados: "); // Mensaje a despegar

lcd.setCursor(0, 1);
lcd.print(" m");
pinMode(LEDR, OUTPUT);
pinMode(LEDA, OUTPUT);

}
void imprimir() {
if (ticks != 0) {

Serial.println((ticks * 0.02) / 100);
ticks = 0;

}
}
void conteo() {

if (digitalRead(CHA) == HIGH) {
if (digitalRead(CHB) == LOW) {
ticks++;
} else {
ticks--;
}
} else {
if (digitalRead(CHB) == LOW) {
ticks--;
} else {
ticks++;
}
}

}

void loop() {
if (ticks < 0) {
ticks = 0;

}

lcd.setCursor(1, 1);
lcd.print((ticks * 0.02) / 100);

if (ticks >= 1) { //Encendido de leds
digitalWrite(LEDA, HIGH);
digitalWrite(LEDR, LOW);

} else {
digitalWrite(LEDA, LOW);
digitalWrite(LEDR, HIGH);

}
if (ticks == 0) {

lcd.setCursor(1, 1);
lcd.print(ticks);
lcd.print("    ");
lcd.setCursor(12, 1);
lcd.print("STOP");

} else {
lcd.setCursor(12, 1);
lcd.print("RUN ");
}

}

This is not the way how you would read out a quadrature encoder. There are a lot of libraries around doing this much better.
A couple of years ago I did a project involving reading 3 encoders at 200kHz with a Teensy 3.2. I used a simple polling algorithm and had not problems at all. Here some information and code which should run on your T3.5.: https://forum.pjrc.com/threads/38736-Encoder?p=120710&viewfull=1#post120710
The actual code is attached to #11 of the linked post.

You might also have a look at the EncoderTool for Teensies:

Examples and documentation can be found in the corresponding wiki.

You can also see: http://www.buxtronix.net/2011/10/rotary-encoders-done-properly.html?m=1
And: https://github.com/gfvalvo/NewEncoder