probonopd / MiniDexed

Dexed FM synthesizer similar to 8x DX7 (TX816/TX802) running on a bare metal Raspberry Pi (without a Linux kernel or operating system)
https://github.com/probonopd/MiniDexed/wiki
1.06k stars 76 forks source link

Optimize rotary encoder movement #89

Open probonopd opened 2 years ago

probonopd commented 2 years ago

Currently, If two clicks are needed for a single movement. mt32-pi.cfg has this information:

# Set the rotary encoder type (if used by control scheme).
#
# Different rotary encoders may complete different fractions of a Gray-code
# cycle per detent ("click").
#
# If four clicks are needed for a single movement, try "quarter".
# If two clicks are needed for a single movement, try "half".
#
# Values: quarter, half, full*
encoder_type = full

Code is here.

Next step: Try mt32-pi.cfg with my rotary encoder.

rsta2 commented 2 years ago

The original code is here. I think it is easier to understand. It needs to sample the inputs from the rotary encoder with 1 KHz. mt32-pi uses its own CPU core for the UI and this purpose. We cannot do this, because we need all secondary cores for the audio processing. I could install an 1 KHz user timer on core 0, but with bad luck its IRQs will not be handled quick enough, because an other IRQ handler is running at this time already.

First I will try to extend the Circle KY-040 driver for the "quarter", "half" and "full" cases. If this does not work, I will try the user timer.

rsta2 commented 2 years ago

@probonopd Extending the Circle KY-040 driver did probably not work. Unfortunately I also do only have one KY-040 and I even do not know, if it is "quarter", "half" or "full". I did think about this some time now. Because I already implemented one rotary encoder driver for MiniDexed and Circle, I won't do again.

You will find other developers for sure, which are ready to do this. I'm afraid I have to draw back from your project in one month, to be able to concentrate on my own projects again. This all costs a lot of time.

probonopd commented 2 years ago

I'm afraid I have to draw back from your project in one month, to be able to concentrate on my own projects again. This all costs a lot of time.

@rsta2 that's sad to hear but completely understandable. You have been doing pure magic both with Circle and with this project. Who would have thought the project would land on the frontpage of Hackaday? All the credit goes to you and to the other giants which this project stands on the shoulders of. You can't be thanked enough :1st_place_medal:

I hope this project has been fun for you, and maybe it also helps a bit to make Circle more known.

rsta2 commented 2 years ago

Thanks for your understanding! Yes, it was fun. Unfortunately I'm not musician enough to enjoy all the coming features of MiniDexed enough, to continuously work on this project. The (shrunken) TX816, that I have now, is already great enough for me. ;)

Giandj commented 1 year ago

Hi this Minidexed project is very impressive and very beautiful to me. A question: Is it normal that my rotary encoder miss some pulse ? If I turn clockwise voice change sometimes very well , sometimes I have to rotate again and again to switch from voice1 to voice2 ...3..4...until 32 Instead if i turn it anticlockwise is much reactive voice from 32...4...3...2...1 chance are more sensitive on anticlockwise turns of rotary encoder why ? The rotary encoder seems to miss some rotation.. what kind of test can I do to encrease encoder sensitivity on pi3b+ ?

craigyjp commented 1 year ago

Have you installed the 10nf caps on the data pins of the encoder to ground?

It helped with the rotation on both my builds.

On Fri, 17 Feb 2023, 13:38 Giandj, @.***> wrote:

Is it normal that my rotary encoder miss some pulse ? If I turn clockwise voice change sometimes very well , sometimes I have to rotate again and again to switch from voice1 to voice2 ...3..4...until 32 Instead if i turn it anticlockwise is much reactive voice from 32...4...3...2...1 chance are more sensitive on anticlockwise turns of rotary encoder why ? The rotary encoder seems to miss some rotation.. what kind of test can I do to encrease encoder sensitivity on pi3b+ ?

— Reply to this email directly, view it on GitHub https://github.com/probonopd/MiniDexed/issues/89#issuecomment-1434518668, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMFJTAIXL5ZJE2ZPCMMWMOTWX5PJTANCNFSM5TP3IVZQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Banana71 commented 1 year ago

Hi,

So far, every rotary encoder KY-040 I have installed has been given 10nf capacitors

322

Wiki - Hardware - Rotary Encouder

Giandj commented 1 year ago

no i haven't installer any additional capacitor because on wiring schema there is no capacitor...so I have to add 1 ? of 10 Nanofarad ?

Banana71 commented 1 year ago

You need two 10nF capacitor. One between CLK to GND And one between DT to GND

Giandj commented 1 year ago

One between CLK to GND And one between DT to GND

Can you give me a schema ? in my case my rotary encoder is wired on rapsberry pi3b+ , This is the schema i followed... https://drive.google.com/file/d/1ol9fCtepMS7_lNUFYss7EbOfytvl94Uj/view

Banana71 commented 1 year ago

KY-040 from the back with two capaciators CLK to GND and DT to GND. KY-040 Kondensatoren small

KY-040 small

You have a pretty old version there If I were you, I would download the current version here and read the wiki. If you have further questions, it is best to open a new discussion.

Giandj commented 1 year ago

I will try whit 2 capacitors thank you..

Giandj commented 1 year ago

KY-040 from the back with two capaciators CLK to GND and DT to GND. KY-040 Kondensatoren small

KY-040 small

You have a pretty old version there If I were you, I would download the current version here and read the wiki. If you have further questions, it is best to open a new discussion.

Hi I have installed 2 capacitors of 10 Nano Farad and now the rotation of KY-40 encoder is better but not perfect... some rotation are also missing ... Another question: why you said I have a pretty "old version" of Minidexed? I have the latest version installed but rotary ky-40 encoder still miss some rotations (with 2 capacitors correctly installed like in your precedent schema ... Can I try to modify the code in mt32-pi.cfg file to try if "full", "half" or "quarter" can adjust better the missing rotations , have you tried ?

Banana71 commented 1 year ago

This is the schema i followed... https://drive.google.com/file/d/1ol9fCtepMS7_lNUFYss7EbOfytvl94Uj/view

Another question: why you said I have a pretty "old version" of Minidexed?

In your TX816Pi2.zip file there is a version from 06/05/2022 and I probably drew the wrong conclusions.

I have installed 2 capacitors of 10 Nano Farad and now the rotation of KY-40 encoder is better but not perfect... some rotation are also missing ...

I've built a few miniDexeds and have always had success with the capacitors. Is your KY-040 ok?

Can I try to modify the code in mt32-pi.cfg file to try if "full", "half" or "quarter" can adjust better the missing rotations , have you tried ?

I have no experience there. The file "mt32-pi.cfg" is unknown to me.

Giandj commented 1 year ago

This is the schema i followed... https://drive.google.com/file/d/1ol9fCtepMS7_lNUFYss7EbOfytvl94Uj/view

Another question: why you said I have a pretty "old version" of Minidexed?

In your TX816Pi2.zip file there is a version from 06/05/2022 and I probably drew the wrong conclusions. yes because after downloading it I have made an upgrade..

I have installed 2 capacitors of 10 Nano Farad and now the rotation of KY-40 encoder is better but not perfect... some rotation are also missing ...

I've built a few miniDexeds and have always had success with the capacitors. Is your KY-040 ok?

My Encoder is ok, I have changed 3 encoders with capacitors , but sometimes some rotation are missing...no problem...before 2 capacitors the rotation issue was most frequent...

Can I try to modify the code in mt32-pi.cfg file to try if "full", "half" or "quarter" can adjust better the missing rotations , have you tried ?

I have no experience there. The file "mt32-pi.cfg" is unknown to me.

In another post (issue) somebody wrote that we can modify quadrature calculation in this text file to make encoder rotation much better... So In this file you can change quadrature from full, half, or single.. Quadrature is a quantity of encoder movements to obtain a single move... So in this Minidexed project some .txt or .cfg file specify to the raspberrypi how much movements to do ( if encodet rotation Is clockwise or anticlockwise ).. I Will try to modify quadrature calculation...

Gustavomurta commented 1 year ago

I have not used Ky-40. I built a circuit with another rotary encoder. And it's working perfectly.

Encoder Rotativo miniDexed

image