Main > Everything Else |
Online electronics parts store? |
<< < (4/12) > >> |
Howard_Casto:
Digikey seems the cheapest so far. Still 5 bucks for shipping, but it's a whole hell of a lot cheaper than 10 bucks for shipping and adding extra parts doesn't seem to up the shipping price. Anyway, this is the style of encoder I was thinking: https://www.digikey.com/product-detail/en/PEC11R-4315F-S0012/PEC11R-4315F-S0012-ND/4699232/?itemSeq=296805556 There's also a cheaper, plastic style, but I've just got a feeling that the signal is going to bounce a lot on that one. https://www.digikey.com/product-detail/en/EN12-HS11AF25/987-1194-ND/2408772/?itemSeq=296825245 One of the reasons I wanted to use something like this is to reduce the vertical height of the shaft extension..... it'd be nice to be able to fit a converted stick inside a madcatz/hori joystick enclosure. That's a tall order I know, but I'm just thinking there aren't a lot of people that will want this on their main mame cab as the yoke makes fighters hard to play. Anyway, the coding, in theory at least is easy. Read A and B and then wait for the change... if they are both equal then it's a tick clockwise, if they differ then it's a tick counter clockwise. It very well may be that the rotary encoders are too cheap to work on a joystick and that's why the beefier 12 position switches were used, but I'd like to find out. With PL1's excellent wiring suggestion I can do the 12 way as well, it'd just be bigger and take an extra input pin. |
PL1:
--- Quote from: Howard_Casto on June 30, 2019, 12:59:24 am ---Anyway, the coding, in theory at least is easy. Read A and B and then wait for the change... if they are both equal then it's a tick clockwise, if they differ then it's a tick counter clockwise. --- End quote --- Wait, wut? :dizzy: The encoder you linked to outputs quadrature wave forms when rotated. It is the mechanical equivalent of the optical circuits in a spinner/trackball/mouse. For example: Last read was A=1 and B=1, your starting point is Phase 3. Next read - A=1 and B=1, you are still on Phase 3 ==> no change, no movement. - A=0 and B=1, you've changed to Phase 2 ==> one step counter-clockwise - A=1 and B=0, you've changed to Phase 4 ==> one step clockwise One thing that could make coding for these encoders different from a typical spinner is that each of the 12 detents are centered on Phase 3. - Datasheet "Quadrature Output Table" diagram shows a dashed line labeled "D" (detent) running vertically through Phase 3. 12 detents and "12 Pulses per 360 ° Rotation" ==> Turn one click = move 4 phases. You may want to convert each 4-phase clockwise or counter-clockwise transition to a single keystroke output instead of mouse movements for easier setup in MAME. Scott |
Howard_Casto:
Yeah your right. Was reading up last night about how the detents made them behave differently than you would expect and got some bad info from a site. Regardless it's super simple was my point. I probably need to use interrupts for these... might help with any noise as it'd self correct fairly quickly. I don't know though, I'm thinking with only 12 positions a normal loop would do ok... have to wait and see. Thanks for the advice/info guys. |
BadMouth:
--- Quote from: Howard_Casto on June 30, 2019, 12:59:24 am ---Anyway, this is the style of encoder I was thinking: --- End quote --- :lol I've also experimented with that style. The idea with that one was to build everything including the yoke into a PCB. I'm not sure if I ever posted it. IIRC, it was 12 or 16 step. It was from sparkfun, possibly this one: https://www.sparkfun.com/products/9117 It was very inconsistent, possibly due to the super low resolution. Sometimes it would register the turn, sometimes it wouldn't. Giving it a full twist always resulted in less than a full twist. I was using an opti-wiz from groovygamegear as the interface. Not sure if it was the interface or MAME that didn't like the low resolution, but 300+ count encoders worked fine. If you're making a dedicated interface, that may not matter. EDIT: That was back in 2012! http://forum.arcadecontrols.com/index.php/topic,122506.msg1312156.html#msg1312156 It turns out that it worked on Ikari Warriors, but not on other rotary games. So it must have been a MAME issue. I guess that won't be an issue if you are converting the input to key strokes. |
PL1:
--- Quote from: Howard_Casto on June 30, 2019, 03:26:54 pm ---Yeah your right. Was reading up last night about how the detents made them behave differently than you would expect and got some bad info from a site. --- End quote --- Did a little more research and the approach you were talking about earlier looks like it might be a better method. :cheers: With the detent centered at Phase 3, both data lines start high. Instead of monitoring both data lines looking for a change, you only need to monitor line A. When line A goes low, read data line B. - If the knob is turned clockwise, the drop happens going from Phase 4 to Phase 1 so line B will be low. (lines match) - If the knob is turned counter-clockwise, the drop happens going from Phase 3 to Phase 2 so line B will be high. (lines don't match) - Once both data lines are high again (back to Phase 3), resume monitoring line A for the next drop. Here's an example with animation and code. He posted more info and code at https://howtomechatronics.com/tutorials/arduino/rotary-encoder-works-use-arduino/ Scott |
Navigation |
Message Index |
Next page |
Previous page |