[comp.sys.amiga.tech] Amiga Mouse info needed

rlcarr@athena.mit.edu (Rich Carreiro) (11/04/88)

Hello,

I am currently enrolled in a digital design class.  My lab partner and
I are going to attempt to build a life machine.  As an input device, we would
like to use an Amiga mouse (since I happen to have an extra one).  Among
other things, we are going to have to build some hardware to read the mouse.
Can someone mail me info on:

(a) The MOUSE (i.e. NOT the connector on the side of the computer) pinouts

(b) Explain the output format, i.e. in what form are the horiz and vertical
    signals, and what the h*** is horiz and vertical quadrature?

(c) If anyone has ever built a mouse interface like this before, tips
    and pointers would be welcome.

I (and my partner) will be eternally grateful for any information we get
(after all, you wouldn't want us to use a Mac mouse 8-)

ARPA:    rlcarr@athena.mit.edu
UUCP:    {wherever}!mit-eddie!mit-athena!rlcarr
BITNET:  rlcarr%athena.mit.edu@MITVMA.mit.edu

*******************************************************************************
* Rich Carreiro                 "MIT isn't Hell.  It's where you go when      *
* rlcarr@athena.mit.edu          you've been bad in Hell." - Anon.            *
*******************************************************************************

brianm@sco.COM (Brian Moffet) (11/08/88)

In article <7804@bloom-beacon.MIT.EDU> rlcarr@athena.mit.edu (Rich Carreiro) writes:
>I (and my partner) will be eternally grateful for any information we get
>(after all, you wouldn't want us to use a Mac mouse 8-)
>

Actually, a little while ago, I took my amiga mouse apart and
went at it with some simple electronics equipment.  I guess
that is what you get when you get board of programing :-)

Anyway, I found that the amiga mouse is what is called an
opto-mechanical mouse.  What this means is that when you move
the mouse, it will rotate 2 wheels inside the mouse.  The wheels
have an *odd* number of holes in them.  These holes allow
a small light to shine on a photo-diode and generate a voltage,
+5 I believe, to either the "normal" or "quadrature" pin.

How this works is:   The "normal" pin is volted high, and the
when you continue to move the mouse, the "normal" is dragged low
and the "quadrature" is dragged high.  the electronics in the
machine can now tell which direction the mouse is moving.
for example (I think this is in the positive direction, I am
not at my machine with my notes)

	      _________	     _________      _________
quad	______|       |______|       |______|       |

	_______        _______      _________
normal	|     |________|     |______|       |______

This applies for the vertical and horizontal.  Also, the
amiga mouse will send 2 of 3 mouse buttons  1 & 3.
It does not send a signal for the middle button.

I posted this because I thought more than 1 person might
be interested.   As soon as I get married (* in january *)
perhaps I'll make a public domain track-ball.  That was why
I did this in the first place.

Oh, yes, I have been called a hacker. :-)

brian

-- 
Brian Moffet			{uunet,decvax!microsoft,ucscc}!sco!brianm
 -or-				...sco!alar!brian
"Evil Geniuses for a better tomoorow!"  My fish and company have policies.
					I have opinions.

sgt@dukeac.UUCP (Stephen G. Tell) (11/09/88)

I build somthing to deal with mouse signals once, and I think I remember
it enough to explain how it works.

I don't have a manual handy, so I don't know the pinouts, but if you
have the simple introductory manual, its good enough with a bit of
explaining:
Power & ground are obvious
The amiga supports 3-button mice on the 9-pin plug, The mouse that
comes with it uses button 1 and 3 inputs, (I think)
I've actually got a 3-button mouse on my machine, but haven't fooled around
with software to use the new middle button.

The horizontal (vertical) quadrature pins tell you speed and direction
for the two axes.  I'll speak in terms of horizontal, vertical is
the same.

The two horizontal signals are basicly the same signal; reversing them
changes the apparent left/right direction.  I forget what the manual's
pinout calls them exactly, but it leads you to believe that they
are somehow fundamentaly different.

If you have a dual-trace scope, hook power to the mouse and look at the
two horizontal quadrature signals as you move back and forth, then the
following should become clear:

Either signal alone gives you speed information as a certain number
of pulses per unit distance the mouse is moved.
The relative phase of the two signals tells you what direction
you're moving.

If we call the two signals A and B, they might look like this for
leftward movement:

   ____       _____       _____
A      |_____|     |_____|     |_____
  __       _____       _____       __
B   |_____|     |_____|     |_____|

And like this for rightward movement:
  __       _____       _____
A   |_____|     |_____|     |_____
  _____       _____       _____       __
B      |_____|     |_____|     |_____|

At any transition of any line, look at the other line to tell you
what direction you're going as follows:

	A		B		moving
	rising		high		left
	rising		low		right
	falling		high		right
	falling		low		left

	high		rising		right
	low		rising		left
	high		falling		left
	low		falling		right

How to do this in hardware:
One way that I've seen it done is to generate a short pulse
with a one-shot on both transitions of both lines (4 one shots,
give short high pulses on each of A rising, A falling, B rising, B falling)
and then AND these each of these with the correct one of
A, inverted-A, B or inverted-B as in the table.

Then, Or together each of these 4 pulses for left and 4 for right
and feed that to a counter.

The pulses from the 1-shots have to be shorter than the pulse rate from
the highest rate of movement you expect from the mouse.

There are other ways to do the hardware; someone want to tell us
how the Amiga does it?
-- 
Steve Tell  Student, Duke University; Employee, Duke Tel-Com (summer only)
Former Chief Engineer, Cable 13 / Duke Union Community Television.
sgt@dukeac.ac.duke.edu;  {ihnp4, ulysses, et. al.}!mcnc!ecsgate!dukeac!sgt

m81_claes@tekn01.chalmers.se (11/09/88)

brianm@sco.COM (Brian Moffet) writes about the Amiga mouse.
>                _________      _________      _________
>quad      ______|       |______|       |______|       |
>
>          _______        _______      _________
>normal    |     |________|     |______|       |______

I say this is the way it is.
              _______       _______       ________
quad    ______|     |_______|     |_______|      |

           _______       _______       _______
normal  ___|     |_______|     |_______|     |______

This way you *CAN* tell which direction you move the mouse!

                     Claes Walther
                     CLWA@Gamma.Me.Chalmers.Se
                     Chalmers University of Technology
                     G|teborg Sweden

***** We don't do disclaimers in Sweden, we only spell wrong *****

gmg@hcx.uucp (Greg M. Garner) (11/10/88)

I sent this Email to the person asking, but it seems that more than one
person is interested in how to do this, so here is my two bits on the 
mouse.

Note that these are the pinouts of the amiga and the mouse, as they 
have the same numbering scheme on the male and female connectors.

pin #       NAME              function

1           FORWARD*          Quadrature output back-forward  

2    	    BACK*             Quadrature output forward-back

3     	    LEFT*             Quadrature output left-right

4	    RIGHT* 	      Quadrature output right-left

5	    No connection

6	    FIRE0*	      left mouse button.

7           +5      	      +5 power into the mouse. 

8           GND  	      Ground into the mouse.           

9 	    POT0Y 	      right mouse button.





Quadrature outputs look like this: (See page E-14 of hardware man v1.1)

 LEFT*  ___     ___     ___     ___     ___     ___
           \___/   \___/   \___/   \___/   \___/
          ___     ___     ___     ___     ___     ___
RIGHT*  _/   \___/   \___/   \___/   \___/   \___/
 
As you can see, these are out of phase 90 degrees. The phase angle 
will change from +90 degrees to -90 degress when then direction
the mouse is moving changes from left to right. A neat little
circuit to take advantage of this fact is as follows:

			
		 _________     Q0 out		    _________
		|	  |    |     _______       |	     |	
LEFT* ----------| D     Q |----|   \ \      \	   |	   Q |--- Q1 out
		|         |    |----| |	     \_____|	     |
		|	  |	|---| |      /	   | D 	     |
		|      Q* |	|  / /______/	   |	     |
		|_________|     |		   |_________|
 				|
			      RIGHT*

These are edge triggered d flip flops. This circuit acts like a counter
which will keep track of the position of the mouse at all times. This
particular circuit is only able to count up to 3, then it rolls over to 
0 again, (outputs at Q0 and Q1), but it will count up when the mouse
is rolling left, and count down when it is rolling right (I may have 
these reversed). If you want to add more resolution, just repeat the part
of the circuit on the right, extending it out to as many bits as 
you might need. You may also be able to use a binary counter that has 
a up/down input (like the 74ls193 I think), and implement the circuit
in fewer gates.  Just repeat this same circuit for the forward/back
part of the mouse, and presto chango, you have a mouse driven 
position sensing device.  

   Adding a little clarity here, the RIGHT* input to the above
circuit is just a up/down select. When it is hi, the circuit counts
down, and when it is lo, the circuit counts up (may be backwards).
It works because the quadrature output RIGHT* will always be hi
on the falling edge of the LEFT* input, causing the EOR gate 
to flip the Q1 output to Q1*, which makes the counter count down.
If the thing reverses direction, the RIGHT* input will now always
be lo on the falling edge of LEFT*, causing the EOR to do nothing
to the output pulse Q1, therefore makeing the counter count up.   

 The two mouse buttons are just normally open switches that are 
shorted to ground when the button is pushed. These do not have 
internal pullup resistors, so you need to supply some. 
A good value I like to use is 1K to +5. The switches will then
supply you with +5 when open, and ground when closed.

Finally, make sure you use a good +5 supply for the mouse, as it 
has 4 comparators internally that generate the quadrature pulses
from the led/photosensor pairs.  I can't think of anything else
that might help you, but if you have more questions you think
I might be able to answer, mail me or call and ask! Drop me
some Email and let me know what your project is about and how
well the mouse works for you. Good luck!

   Greg Garner
   gmg@hcx.uucp   path:  ...!uunet!harris.cis.ksu.edu!hcx!gmg
   501-442-4847

ditto@cbmvax.UUCP (Michael "Ford" Ditto) (11/10/88)

In article <1093@dukeac.UUCP> sgt@dukeac.ac.duke.edu (Stephen G. Tell)
writes [ a decent description of how mouse quadrature works ]:
>At any transition of any line, look at the other line to tell you
>what direction you're going as follows:

... but then describes a really icky way of interpreting these signals
in hardware ...

>How to do this in hardware:
>One way that I've seen it done is to generate a short pulse
>with a one-shot on both transitions of both lines (4 one shots,
 [ ... and lots of other awful stuff ... ]

There is a very simple way:  Use one signal as an edge-triggered clock
for an up/down counter, and the other signal is simply the counter's
direction input.  I'm pretty sure that's the way the Amiga does it.

It doesn't matter which signal is which, or whether you count rising
or falling edges, or whether the direction is UP/DOWN* or DOWN/UP*;
changing any of these will simply reverse the counting direction.
-- 
					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ford@kenobi.cts.com
- The Unix Programmer's Manual,		...!sdcsvax!crash!elgar!ford
  2nd Edition, June, 1972.		ditto@cbmvax.commodore.com