Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Encoder Switch Questions

Status
Not open for further replies.

Andy1845c

Active Member
Hey guys,

I bought a few of these rotary encoder switches a while ago with intentions to use them for something I never did, and now have ideas of using them with a PIC on another project.
Jameco Electronics Opto & Illumination: BOURNS, INC.: PEC12-4225F-N0024

Problem is, I am having a bit of a rought time trying to figure out how they work, and that makes pondering how to decode the output even harder.

I was expecting them to hold the grey code output, but from what I can tell with my DMM, they just give a pulse as it is rotated, and when at rest, both terminals are open.

Is this correct?

Do they all operate like this?
 
It's bound to be a quadrature switch encoder, I use ones like that a lot. It's two SPST switches that make and break in quadrature pattern, so you can tell CW from CCW.

You hook the common to ground and the switch legs to port pins through pull-up resistors. Read them with an encoder routine, makes a terrific input gadget.
 
Thanks for the reply, Duffy. :)

When the switches "make" should they stay "made" until the shaft is turned more? Mine seem to make if you get them midway between detents and then go back to "break" when the switch is at rest. I guess what I am getting at is that normal? Do I have to constanly be watching the outputs with my PIC to catch these breif changes in the state of the pins?

Am I even making any sense? lol
 
Last edited:
If you look in the data sheet for the encoder listed on the Jameco page you'll see a timing diagram that shows the two outputs versus rotation. For CW rotation output A goes open before output B with a 50% duty-cycle for each output. Conversely, for CCW rotation output B goes open before output A.

The signal polarities they show are for the common terminal grounded and pull-up resistors gong to the outputs.
 
I always poll those encoder inputs (at a high rate, like 1khz or so) but you could also use the "interrupt on change" feature.

Believe me, you won't ever want to go back to using a couple of pushbutton switches to tappity-tap-tap some input variable up or down again.
 
You would get a short pulse if you are measuring between the two output terminals. You need to measure between the outputs and the common terminal.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top