*taps fingers together* Goood, goood.
Hey All,
I've had this finished for some time now, and been meaning to post my experience with it.
I had fallen in love with the idea of the ALPS RKJXT Rotary Encoder/Joystick as a solution for input on my CarPC. So, I started looking into it further.
I tried to build a board, that used various hardware means to decode the quadrature signal from the encoder, including the usdigital ls chips but eventually was unsuccessful.
My solution always depended upon a game controller interface called the GPWiz, which turned a low going switch input into an HID signal, and the Girder software to intercept that HID signal, and turn it into something useful for the front-end I was using.
Eventually, I gave up on decoding the Quadrature signal in hardware and built a LUA method to be used in Girder under the HID "OnRead" method, and shorted a couple pins on the board I'd built to hold the decoding chip.
Over all, it works quite well, and I'm happy with it. I haven't actually installed it in a car, since I'm still in the process of designing/building my setup, and haven't actually installed anything yet. However, the device seemed to work well, and felt good, and was VERY compact.
I've included below, the code for Girder, as well as a couple screenshots of the EaglePCB drawings of the two boards I used. I'll get some photos of the whole thing later today, and post those as well.
Code:function HidRead( data ) -- This uses the bitwise shortcut method of decoding a quadrature signal found at; -- http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv8.pdf -- Set some variables we'll use later envTable = _G envTable = getfenv(1) if envTable.prev == nil then envTable.prev = "" end if envTable.prevBits == nil then envTable.prevBits = 0 end local s="" local index=0 local curBits = envTable.prevBits if data then -- Check each byte in the string. This comes in the format XX XX XX XX XX XX for b in string.gfind(data, ".") do -- For the GPWiz 32, the first two bytes are always 77 77. The third byte contains info we're interested in -- namely 01 == Quadrature A and 02 == Quadrature B if index == 2 then curBits = math.band(string.byte(b),3) end -- Concatenate this bit back onto the data string s =s .. string.format("%02X ", string.byte(b)) index = index+1 end end -- Check to see if our current data string is the same as the last, we don't want to do anything if it is. if s ~= envTable.prev then -- Bitshift our current byte one to the right so we can compare previous B with current A shifted = math.bshiftr(curBits,1) result = math.bxor(envTable.prevBits, shifted) -- Now we need to filter our result to only the second bit andResult = math.band(result, 1) if andResult == 0 and curBits ~= envTable.prevBits then gir.TriggerEvent("Quadrature Increased", 18, 0) elseif andResult == 1 and curBits ~= envTable.prevBits then gir.TriggerEvent("Quadrature Decreased", 18, 0) end gir.TriggerEvent(s, 239) end envTable.prevBits = curBits envTable.prev = s end
rkjxt-cad by qwikrex, on Flickr
controller-cad by qwikrex, on Flickr
all-boards by qwikrex, on Flickr
encoder-side by qwikrex, on Flickr
encoder-bottom by qwikrex, on Flickr
Last edited by cherrybomb; 02-15-2011 at 08:09 PM.
'99 Ford Explorer Eddie Bauer
CarPC Progress ~= 97%. Everything is installed, and operational. Still need to tweak and tune, and do some "finish" fabrication.
CarPC Project Web Site
SpaceNavigatorDriver SourceForge Project
Check out my blog.
I should also note that in order for my code above to work, the A and B leads of the encoder need to trigger input 0 and 1 of the GPWiz, otherwise the code would be detecting the wrong inputs.
'99 Ford Explorer Eddie Bauer
CarPC Progress ~= 97%. Everything is installed, and operational. Still need to tweak and tune, and do some "finish" fabrication.
CarPC Project Web Site
SpaceNavigatorDriver SourceForge Project
Check out my blog.
Do you have any of these boards left Ryan, or did you make them yourself?
I do have one of each left, and could have more made.
I don't have the materials to make the boards, but I used a bulk PCB house to make them for a nominal fee. If I had enough people interested, I could have more made.
'99 Ford Explorer Eddie Bauer
CarPC Progress ~= 97%. Everything is installed, and operational. Still need to tweak and tune, and do some "finish" fabrication.
CarPC Project Web Site
SpaceNavigatorDriver SourceForge Project
Check out my blog.
Ryan, PM me how much you want for those boards. What is the purpose of the controller board? Is it just an easier way to interface with the rest of the pins?
that's pretty great, way better than how I hacked up a 10 button mouse
can you use the center push as well as all the directions?
You should be able to, as long as you wire it up to the translator board.
cherrybomb: Did you have to write some scripting to handle the center push as well? I started writing my own code to do what the GPWiz does, and I have that much figured out. I have not used Girder before, but it looks like you can program some of the code in yourself.
Well, I had originally created the controller board to decode the signal from the rotary encoder, and just turn it into pulses for UP or DOWN, but I couldn't quite get the chip to work the way I wanted it to.
The controller board does also route the signals to the pins of the GPWiz that my Girder code expects, and provides a place for as many as 10 other buttons and LED's (always on, not switched) to be attached.
Since the decoder chip is no longer part of the equation, it's just a matter of bridging some pins where it should go.
'99 Ford Explorer Eddie Bauer
CarPC Progress ~= 97%. Everything is installed, and operational. Still need to tweak and tune, and do some "finish" fabrication.
CarPC Project Web Site
SpaceNavigatorDriver SourceForge Project
Check out my blog.
The rotary, center push, and all 8 directions are usable with this hardware and software configuration. The software piece I wrote only decodes the Quadrature signal from the encoder, the rest is much more straight forward in Girder.Originally Posted by LYHTSPD
The center push (button 11 on the GPWiz) is set any time any of the other directions are, so you'll use Girder to "learn" what each direction looks like (I.E. 11 and 3 for up) and then map it to some functionality.
'99 Ford Explorer Eddie Bauer
CarPC Progress ~= 97%. Everything is installed, and operational. Still need to tweak and tune, and do some "finish" fabrication.
CarPC Project Web Site
SpaceNavigatorDriver SourceForge Project
Check out my blog.
Bookmarks