analog to quadrature converter?

Aug 24, 2005 16 Replies

How difficult would it be to make an analog to quadrature converter, that reads a potentionometer, and detects a change in resistance and based on whether it increased/decreased, sends a pulse (turns on/off two switches) that mimics a mechanical rotary encoder? I am looking for



256 pulses per revolution. The potentionometer would need to be small (about the size of a large guitar pot, the circumference of a quarter) and the circuitry not too bulky (fit inside a small project box), and be powered by 5v, .5ma. It would possibly use a PIC controller.

If possible (without complicating it too much) I would like the potentionometer to be one of those ones that can spin a full 360 deg, so after a full spin, the resistance would go back to 0 (or max resistance if turend the other way), and the converter would need to be smart enough to detect this and compensate so it sends the correct quadrature.



Any ideas?



Is there some reason you do not want to just BUY a rotary encoder with quadrature outputs? I think I have seen some about the size you want.

Jeff.

An easier way to do it would be to just use a rotary encoder and forget the pot. There are lot's of rotary controls out there that behave (mechanically) like pots but produce a quadrature (or absolute) output based on position, rather than a variable resistance. They're plenty cheap -- I think digikey has zillions of these (search for "rotary encoder"). There are both quadrature encounders and encoders that output an absolute position, and there are both optical and mechanical versions.

Is there any reason you have to use a pot?

Otherwise, go to

formatting link
and search for "rotary encoder".

i haven't found a mechanical encoders with the resolution I need (256 pulse per revolution(ppr)), and i didn't know optical encoders came with all the circuitry inside them

- i do not know much electronics. if i can find a 256 ppr encoder that just takes 5v DC that is affordable that will work, but they seem a bit pricey at $50 for a 128 ppr. so the potentionomter was an idea for a workaround

If I can find a 256 ppr optical encoder that just requires 5v and no fancy circuitry and is affordable (the cheaper the better, can you get one for

Pretty easy. You can do that with a PIC or ATtiny with 8 pins. They come with 8 or 10 bit analog inputs and any kind of output. You will have some problems at 360 degrees when the pot goes back to 0, because this is usually not just a tiny jump, but several degrees of dea area without readings. Also, you have to find someone to write the program for you and flash the controller. That will run you *far* over $80 for the encoder.

The QEDS-7148 (HP) rotary encoder has 500 counts/rev and is about the size you want. They are USD $15.00 apiece from C and H sales. Go to:

formatting link
And check their online catalog. I have a couple of these, and they are quite nice.

Thanks - I will check this out. $15 is doable.

I can live with just using existing Atari 2600 paddles, which don't go back to 0. Is it possible to make a 4-in-1 encoder, that generates quadrature for 4 paddles at once? Also I can probably write the program myself, I am a programmer and have done some C. Are the compiler & tools freeware? As far as flashing the controller, how expensive is the equipment? How hard is it to wire the PIC? Can it be made to run off the of 5v .5 mA going through the switches?

I think you'll find that it's cheaper than a POT and a PIC, assuming your time isn't worthless. Remember that you need a programmer for the PIC as well, which isn't free (although it can be done cheaply, or you might already have one).

Also, this unit is optical so it shouldn't wear out any time soon.

One other thing you should understand (and from the tenor and subject of your messages I thought you might not) is that quadrature output is not absolute -- it merely gives you distance and direction of travel. This unit is quadrature output. Hit google for more information on quadrature output (if you need more info).

Hope that helps -- tAfkaks

Not a problem, my game already is coded for quadrature - 2 bits - you simply compare the last value read with the current value and you know what direction the knob was turned.

I checked out the encoder, the only problem is it is 40 mA, and I only have 5 mA to work with (though it matches on 5V).

How difficult / expensive is it to get the compiler and PIC flash tools and do it myself? I am more worried about wiring up the PIC, not knowing electronics. Also are there PICs that run on 5V .5 mA?

The PIC IDE (w/ assembler) from microchip is free. You'll pay for a C or basic compiler, though. If you go avr, you can use the gcc toolchain. In both cases you'll need a programmer -- there are a lot of options, so use Google for details. I'm not aware of a part that runs on .5ma (did you mean 5ma?) -- but again, go to the Atmel or Microchip sites to check the datasheets. Most parts run on 5v.

Is there any reason you're so limited on current draw?

I'm limited by the power supply of the keyboard interface that I'm using to read my inputs (Hagstrom KE72 module, see hagstromelectronics.com). Also they have told me that high counts per revolution might be too fast for the keyboard throughput (limited by the PC). If that's a problem, I would lean toward simply using a simple

8-bit DAC for each paddle but it kills me to have to use 8 inputs for a stupid paddle.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required