Searching \ for '[PIC]: Mouse encoders' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=encoder
Search entire site for: 'Mouse encoders'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Mouse encoders'
2001\03\06@092433 by Russell Farnhill

flavicon
face
Hi,

Iam building myself a UV light box timer, everything is working fine so far
and now I want to try and use a mouse encoder with a knob on the end so
I can dial in the time to count down from. This is where I need some advice,
looking at a mouse with a scope I find 3 pins on the photo transistor
or whatever it is and 2 pins output a square wave when I spin the encode
wheel.
Iam ok so far, but how do I detect which direction the wheel is spinning? I
thought you get one pulse on both pins for one direction and a pulse only
on one pin and not the other for the opposite direction. This doesn't appear
to be happening, or at least I can't see it and it's quite tricky spinning
by
hand and trying to study the waveforms as I have my scope triggering off one
of the pins so I can see the phase difference between channels a and b.

Oh.. and Iam using a 16f84 to drive the seven seg leds and read the mouse
encoder

Hope that made sense !

I'd appreciate any help

Thanks,

russell.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\03\06@110928 by Attila Muhi

flavicon
face
Hi !

On other optic encoders, it can look like this: one pin is the reference signal. The signal on the other pin is different in phase, if the edge comes before the ref signal, the disc spins in one direction, if the edge comes after the reference signal, the disc spins in the other direction. I think that applies to mouse encoders as well.

73

Attila Muhi - SM4RAN

-----Ursprungligt meddelande-----
Från: Russell Farnhill <.....r.farnhillKILLspamspam@spam@STOR-WAVE.CO.UK>
Till: PICLISTspamKILLspamMITVMA.MIT.EDU <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU>
Datum: den 6 mars 2001 15:26
Ämne: [PIC]: Mouse encoders


{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


2001\03\06@122950 by Christian Dorner

flavicon
face
Hi!

> by
> hand and trying to study the waveforms as I have my scope triggering off
one
> of the pins so I can see the phase difference between channels a and b.

The phase difference between the two cannels is the answer.

Regarding the direcetion of the movement first channel A and THEN channel B
toggle it's level and in the other direction channel B and THEN channel A
toggle it's level.

Sorry for my bad english.

cu, Doc ...

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2001\03\06@130204 by mike

flavicon
face
On Tue, 6 Mar 2001 14:30:34 -0000, you wrote:

>Hi,
>
>Iam building myself a UV light box timer, everything is working fine so far
>and now I want to try and use a mouse encoder with a knob on the end so
>I can dial in the time to count down from. This is where I need some advice,
>looking at a mouse with a scope I find 3 pins on the photo transistor
>or whatever it is and 2 pins output a square wave when I spin the encode
>wheel.
>Iam ok so far, but how do I detect which direction the wheel is spinning? I
>thought you get one pulse on both pins for one direction and a pulse only
>on one pin and not the other for the opposite direction. This doesn't appear
>to be happening, or at least I can't see it and it's quite tricky spinning
>by
>hand and trying to study the waveforms as I have my scope triggering off one
>of the pins so I can see the phase difference between channels a and b.
>
>Oh.. and Iam using a 16f84 to drive the seven seg leds and read the mouse
>encoder
These encoders usually have a roughly 90 degree phase shift between
the 2 outputs.
The simplest way is to wait for (or have an interrupt on) a falling
edge on one of the inputs, and when received, sample the other input.
The state of the second input represents direction, so you either add
or subtract one from the position depending on the state, e.g.
<wait for falling edge on input 1>
movlw -1
btfsc <input 2>
movlw 1
addwf position

There are other ways which give more resolution but you probably won't
need to for your application.
One alternative, which gives the best resolution, is to use a state
lookup table, where on every change(rising or falling) in either input
(e.g. using RB4-7 int on change), you create a 4 bit value consisting
of the new and old states of the 2 inputs, and look up the increment
value (-1, +1 or 0 for illegal states) in a table.  
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2001\03\06@150536 by Olin Lathrop

face picon face
> Iam ok so far, but how do I detect which direction the wheel is spinning?
I
> thought you get one pulse on both pins for one direction and a pulse only
> on one pin and not the other for the opposite direction. This doesn't
appear
> to be happening, or at least I can't see it and it's quite tricky spinning
> by
> hand and trying to study the waveforms as I have my scope triggering off
one
> of the pins so I can see the phase difference between channels a and b.

You usually use two detectors in quadrature (90 degrees out of phase) for
this.  With both signals you can determine direction and number of steps.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, RemoveMEolinTakeThisOuTspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body


2001\03\06@161420 by Drew Vassallo

picon face
>Iam ok so far, but how do I detect which direction the wheel is spinning? I
>thought you get one pulse on both pins for one direction and a pulse only
>on one pin and not the other for the opposite direction. This doesn't
>appear
>to be happening, or at least I can't see it and it's quite tricky spinning
>by

The opto has two light sources/receivers in it.  The slots in the opto wheel
are set up so that one diode is partially occluded while the next slot is
clear as it turns around.  If the "second" diode is uncovered while the
first is being covered, it's turning one direction.  If the opposite
happens, it's turning the other direction.

Try looking at the output of the pins on a storage scope.  Maybe you can see
the difference more clearly.

I would really suggest searching for this on the internet... I found a GREAT
page that showed *exactly* how this works, but since I didn't have a project
for it, I kind of skimmed over it.

Sorry if this doesn't really help; look for that internet page... it's out
there.

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email TakeThisOuTlistservEraseMEspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


2001\03\07@062129 by Russell Farnhill

flavicon
face
Hi,

       Thanks for everyone's help on this, I think I know how to
       read the encoder now. I'll breadboard it and do some
       tests based on the new info and see how I go.

Thanks,

Russell.

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu


2001\03\09@144557 by Rick Mann

flavicon
face
on 3/6/01 6:30 AM, Russell Farnhill at r.farnhillEraseMEspam.....STOR-WAVE.CO.UK wrote:

> Iam ok so far, but how do I detect which direction the wheel is spinning? I
> thought you get one pulse on both pins for one direction and a pulse only
> on one pin and not the other for the opposite direction. This doesn't appear
> to be happening, or at least I can't see it and it's quite tricky spinning
> by
> hand and trying to study the waveforms as I have my scope triggering off one
> of the pins so I can see the phase difference between channels a and b.

What you're doing is called quadrature encoding/decoding, and here is a link
to help explain it:

http://kahuna.sdsu.edu/~kennedy/research/firmware/rotdec/rotdec.html

this page talks about creating a state machine out of ABEL code, but you can
probably apply the principals to PIC firmware.

Let me know what you come up with; I have to do the same thing myself soon.

BTW, let me also suggest Bourns rotary encoders. They're probably much
handier than trying to use a mouse encoder.

http://www.bourns.com/html/encoders.html

I've got a handful of the ECW line, and so far I like them. I think Digi-Key
sells them.

------------------------------------------------------------
Roderick Mann                 EraseMErmannspamlatencyzero.com.sansspam

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...