??? 05/23/04 03:43 Read: times |
#70977 - Rotary encoder problems |
I have just built a small circuit using an Alps rotary encoder, but I can't get it to work correctly. The pulses from the encoder are being counted, but unfortunately the counter goes up no matter which way I turn the encoder ;)
One side of the encoder is connected to P3.5 (ENC0 in the code), the other side is connected to INT0 through an HC148 priority encoder. This is the code I use: void Button(void) interrupt 0 //Extern 2 - INT0 { IE = 0; enc = ENC0; if (BUT2 == 0) //Encoder { if (enc == 0) //Vol+ { if (vol < 63) { vol++; writespi(1); } } else //Vol- { if (vol > 0) { vol--; writespi(1); } } } Are there any obvious errors in the code (or hardware)? If I "cheat" and disconnect P3.5 (keeping it high) the counter does go down. The controller is an AT89C4051 running on 11.0592MHz, and the encoder is an Alps STEC16B04 that has the following data: # Output signal, channel A leads channel B by 54° ±30° with clockwise rotation # 24 pulse Best regards, Mikkel C. Simonsen |
Topic | Author | Date |
Rotary encoder problems | 01/01/70 00:00 | |
RE: Rotary encoder problems | 01/01/70 00:00 | |
RE: Rotary encoder problems | 01/01/70 00:00 | |
RE: Rotary encoder problems | 01/01/70 00:00 | |
RE: Rotary encoder problems | 01/01/70 00:00 | |
RE: Rotary encoder problems | 01/01/70 00:00 | |
RE: Rotary encoder problems | 01/01/70 00:00 | |
RE: Rotary encoder problems![]() | 01/01/70 00:00 | |
RE: Rotary encoder problems | 01/01/70 00:00 | |
RE: Rotary encoder problems | 01/01/70 00:00 | |
RE: Rotary encoder problems | 01/01/70 00:00 |