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.

Optical mouse based on an PIC microcontroller

Status
Not open for further replies.
dapyta said:
Does anyone have a project of an optical PS/2 mouse based on a PIC microcontroller?

The UK magazine EPE did a project a few months ago on using PS2 mice and keyboards with a PIC. You can download the software from their website.
 
dapyta said:
More I need a scheme of that project.

There's not much to it, pins RA0 and RA1 have 1K resistors direct to the pins, with the other ends connected to 10K pullup resistors (going to 5V). The clock and data lines connect to the junctions of the 1K and 10K. Clock(pin 3) is RA1, and data (pin 1) RA0. Obvioulsy you need to connect 5V (pin 5) and Gnd (pin2).
 
deja_wu said:
ı wish do one optical mouse ownself.
anybody can helpme
You'd be amazed what Google can do.

Look at this datasheet from Agilent.

I would not expect someone to provide a complete project with step by step instructions and pc code.

If you look some more, there are many examples of interfacing PIC with PS2.
 
doesn't sound like a very worthwhile project in my opinion. You can buy cheap optical mice for just a couple dollars, but you're going to spend way more than that buying parts to build one. And what's worse, most likely the cheapest way to get the parts would be to just build it from an existing mouse, and then all you are doing is removing the (perfectly good) controller board and replacing it with your own, and what's so exciting about that?
 
An optical mouse using a PIC only is a bad idea if not completly impossible. Optical mice use a CMOS camera and a dedicated processing section to photograph the light patterns coming from the surface it's being used on and correlate a relative motion from the last know pattern.
 
Did anyone find an assembly language routine to read a PS/2 mouse that can be easily modified to work on a PIC 16F628A? The 2 from EPE magazine didn’t work for me. Can you write to an input port before changing it to an output port? He did that numerous times. Can you do that?

START MOVLW 0xFF
MOVWF PORTA ;PORTA is input, stayed at 00000000 ?
CLRF PORTB ; PORTB was clear and is input, wouldn't have changed

SENDCOMMAND CLRF PARITY
BCF PORTA , 01 ; set clk low for at least 100us (1)
BSF STATUS , RP0
BCF TRISA , 01 ; set clk as output
BCF STATUS , RP0

I have been searching for 3 days and found a lot of info but not a useable routine. If anyone has a good link, please post it.
Thank you
Clyde
 
ClydeCrashKop said:
Can you write to an input port before changing it to an output port? He did that numerous times. Can you do that?

One is not actually writing to the port pin but the port latch instead if the port is configured as an input port.

Not only is this possible but I think it is more "professional" to do it this way. The reason being one knows and can control exactly what the pins logic level would be when the port becomes an output port. Doing it otherwise(set port direction & then logic level) would set all pins HIGH/LOW for at least one or more instruction cycles and then the proper level can be outputted to the port.

For some outside circuits connected to the port, this brief moment of "wrong" logic state is not acceptable or desirable.
 
eblc1388 said:
Not only is this possible but I think it is more "professional" to do it this way.

Yes it's normal to do it that way, set the output latch to what you want for your initial position before you set TRIS - this avoids briefly setting the pins wrong.

Assume you're building a timer for a bomb? - and to set the bomb off you need to set the pin high. Your initialisation routine will set the port LOW before you TRIS it as an output - otherwise when you TRIS it the pin might go HIGH instead, with an unfortunate outcome! :p
 
Thanks for clearing that up. I wondered about the "wrong" logic state between changing to output and writing to it.
 
As per usual, I was whipping a dead mouse! I wondered why I couldn’t get a heart beat. It works much better with a live one.
 
Status
Not open for further replies.

Latest threads

Back
Top