Deconvolution for rotational speed estimation on an ESP32 in real time

  Рет қаралды 222

T.J Moir

T.J Moir

7 ай бұрын

How to get accurate rotational speed estimation from a quadrature encoder without counting pulses in a given time. It's rather long starting with theory so you can skip to the demo at the end if you like. Uses an ESP32 micro and a quadrature encoder. Real time demo is shown. Code is here:
//Deconvolution filter to get rotational speed from rotational digital position
volatile int counter = 0;
// Quadrature encoder: change these numbers as required
#define outputA 35
#define outputB 32
// for sampling freq
int sample_pin = 21;
float d1, b0, b1, z0, z1, u0, u1, yout; // d is spectral factor coefficient from polynomial
void IRAM_ATTR isr_quadencoder() {
// quadrature encoder
if (digitalRead(outputA) == digitalRead(outputB)) {
//Clockwise
counter++;
} else {
//Counter Clockwise
counter--;
}
}
boolean running = false;
void setup() {
d1 = -0.0839;
b0 = 0.8392;
b1 = -b0;
z0 = 0.0;
z1 = 0.0;
u0 = 0.0;
u1 = 0.0;
// Serial port for debugging purposes
Serial.begin(57600);
pinMode(outputA, INPUT); //Encoder input A
pinMode(outputB, INPUT); //Encoder input B
pinMode(sample_pin, OUTPUT); //Sampling freq measure with scope
attachInterrupt(outputA, isr_quadencoder, FALLING);
// end setup procedure
}
//while loop
void loop() {
// Deconvolution filter
z1 = z0;
u1 = u0;
u0 = counter;
//z0=0.0839*z1+0.8392*u0-0.8392*u1;
z0 = -d1 * z1 + b0 * u0 + b1 * u1;
yout = 100 * z0;
Serial.print(6000);
Serial.print(", ");
Serial.print(-6000);
Serial.print(", ");
Serial.println(yout);
delay(4);
digitalWrite(sample_pin, running);
running = !running;
// end of while loop
}

Пікірлер: 2
@mberoakoko24
@mberoakoko24 7 ай бұрын
I found this very randomly sir, this has peaked my curiosity alot , thank you sir.
@TJMoir
@TJMoir 7 ай бұрын
Thank you, glad you found it of use.
Matlab Online Tutorial - 01 - The User Interface, Part 1
5:21
Math and Science
Рет қаралды 144 М.
Two wheeled self-balancing wheel chair
2:09
T.J Moir
Рет қаралды 307
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
Smart Sigma Kid #funny #sigma #comedy
00:40
CRAZY GREAPA
Рет қаралды 23 МЛН
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 831 М.
Real time Kalman filter on an ESP32 and sensor fusion.
23:40
T.J Moir
Рет қаралды 12 М.
Length Measurement using Counter - Encoder
0:52
Intech Chennai
Рет қаралды 39 М.
Water powered timers hidden in public restrooms
13:12
Steve Mould
Рет қаралды 620 М.
Should Americans Worry About Mass Surveillance in the US?
15:40
VICE News
Рет қаралды 270 М.
How AI could help us talk to animals
9:06
Vox
Рет қаралды 295 М.
Why The U.S. Elects So Many Older Politicians
9:59
CNBC
Рет қаралды 115 М.
AI Interacts with other AI ChatGPT4o
6:36
T.J Moir
Рет қаралды 469
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22