Adding Rotary Encoder to Digital In Expansion

Home :: MIDIfighter Resources and Discussion :: Adding Rotary Encoder to Digital In ExpansionReply
Adding Rotary Encoder to Digital In Expansion
Posted on: 05.04.2011 by Elvira Deshazier
Hey,

As said in the title, I am about to try installing a rotary encoder, two in fact, to the digital ins on my Midi FIghter. I have been doing some research with a buddy of mine and it seems that I am going to have to use 2 of the ports per encoder.

I believe that because I believe the digital in's work in a binary form. They either are in a High state or a Low state. so 0 or 1.

So first off, if that is wrong then I would love to know how these actually do work. If that is how they work, then I guess my next step would be coding. I would attempt to get an encoder with 2 data outs, one for inc and one for dec, that way when one of the ports fires, the code knows it is inc and when the other fires it knows it is dec. I know a decent amount of Java, never worked with C but it can't be too hard...

Any suggestions? Oh ya, I was also hoping to install an encoder with a push function, i.e. I can push in the encoder like a button. I thought that might be able to work from a programming perspective cuz I could fire both ports at one and have that be the other option aside from inc and dec.

I hope I explained this well
Elvira Deshazier
05.04.2011
Hey,

As said in the title, I am about to try installing a rotary encoder, two in fact, to the digital ins on my Midi FIghter. I have been doing some research with a buddy of mine and it seems that I am going to have to use 2 of the ports per encoder.

I believe that because I believe the digital in's work in a binary form. They either are in a High state or a Low state. so 0 or 1.

So first off, if that is wrong then I would love to know how these actually do work. If that is how they work, then I guess my next step would be coding. I would attempt to get an encoder with 2 data outs, one for inc and one for dec, that way when one of the ports fires, the code knows it is inc and when the other fires it knows it is dec. I know a decent amount of Java, never worked with C but it can't be too hard...

Any suggestions? Oh ya, I was also hoping to install an encoder with a push function, i.e. I can push in the encoder like a button. I thought that might be able to work from a programming perspective cuz I could fire both ports at one and have that be the other option aside from inc and dec.

I hope I explained this well
robert chanda
05.04.2011
Yes, the Midifighter is programmed in C, which is the same as the Arduino but without the supporting libraries and environment.
Elvira Deshazier
05.04.2011
ok, so now i'm trying to write some code for the midi fighter board. is the language the same as arduino? that's what I have gathered from other posts but I just wanna be sure.
Elvira Deshazier
06.04.2011
ah, ima fewl. I got it now. thanks fat dude!
robert chanda
06.04.2011
No, two digital inputs per encoder. Look at the diagram, read the link.
Elvira Deshazier
06.04.2011
oh! so if I get you, I only need to use one d-in per encoder? That just like blew my mind and destroyed my design which is awesome!!
robert chanda
06.04.2011
They work using a technique called "quadrature encoding". Essentially two square waves offset by half a cycle:



By watching for rising and falling edges on both the lines you can work out which direction the encoder is turning and by counting the edges-per-second you can work out how fast. Your most difficult task, with a purely software based solution, is to never miss an edge transition. One way to do this is to enable interrupts on the input pins and write an ISR (interrupt service routine) for each pin, or you can just say screw it and brute-force poll the device as fast as you can.

Plenty of tutorials on how it works and how to code for it.


<< Back to MIDIfighter Resources and DiscussionReply

Copyright 2012-2023
DJRANKINGS.ORG n.g.o.
Chuo-ku, Osaka, Japan

Created by Ajaxel CMS

Terms & Privacy