How to change button to rotary encoder

Pytania, kody i porady dotyczące nie tylko Bascom.
ODPOWIEDZ
Awatar użytkownika
venter
Posty: 4
Rejestracja: 21 kwie 2022, 20:09

How to change button to rotary encoder

Post autor: venter » 21 kwie 2022, 20:24

Hello,
I am newbie here.
I found this forum, I look there is great content inside this website, beside a forum.
Well, I watch on the website there are a sample for radio tuning with a rotary encoder, so I need help some help to your guys here to solved my problem to change the code from the button to be use a rotary encoder.
Here are my code :
  1.  Do
  2.       'up
  3.       If Pind.6 = 0 Then
  4.          M_sel = 0
  5.          Mem_bit = 0
  6.          If Main_freq < 1080 Then Main_freq = Main_freq + 1
  7.          Call Set_lcd()
  8.          Waitms 180
  9.       End If
  10.       'down
  11.       If Pinb.6 = 0 Then
  12.          M_sel = 0
  13.          Mem_bit = 0
  14.          If Main_freq > 875 Then Main_freq = Main_freq - 1
  15.          Call Set_lcd()
  16.          Waitms 180
  17.       End If
  18.       'enter
  19.       If Pind.7 = 0 Then
  20.          If M_sel = 0 And Mem_bit = 0 Then
  21.             Menu_index = 0
  22.             Call Main()
  23.          Else
  24.             Incr Menu_index
  25.             If Menu_index > 4 Then Menu_index = 0
  26.             Bitwait Pind.7 , Set
  27.             Select Case Menu_index
  28.                Case 0 : Call Main()
  29.                Case 1 : Call Lcd_home()
  30.                Case 2 : Call Memory()
  31.                Case 3 : Call Text()
  32.                Case 4 : Call Svmem()
  33.             End Select
  34.          End If
  35.       End If
  36.    Loop
  37. End Sub
Greeting,
Ven
If you do wrong, and I am sure I will be wrong too, I am newbie here
:? :? :?
Awatar użytkownika
niveasoft
Posty: 1207
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: How to change button to rotary encoder

Post autor: niveasoft » 21 kwie 2022, 20:42

On what uC this is coded? This is important info that is lack here.
Because for now you have buttons coded on two different ports (PIND & PINB) so if this should still work on those pins then some pooling with timer can be used if available/spare. Maybe PCINT can be used? Or maybe those pins are not critical for this design....
So schematic or some more info will be good idea to getting started.
Awatar użytkownika
venter
Posty: 4
Rejestracja: 21 kwie 2022, 20:09

Re: How to change button to rotary encoder

Post autor: venter » 21 kwie 2022, 22:06

Hello Nive,
I use a processor Atmega8.
Yes, there is I used 2 different port, there is PORTD.6 (UP) and PORTB.6(DOWN) and PORTD.7 (Enter).
I used is standard a rotary encoder, here is my schematic used with the buttons.
I am sorry, I am not be able to added the schematic picture here, because I tried it to add but it doesn't work (insert image), I am a newbie, so I am still doesn't know how to do
Obrazek

Greetings,
Ven
If you do wrong, and I am sure I will be wrong too, I am newbie here
:? :? :?
Awatar użytkownika
niveasoft
Posty: 1207
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: How to change button to rotary encoder

Post autor: niveasoft » 21 kwie 2022, 22:20

Images can be added as link into some external hosting for images I think. I dont have time to setup some images gallery here yet.
Picture you can add as attachment (a tab "załaczniki" at the bottom of the posting page).
Do you have any of Timer0, Timer1 or Timer2 free?
Awatar użytkownika
venter
Posty: 4
Rejestracja: 21 kwie 2022, 20:09

Re: How to change button to rotary encoder

Post autor: venter » 26 kwie 2022, 23:04

Hello Nive,
I have sent email to you.
Did you received it ?, please help.

Greeting,
Ven.
If you do wrong, and I am sure I will be wrong too, I am newbie here
:? :? :?
Awatar użytkownika
niveasoft
Posty: 1207
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: How to change button to rotary encoder

Post autor: niveasoft » 27 kwie 2022, 18:53

Yes. I got it. We will continue here but this must little wait cause Im busy.
I hope you don't mind if I include the diagram from your email.
Maybe someone else give you solution quicker.
I read your code and this is only 500 lines only and simple so maybe you should attach it into the topic :D
Makeing it encoder operational instead buttons I recommend use timer poolling method because you have three timers free.
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
Awatar użytkownika
venter
Posty: 4
Rejestracja: 21 kwie 2022, 20:09

Re: How to change button to rotary encoder

Post autor: venter » 29 kwie 2022, 21:14

Hello Nive,
It's okay you can attach my screen shoot picture here.
I hope you can help me to changed that a buttons to a rotary encoder, I am not so hurry for that hobby project, most important thing for me, it will work nicely and good in hardware with a rotary encoder.
Also I want to I ask you Nive, that I tried on a proteus working good, but on actual hardware it doesn't working, mean is the character on lcd is not appears, I am sure that is issue on fuse bit in a configuration when I burning or flashing to the processor, my question is, what is the fuse settings with configuration bit for it processors, could you please give a screen shoot picture to a correct settings, so I will tried to refer that your configuration.

Greetings,
Ven.
If you do wrong, and I am sure I will be wrong too, I am newbie here
:? :? :?
ODPOWIEDZ