Shop OBEX P1 Docs P2 Docs Learn Events
Problem connecting a PS/2 mouse to a Basic Stamp — Parallax Forums

Problem connecting a PS/2 mouse to a Basic Stamp

BobbyJBobbyJ Posts: 22
edited 2004-08-04 13:37 in BASIC Stamp
Standard disclaimer: I am new to Basic Stamps

I am working on a prodject and am trying to connect a PS/2 mouse to a BS2. The reason for using a PS/2 mouse is simply because I have a few extras laying around.·I was planning on using the SHIFTIN and SHIFTOUT commands to handle communications with the mouse.·The commands seemed to be almost perfect for what what I needed to do.

Here's the problem I have. The command reference for SHIFTIN and SHIFTOUT·both state that they·will·generate the clock signal. But, the PS/2 mouse protocol states that the mouse always generates the clock signal. Having both devices generate the clock signal seems like it would be a problem.

So far·the only work around I can think of is·using PULSIN to listen for the clock signal. But the problem I see with this is the command reference states, "PULSIN will wait, for the desired pulse, for up to the maximum pulse width it can measure". For the BS2 that is 131.07 ms. There is a really good chance that the mouse·will sit idle for peirods much·longer than that. I am pretty much all "googled-out" looking up info on the PS/2 protocol, and do not know for sure if the mouse·sends any data when it is idle. I am assuming it does not, which means that PULSIN will do a lot of "timing out" waiting to the clock signal to start.


Anybody have a solution for this?

Comments

  • K de JongK de Jong Posts: 154
    edited 2004-08-04 00:00
    Why don't you take an esier problem to solve with the Stam first to get acquainted a bit.

    All these newbies with their fantastic ideas.................

    Klaus
  • DonDon Posts: 34
    edited 2004-08-04 00:40
    As another poster opined, this is a somewhat advanced project.· However, if you're determined to tackle it you might consider hooking the mouse up to a shift register which is clocked by the mouse-generated clock.· Something like the 74LS164, comes to mind.· You'll also probably need a few flip-flops or a counter to detect when enough bits have been shifted in.· Then, the Stamp can either read the shift register data directly or shift it in using another shift register (e.g. 74LS165 or '166).

    If you ignore the parity bit, you'll only need an 8-bit shift register.· You will need some additional logic to recognize the start and stop bits.
    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2004-08-04 01:37
    I'm not sure of the exact part, but I believe Al Williams has a chip for reading PS/2 Keyboards & Mice.· Maybe you should check out his site...In fact, here is a direct link to the chip I was thinking of...

    http://www.al-williams.com/pak11.htm





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Knight Designs
    324 West Main Street
    P.O. Box 97
    Montour Falls, NY 14865
    (607) 535-6777

    Business Page:·· http://www.knightdesigns.com
    Personal Page:··· http://www.lightlink.com/dream/chris
    ·
  • ionion Posts: 101
    edited 2004-08-04 02:12
    Al Williams has a pak VIa which can interface with a mouse or keyboard. I am using it for a KB interface and works great.Save me hours of coding as i am newbie like you. Here is the link:

    http://www.al-williams.com/pak6.htm

    Ion
  • BobbyJBobbyJ Posts: 22
    edited 2004-08-04 03:55
    I may be new to Basic Stamps, but this is by no means my first project. I have already built 3 MIDI controllers that I use on my PC. The first 2 I built used circuit designs and code from other people that had put their designs on the internet. The 3rd was about 50% my design. I wish I could take on an easier problem to solve, but unfortunately this is the only problem I have, at least for now.

    The project I am now working is to build a custom controller for my XBox. Before getting the XBox I had always gotten my gaming fix from my PC. My all time favorite type of games to play are First Person Shooters. On the PC I used the keyboard and mouse as controllers for the games. The keyboard is used for movement (forward, back, left, right, jump, crouch, evade, etc.) and the mouse is used to aim and fire weapons. It is hands down (in my opinion) the most fluid and accurate way to play these types of games.

    Unfortunately, as far as I can tell, Microsoft did not allow for direct support on the XBox for a keyboard and mouse. If somebody wants to develop games for the XBox and wants to allow for the option for using them, they have to write all the code into the game to support it. So I am currently in the position of being forced to use the game controller that shipped with the XBox. These controller work extremely well for some games, but not for what I am playing.

    My goal is to replace the right thumb-stick on the XBox controller with a mouse and to replace everything else with new buttons. The idea is to have the same type on controller·for the XBox that I already have on my PC. So far I have been able to do everything except replacing the right thumb-stick. This is the only part of the project, at least for now, that I will be using the BS2. Once I get the X & Y axis and the button state information into the BS2, everything will/should be pretty easy.



    I'll check out the links you guys gave. I was hoping this problem could be solved using just the Basic Stamp. But, if I have to add in something else i guess I'll go that route.
  • AlWilliamsAWCAlWilliamsAWC Posts: 135
    edited 2004-08-04 13:37
    Just to clarify, the PAK-VIa will work with a keyboard or mouse and if you want to read raw data from the mouse, it is probably the way to go. If you want to read position data from the mouse (that is, read the X/Y coordinates) you want the PAK-XI. You can do it all with the PAK-VIa, but it is harder. There are several mouse/Stamp articles in our document library (which has a lot of free projects) at http://www.awce.com/doclib.htm.

    Good luck!

    Al Williams
    AWC
Sign In or Register to comment.