Something in the area of gpio_a.16 and another with gpio_b.17 This needs a few days to find a braincell that’s a bit more digitally minded then the others
It looks like this should now be all the info i need… and now i need to look how to enter the correct commands to set these values. That’s for tomorrow…
I need <id>,<steps>,<axis>,<gpioa>,<gpiob>,<inverted>
Hey Frietpan first greetings to the netherlands from germany near the border !
You could take a look here: Build Your Own Wifi Radio : 14 Steps (with Pictures) - Instructables this guy is using a openwrt router to make a webradio,using a rotary encoder with a microcontroller. i think it could be done by adding a arduino nano or something else into the router this should be a solution for your problem
Greetings Rene! Are you in the Aachen area perhaps? (near the Dutch mountains)
Thats a nice project! However, it uses an ‘expensive’ atmel to do the GPIO stuff. It looks less complicated then the route I took. Once this encoder stuff is figured out it should make things more easy. By connecting the encoder directly to the SoC there is no more need to use an extra chip do add a basic selector switch / control knob.
I want to use it as a volume knob / light dimmer and also as a OpenWrt config selector. … yeah too many ideas…
The most practical use would be a config selector for a travel router. By making additional config folders ie /config1, /config, /config3, etc. When you turn the knob then another folder is used. This way you could store an endless number of configurations… Just by connecting a rotary to the GPIO’s But I’m not there yet… Getting close though. I’m now at the point where i have to figure out what kmod-rotary-gpio-custom wants to know exactly.
I have tried a few things but since i’m not comfortable with it yet i hope i don’t mess up anything.
Yes i understand, but i´m not sure if the soc can handle the timings of the LOW/High´s from the encoder… sadly my rotary encoder is on its way from china to germany, will test in about three weeks xD
i´m located Near Borken (near in the Netherlands Winterswijk)
I also had my doubts, but afterall there is kmod-input-gpio-encoder and kmod-rotary-gpio-custom these drivers seem specifically made for using encoders on GPIO pins. A little bit hard to understand how they work, but it’s all there and they seem to exist for quiet some time for linux. And the AR9331 SoC seems to be modern enough. It would be great if someone with more knowledge would jump in and tell us the secrets but it looks like we are the pioneering pirates. HAR HAR!
Now i also have to build a Radio. Then I can tune in to one of the streams from Culturserver.de
Borken That’s not too far from here. It’s a little up north from Airport Weeze right?
Compiling OpenWrt, i’m not at ease with it all. …Fear of making bricks…
I have read the OpenWrt wiki and on the GLi blog there is also a tutorial, the configuration procedure doesn’t look too difficult, but still it feels like there is a potential to make mistakes that can make bricks. Now if it is possible to flash images from USB then I would give it a try. How do you know that your self compiled image is safe to flash? Do you like to gamble, or do you have tools to repair bricks?
@Rene I hope you discovered a few new clues. I have been trying to read up on this but it’s hard to find the right info, and even harder to understand it. (i’m still missing a few basic skills here)
I’m now going to play with Arduino and encoders to see if that can give more insight, though i doubt it will since Arduino is a bit different on this. Still i’m sure i’m going to learn something usefull.
In Arduino the Encoder stuff is pretty straightforward. It’s a bit frustrating that I don’t see how this stuff has to be configured in OpenWrt. Wouldn’t it be nice if there would be a virtual duino-ish section in OpenWrt (WrDuino?? ) A section that allows you to control the GPIO’s by using the arduino IDE.
Jeroen pointed me to your questions in the GPIO thread, i’ll post my answer here to keep the encoder stuff in this thread.
The encoder i used is a quadrature encoder, most common available are made by keyes or xinda but there are many more. these encoders have 2 10k resistios Some also have a 10k pullup for the SW pin (pushbutton function when you press the encoder shaft)
First of all i’m glad to hear that you know a bit more about the kernel stuff i hope you can explain a bit (or all) that has to be checked and set. On the openWrt forum i could not find much on the topic, and even less in the wiki. I hope i can collect enough info to make a basic but useful wiki article on this.
Alzhao has compiled the kernel for us and so this should now be enabled in the kernel though its not yet clear to me how to make this work. it seems we should be able to configure the GPIO with a script that tells the software what pins to use. But i still can’t figure out how.
Meanwhile i have played a bit with arduino and encoders and there it’s not too hard to make it work, however Arduino is a different animal in this regard.
this is the most common rotary encoder so it should not be too hard to find. (in what part of the world do you live?)
Thanks for the update. I ordered some rotary encoders, but I got a bit excited and ordered them naked (no breakout board or Resistors). This is not a problem, I can make my own PCB for them.
So, from rerading the source file for the gpio kernel module, when you modprobe/insmod the module you need to specify the parameters for the bus you are using.
Are the number of params supplied < 5? If so, don't continue
(Ooh, my rotary encoders just arrived as I'm typing!)
param 0 - device id (int) (remember we zero index in code)
param 1 - step count (int)
param 2 - axis (int)
param 3 - gpio_a (int)
param 4 - gpio_b (int)
param 5 - If 1 invert a AND b, else, NOT invert a AND b.
As far as I can see, it should be along the lines of;
insmod rotary-gpio-custom bus0=0,20,?,(gpio a number), (gpio b number),0
I need to dig deeper in the code to find what the values for axis should be, but the module hardcodes "relative axis" to false so perhaps experiment with values of 0,1,2 etc.
I don’t yet have my router to test this myself, bus once this has loaded, you should have a bus device for it that you can cat the value of in a loop while you turn the knob.
Also, as far as I can see, the kernel module does not manage the press switch, you must handle that seperately with a GPIO.
I see we where looking in the right direction, though i still don’t fully understand it.
I’m trying the insmod command but not much luck with it yet. So now I start to wonder if the rotary_encoder.h is correctly compiled into the kernel for the AR150
insmod rotary-gpio-custom bus0=0,20,0,16,17,0
ID 0
20 steps
axis 0 (also tried x)
GPIO 16 and 17
not inverted
I will try with the clean CC firmware tomorrow and see how that turns out.
Looks like i really need to spend some time to learn to compile my own, but currentley I have a few other distractions that hold me back.
But if that insmod command is all it takes that’s really nice.