I think your speculation supports my gut feeling that I'm asking the ESP32 to do something that it really can't. I like the idea of your work around by using parallel inputs and attaching separate interrupts to them. I'll give that a try later today when I get some time. Real life has "interrupted" my hobby and I've some business to take care of.
Thanks again everyone, I'll keep you posted.
PROBLEM SOLVED!
Thanks for the help from all you. You should have seen the smile on my face when I saw the number 400 on my serial monitor. 😀 . Not sure if I tagged everyone properly so let me know how to do that if it helps.
I used Dave's work around using parallel inputs and it worked right away. I haven't looked at the libraries yet, but I plan to. However, since the ultimate application of this is to read linear scales (that have quadrature outputs) from a machine tool for absolute positioning, is it comforting to know exactly how the counts are derived versus using data from a library that I didn't write. The libraries are likely just fine, but I know this code works as intended.
I was obviously confusing the processer with what I was trying to do. I'm sure there are other ways of doing this, and perhaps better ways, but this works fine for me now. I learned a lot from this exercise, which is something I try to do each day.
Here is the modified code I used. It could certainly be optimized but it does illustrate the changes that allowed this scheme to work. Channel A of the encoder is connected to pins 32 & 34, Channel B is connected to pins 33 & 35. There are plenty of GPIO pins on the ESP32 so doubling up is not a problem from a hardware perspective.
Thanks again for all the help. This is an awesome forum.
Jim
#define A1_pin 32 // ARise #define B1_pin 33 // BRise #define A2_pin 34 // AFall #define B2_pin 35 // BFall volatile long NSV = 0; // Net Sum Value int A1pin = 0; int B1pin = 0; int A2pin = 0; int B2pin = 0; void IRAM_ATTR Arise (){ B1pin = digitalRead(B1_pin); if (B1pin==0) {NSV++;} if (B1pin==1) {NSV--;} } void IRAM_ATTR Brise (){ A1pin = digitalRead(A1_pin); if (A1pin==1) {NSV++;} if (A1pin==0) {NSV--;} } void IRAM_ATTR Afall (){ B2pin = digitalRead(B2_pin); if (B2pin==1) {NSV++;} if (B2pin==0) {NSV--;} } void IRAM_ATTR Bfall (){ A2pin = digitalRead(A2_pin); if (A2pin==0) {NSV++;} if (A2pin==1) {NSV--;} } void setup(){ Serial.begin(115200); pinMode (A1_pin, INPUT); pinMode (B1_pin, INPUT); pinMode (A2_pin, INPUT); pinMode (B2_pin, INPUT); attachInterrupt(A1_pin,Arise,RISING); attachInterrupt(B1_pin,Brise,RISING); attachInterrupt(A2_pin,Afall,FALLING); attachInterrupt(B2_pin,Bfall,FALLING); } void loop(){ Serial.println(NSV); }
By the way, Alice sends her best......