PS/2 Mouse sample code with serial terminal support?
Botdocter
Posts: 271
I have a ps/2 mouse ready to hook up but now i need some code to make it run. I have downloaded the "Mouse" driver from the obex, but it doesn't contain any demo code.
All i need is the mouse to count the steps it's away from it's base(starting point) as Y, and the rotation must be calculated with X, so a fixed total value 360 degrees
PNG file is attached to make my idea more clear.
Any help is appreciated since i cannot find any tutorials or topics on this...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
All i need is the mouse to count the steps it's away from it's base(starting point) as Y, and the rotation must be calculated with X, so a fixed total value 360 degrees
PNG file is attached to make my idea more clear.
Any help is appreciated since i cannot find any tutorials or topics on this...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
it seems that great minds think alike; i been working out
the finer points of building a bot incorporating a PS/2
mouse as the soul sensory input. it would use a internal
mapping subroutine to 'know' where it is in a room, etc.
i was planning on using a cutdown protoboard, but the
size and expense has me working on a version using a
PIC and a small toy robot i bought. i was going to use
the Prop mouse driver also, but now i guess i'll have to
port it PIC asselmbler (oh boy, what fun). i have a genuine
Paralllax optical mouse ($5, great deal) that i plan to
harvest for parts.
good luck with your mouse-bot.
blake
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Can't sleep, clown will eat me."
Bart Simpson
http://forums.parallax.com/showthread.php?p=661158
http://forums.parallax.com/showthread.php?p=782525
hackaday.com/2006/01/29/robotic-motion-sensing-using-an-optical-mouse/ humanoido
Post Edited (humanoido) : 4/14/2010 2:07:46 AM GMT
it uses wavefront mapping.
Search on the forum for 'matrix' and you'd find my topic.
Might you find anything on ps/2 let me know
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
But nothing when the mouse moves..
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
Not surprising, as you print the local variables, not the function results: Change the code to:
And it should work as you expect. You don't actually need mousex and mousey, if all you want to do is print to the serial output. You can call the functions mouse.delta_x and mouse.delta_y inside the dec().
HTH,
Juergen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects
Thank you!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
nothing...?!?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
Let me try that and ill get back to you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
Wat is wrong? I saw that in the mouse itself, on the cPin and dPin there are allready 2 resistors could that be a problem?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
HELP!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
No not at all.
There are two ways to solve a problem arrowing and narrowing.
arrowing means shoot around creative guesses in the hope that one hits the problem.
can be succesfull quickly can be unsuccessful endlessly
narrowing means narrow down the problem by excluding possible reasons STEP BY STEP.
ALWAYS successful after a limited amount of time.
Did you connect the mouse to a PC testing if it works with a PC? If everything is alright the mouse-internal LED lights up
you can't reverse this conclusion. if the internal LED lights up this is no guarantee that EVERYTHING is working
Did you check the input pins by simply connecting them through a switch to +3.3V/0V?
Did you check the clock and dataline of the mouse with an oscilloscope what the signal levels are when connected to the propeller?
Alternative: did you made a small testprogram that checks if the clockline/dataline is switching
Did you download the code to RAM or EEPROM?
What kind of board do oyu have?
The more information you provide about your setup the better the help can be.
From providing the word "help" the only help can be asking back questions
best regards
Stefan
Anyway, a few questions where already answered a few posts back. So here we go:
i have no pc to test the mouse on since i'm a mac user.
I've changed the input pins to other pins but did not matter.
I have a propeller robot control board ( as used in the stingray)
i bought 2 mice and the inside is quite different. One has resistors for the leds and for the clock and datapin. When i connect this one the power seems to be too low to work. The other one has no internal resistors and power is just fine. Neither of them give me any output what so ever.
If you need to know more, please let me know...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
you haven't even answered my questions yet
do you have an oscilloscope?
I took a look onto the schematic of the propeller robot control board
(could have been provide by you to make it easier for other forum-members to help you)
most of the prop-IO-pins are conected to some kind of hardware that will interfere with the mouse.
As long as you don't tell us on which Prop-IO-pins you have connected the mouse everything is speculation
so please tell us which IO-pins you use for the mouse - and addtional - your knowledge level about electronics
best regards
Stefan
He used pins 8 and 9, as can be seen in the source he posted. I don't think he changed his code to what I suggested in the first reply, though.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects
Give it a try.
Jim
i really have no idea what i did wrong. If i connect it to those ports without the converter in between. Do i still need the pullup resistors?(100 ohm and 10K)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
Post Edited (Botdocter) : 4/19/2010 3:17:16 PM GMT
Jim
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
I tried everything. Usb mice, ps2 mice and combi mice ( also wireless ).
I really need this mouse to work before i can code anything else. Please help me!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
Have you made the connections right ? The MiniDIN have a weird numbering of the pins.
Here is a working Layout, viewed from the component side.
Andy
If so i have the wires the right way.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
using a wireless mouse at the beginning is not a good idea as then you are dealing with another source of faults: the wireless connection.
If you start to develop something you should keep the things as simple as possible.
did you make the basic checks that I recommended?
You seem to be a hobbyist. But at some points you need to work like a professional. If you are just guessing around "it might be this or that"
your hobby is guessing around and trying and no longer programming.
If a professional encounters a problem and can't solve it with two quick guesses he switches to analysing ALL the details.
Not a single detail is skipped by thinking "I think this is it not" And he checks REALLY EVERYTHING.
This means:
Using a SPIN-demoprogram that is well known as working. Checking does the mouse work with this?
next check is: are the IO-pins still working properly?
using a small testprogram that check the IO-pins are they still working as input / output by simply connecting then through a current-limiting resistor of 1kOhm with a switch
which connects the IO-pin to ground or +3.3V
then testing the io-pin with a small led-blinking program conneting a current-limiting resistor of 220 ohms and an LED to the IO-pin
only if you HAVE DONE these checks you can be REALLY sure the IO-pins are still working
Without that checks you are just ASSUMING they are working. If this is NOT the case you can try pull-up-resistors, pinouts mices as long as you want
you won't find the error.
next thing using an oscillsocope to analyse the signals on the pins of the mouse.
1.) when connected to a PC
2.) when connected to the propeller
comparing them
if you don't have an oscilloscope write a small testprogram that makes a variable count up everytime the state of the IO-pin connected to the data-line of the mouse changes
from this you get a feedback "dataline changes its signal state". Of course then you know much less then if use an oscilloscope.
connect the mouse to the data and clock-io-pin
additional connect the clock-io-pin through a resistor to another free IO-pin and use a freq-measuring program started in another cog to see if the clock-line
toggles at the required frequency
etc. etc. etc.
best regards
Stefan
I need to say one thing though...
I'm getting so tired of members who seem to think i just ask and do no research myself.
because i do!
The information found on this forum isn't very clear though most of the time.
For a newbie to spin, a lot of things are not understandablr because of a lot of 'jargon'
anyway...
All the code that i have untill now, i wrote myself. Nothing is copied, and so i did my own research.
As for the mouse: i didn't just try anything. I followed the posts that i could find and it turned out to do nothing. So i tried to find a solution but had no succes. And here we are.
I have no osciloscope and have code from the obex to make it work. Even have code that has been posted in this topic by one of the members but also no succes...
I hope i can write those test programms. At least i will try...
Thanx!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
You should make the connections before the voltage translater as hover1 suggested, and don't forget to close the
jumper to disable the translator (JP3 if you use pins 8/9).
Andy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 Parallax Propeller Robot Control Board
1 Memsic MX2125 accelerometer/ tilt
1 Parallax Ping))) ultrasonic sensor
a few motors and a whole lot of chaos!
Post Edited (Botdocter) : 4/21/2010 7:21:23 PM GMT
Let use know how it turns out.
Jim