Edzelf / ESP32-Radio

Internet radio based on ESP32, VS1053 and a TFT screen.
GNU General Public License v3.0
985 stars 229 forks source link

Rotary encoder question. #192

Closed paysan18 closed 5 years ago

paysan18 commented 5 years ago

My rotary encoder does not work. However the push button works. I can see the action of the push button in the debug serial output. But when I rotate the encoder nothing comes out in the trace.

I tried a little standalone prog and all looks ok with this encoder. Same pins used. By looking at the code I have some questions.

  1. Pins are not defined in the Esp-radio-init sketch. Why not?

  2. If I press the config button I see them configured as pin 25, 26 and 27. So this looks good. Where does this come from? From the progpin_struct?

  3. What do the different fields mean in the struct progpin_struct?

Rainer-G commented 5 years ago

Do you still have the interrupts occuring without moving the encoder ? I had the same problem and found that if the interrupts come very fast, a rotation will not be detected. I put this :
tftset( 3, dbgprint( "Timer %5d %3d", enc_inactivity, rotationcount )) ;

at the start of chk_enc for a test and found that enc_inactivity never was above 3 or 4 so it was reset by the interrupt routine

Gesendet von Mail für Windows 10

Von: Willem Nijntjes Gesendet: Freitag, 30. November 2018 11:57 An: Edzelf/ESP32-Radio Cc: Subscribed Betreff: [Edzelf/ESP32-Radio] Rotary encoder question. (#192)

My rotary encoder does not work. However the push button works. I can see the action of the push button in the debug serial output. But when I rotate the encoder nothing comes out in the trace. I tried a little standalone prog and all looks ok with this encoder. Same pins used. By looking at the code I have some questions.

  1. Pins are not defined in the Esp-radio-init sketch. Why not?
  2. If I press the config button I see them configured as pin 25, 26 and 27. So this looks good. Where does this come from? From the progpin_struct?
  3. What do the different fields mean in the struct progpin_struct? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
paysan18 commented 5 years ago

Rainer, the interrupts did not come from the rotary encoder pins but from the pushbutton pin. I solderred a capacitor to GND on this pin and all works fine now. But the rotary is still dead. I will try the suggestion from Rainer this evening. Wim

Rainer-G commented 5 years ago

Wim, for my information : when you do a double or triple click and then no further action, will the display return to the text it was before the clicks ? If it does, no unexpected interrupts ocurr on enc data and clock. Rainer

Gesendet von Mail für Windows 10

Von: Willem Nijntjes Gesendet: Freitag, 30. November 2018 12:45 An: Edzelf/ESP32-Radio Cc: Rainer-G; Comment Betreff: Re: [Edzelf/ESP32-Radio] Rotary encoder question. (#192)

Rainer, the interrupts did not come from the rotary encoder pins but from the pushbutton pin. I solderred a capacitor to GND on this pin and all works fine now. But the rotary is still dead. Wim — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

paysan18 commented 5 years ago

Rainer, I have no display attached. But the messages came in the serial debug trace without I touched anything. But like I told you, just from the switch. The rotary is still dead. During the bootup trace I see the line Rotary encoder enabled. I solderred 3 x 0.1 capacitors on the sw, dt and clock pins of the rotary to gnd. The wires are very short. About 3 cm.

Rainer-G commented 5 years ago

Hello Wim,

the trace show a single click even on very short clicks, that’s you can see random interrupts without any action. Rotary counts are only shown at stable situations ( debouncing, look at the interrupt routine ) so spurious interrupts may not be seen.

Just for a test, try

  dbgprint( "Timer %5d ", enc_inactivity  ) ;  in chk_enc, this works without display using the serial monitor.

If the counter goes above 40, there are definitely no interrupts on data and clock! Or, if not done so far, add capacitors similar to the enc sw!

Cheers, Rainer

Gesendet von Mail für Windows 10

Von: Willem Nijntjes Gesendet: Freitag, 30. November 2018 13:54 An: Edzelf/ESP32-Radio Cc: Rainer-G; Comment Betreff: Re: [Edzelf/ESP32-Radio] Rotary encoder question. (#192)

Rainer, I have no display attached. But the messages came in the serial debug trace without I touched anything. But like I told you, just from the switch. The rotary is still dead. During the bootup trace I see the line Rotary encoder enabled. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

paysan18 commented 5 years ago

screenshot from 2018-11-30 16-03-30 Rainer, I placed the line just after the curly bracket "{" in the chk_enc. Now when I watch the debug output I see the counter increasing. When I turn the knob the counter resets and starts from zero. This means at least that the rotary is working. But is your line at the right place? An other possible problem is the type of rotary encoder. There are a few different types. The type I use gives open circuit at the detents. The code of rotation comes out in between the dentent positions.

Rainer-G commented 5 years ago

Hi Wim,

the place is ok! It also can be somewhere in the main loop, it only needs to processed each loop.

If the counter goes above 40 without any activity, it looks ok. It should go to zero only when you turn the knob or press the button. But if you still do not see any rotationcount in the trace and the encoder works in a different program I cannot see a reason for this. In the trace you sent Nov. 27th, there were numerous -1 in a row, is this sill the case ?

Rainer

Gesendet von Mail für Windows 10

Von: Willem Nijntjes Gesendet: Freitag, 30. November 2018 16:11 An: Edzelf/ESP32-Radio Cc: Rainer-G; Comment Betreff: Re: [Edzelf/ESP32-Radio] Rotary encoder question. (#192)

Rainer, I placed the line just after the curly bracket "{" in the chk_enc. Now when I watch the debug output I see the counter increasing. When I turn the knob the counter resets and starts from zero. This means at least that the rotary is working. But is your line at the right place? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

paysan18 commented 5 years ago

It’s strange that the counter reacts to the rotation of the encoder but the program does not. Indication in the trace file and no in or decrease of the volume.

When the button is pressed 3 times the system hangs because the SD card will be opened. This does not work. The only way to get out of this is a reboot.

Groeten, Wim

Op 30 nov. 2018 om 16:35 heeft Rainer-G notifications@github.com het volgende geschreven:

Hi Wim,

the place is ok! It also can be somewhere in the main loop, it only needs to processed each loop.

If the counter goes above 40 without any activity, it looks ok. It should go to zero only when you turn the knob or press the button. But if you still do not see any rotationcount in the trace and the encoder works in a different program I cannot see a reason for this. In the trace you sent Nov. 27th, there were numerous -1 in a row, is this sill the case ?

Rainer

Gesendet von Mail für Windows 10

Von: Willem Nijntjes Gesendet: Freitag, 30. November 2018 16:11 An: Edzelf/ESP32-Radio Cc: Rainer-G; Comment Betreff: Re: [Edzelf/ESP32-Radio] Rotary encoder question. (#192)

Rainer, I placed the line just after the curly bracket "{" in the chk_enc. Now when I watch the debug output I see the counter increasing. When I turn the knob the counter resets and starts from zero. This means at least that the rotary is working. But is your line at the right place? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

paysan18 commented 5 years ago

Problem with the rotary has been solved. Cause was a bad solder joint. Sorry guys, I’m getting old. My eyes are no longer as what they were.... Thanks Rainer.....

Groeten, Wim

Op 30 nov. 2018 om 16:35 heeft Rainer-G notifications@github.com het volgende geschreven:

Hi Wim,

the place is ok! It also can be somewhere in the main loop, it only needs to processed each loop.

If the counter goes above 40 without any activity, it looks ok. It should go to zero only when you turn the knob or press the button. But if you still do not see any rotationcount in the trace and the encoder works in a different program I cannot see a reason for this. In the trace you sent Nov. 27th, there were numerous -1 in a row, is this sill the case ?

Rainer

Gesendet von Mail für Windows 10

Von: Willem Nijntjes Gesendet: Freitag, 30. November 2018 16:11 An: Edzelf/ESP32-Radio Cc: Rainer-G; Comment Betreff: Re: [Edzelf/ESP32-Radio] Rotary encoder question. (#192)

Rainer, I placed the line just after the curly bracket "{" in the chk_enc. Now when I watch the debug output I see the counter increasing. When I turn the knob the counter resets and starts from zero. This means at least that the rotary is working. But is your line at the right place? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Edzelf commented 5 years ago

Maybe you should use Rainer's PCB....

paysan18 commented 5 years ago

Yes, good idea!

Groeten, Wim

Op 30 nov. 2018 om 22:47 heeft Ed Smallenburg notifications@github.com het volgende geschreven:

Maybe you should use Rainer's PCB....

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

paysan18 commented 5 years ago

Rainer, can I see a picture of your print for this radio please?

Rainer-G commented 5 years ago

Here it is, Wim!

It uses different boards, I selected these for my tests as they were breadboard friendly!

Rainer

Gesendet von Mail für Windows 10

Von: Willem Nijntjes Gesendet: Freitag, 30. November 2018 23:38 An: Edzelf/ESP32-Radio Cc: Rainer-G; Comment Betreff: Re: [Edzelf/ESP32-Radio] Rotary encoder question. (#192)

Rainer, can I see a picture of your print for this radio please? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Rainer-G commented 5 years ago

Here is a picture of the PCB

Gesendet von Mail für Windows 10

Von: Willem Nijntjes Gesendet: Freitag, 30. November 2018 23:38 An: Edzelf/ESP32-Radio Cc: Rainer-G; Comment Betreff: Re: [Edzelf/ESP32-Radio] Rotary encoder question. (#192)

Rainer, can I see a picture of your print for this radio please? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

paysan18 commented 5 years ago

Problem found and case can be closed.

Problem was a solder bridge between the clk pin and ground of the rotary encoder. Found it by looking at the bootup debug trace. GPIO-25 was LOW and remark was possible no pullup.

paysan18 commented 5 years ago

Here is a picture of the PCB Gesendet von Mail für Windows 10 Von: Willem Nijntjes Gesendet: Freitag, 30. November 2018 23:38 An: Edzelf/ESP32-Radio Cc: Rainer-G; Comment Betreff: Re: [Edzelf/ESP32-Radio] Rotary encoder question. (#192) Rainer, can I see a picture of your print for this radio please? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Rainer, I don't buy your PCB. I have a different type of ESP32 and VS1053.

paysan18 commented 5 years ago

Here is a picture of the PCB Gesendet von Mail für Windows 10 Von: Willem Nijntjes Gesendet: Freitag, 30. November 2018 23:38 An: Edzelf/ESP32-Radio Cc: Rainer-G; Comment Betreff: Re: [Edzelf/ESP32-Radio] Rotary encoder question. (#192) Rainer, can I see a picture of your print for this radio please? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

I don’t see any picture. Is this the same pcb as sold by Naked Ninja in Roterdam?

paysan18 commented 5 years ago

Rainer, can I see a picture of your print for this radio please?

Is this the pcb as mentioned in issue #181 ?