Eye Ball Sensor

Embed Size (px)

Citation preview

  • 8/3/2019 Eye Ball Sensor

    1/14

    I Make Projects . comOn the right project, some bad rust looks better than some goodpaint.

    Main|Projects |About|Contact and Services

    The Seeing-Eye-MouseA general-purpose sensor made from anoptical or ball mouse (for use on a robot,but useful for most anything else too)

    What It Is

    Short Version

    To put it concisely, the Seeing-Eye Mouse (like a seeing-eye dog) is apiece of logical "glue" - it gives you a simple interface to a computermouse for whatever purpose you may want.

    I used it as a navigational device for a robot (like aguide dog for a robot, but it's a mouse).

    Slightly Longer Version

    The Seeing-Eye Mouse is a chip (made by programming a PIC) thatallows you to use any PS/2 (or USB) mouse as a sensor, allowing you toeasily read information such as direction and speed (relative a surface,like the floor) in various useful and interesting ways. It has beenpurposefully designed to allow for a wide range of interface modes so it'seasy to hook up to any electronic project.

    Plug in a mouse, and it reads the mouse movements and turns that

    http://imakeprojects.com/http://imakeprojects.com/http://imakeprojects.com/http://imakeprojects.com/Projects/http://imakeprojects.com/Projects/http://imakeprojects.com/Projects/http://imakeprojects.com/About/http://imakeprojects.com/About/http://imakeprojects.com/About/http://imakeprojects.com/Contact/http://imakeprojects.com/Contact/http://imakeprojects.com/Contact/http://en.wikipedia.org/wiki/Guide_dogshttp://imakeprojects.com/feed.xmlhttp://imakeprojects.com/feed.xmlhttp://imakeprojects.com/feed.xmlhttp://imakeprojects.com/feed.xmlhttp://imakeprojects.com/feed.xmlhttp://en.wikipedia.org/wiki/Guide_dogshttp://imakeprojects.com/Contact/http://imakeprojects.com/About/http://imakeprojects.com/Projects/http://imakeprojects.com/http://imakeprojects.com/
  • 8/3/2019 Eye Ball Sensor

    2/14

    movement into digital pin outputs and (optional) RS232 data, to be used inany way you like.

    For example, when attached to a robot it works as a navigational aid(detecting relative direction and speed). But you can use it in other ways,

    too. I originally made it to be an additional sensor for my Mini SumoRobot. (More on that later in the page)

    Here is a picture of a mouse (this one is USB) pluggedinto a USB->PS/2 adapter, and plugged into a workingprototype of the Seeing-Eye Mouse. The PCB hasswitches and traces allowing all possible modes ofcommunication and operation, though the Seeing-EyeMouse chip can actually be effectively used with noexternal components. A PCB is not required - it justmade my prototyping easier.

    Some Words About Why

    Hardware hackers in general and robot-makers in particular are pleasedby using things in elegant and unusual ways. And the Seeing-Eye Mousepleases me.

    The mouse really is a nice little elegant piece of hardware and capable ofquite a lot. And they are cheap. It's a shame to use them only forcontrolling a mouse pointer on a screen.

    In fact, especially for robotics the Seeing-Eye Mouse fills a sensor void -being able to detect actual motion in a easy, simple, cheap, andmeaningful way.

    I originally conceived of the idea for use in Sumo Robotics as a way formy robots to detect whether or not they were being pushed by theiropponent. But it's really useful for anything else that might tickle yourfancy.

    What It DoesIt is a man-in-the-middle between you and the mouse, and takes care ofall the protocol, state tracking, etc. It then presents the data in variouseasy-to-read, easily interfaced formats. If you can read simple HI/LOW pinoutputs from a chip, you can use the Seeing-Eye Mouse. (Optionallyhigher functionality is available by RS232 serial output, too.) There is evena mode that drives regular R/C servos directly with PWM output.

  • 8/3/2019 Eye Ball Sensor

    3/14

    How It Works

    Whenever the mouse is moved, it does some low-level hardware stuff todetermine some basics about the motion and other events (such as buttonpushes/releases). It sends this data -- X/Y change from last position -- tothe host (usually a PC, or in this case the Seeing-Eye Mouse chip) whichthen interprets it in order to take some kind of action.

    With a PC, that data is used to move the mouse pointer and performbutton click actions.

    The Seeing-Eye Mouse reads the mouse's raw data and handles all theprotocols, state tracking, and calculations (including remembering pastdata) required to provide you with simple, meaningful results that anyonecan understand and use.

    Bare-Bones Operation Action Shots

    The prototype board pictured below demonstrates the most basic ofoperation modes: mouse movement direction.

    Red Arrows showdirection of mousemovement.

    Yellow Dots

    represent lit LEDs.

    The White Binaryrepresents the 4output pins (FBLRfor Forward, Back,Left, Right)

    In the BasicMode, the whitebinary is also sent

    as ASCII out a pinas RS232 serialdata.

    Other built-in,more advanced

  • 8/3/2019 Eye Ball Sensor

    4/14

    modes ofoperation areavailable. More onthem later.

    Note that combined directions(diagonals) are also represented.

    Advanced Capabilities

    It is possible to configure both the sensitivity (movement detection

    threshold) of the Seeing-Eye Mouse as well as the mode of operation.These are all set by hardware (tying configuration pins high or low). Nosoftware configuration required.

    These other modes include output data such as:

    Basic FBLR (Forward,Back,Left,Right one on each of 4 pins) logic-level TTL output whenever movement in a direction in excess ofthe configured threshold (sensititvity) is detected. Same data alsoavailable as RS232 output (9600 baud, 8N1, TTL true).

    PWM output (suitable for driving RC servos directly) representative

    of velocity in the forward/back and left/right axes of movement.

    Button states of the mouse.

    RS232 output of current velocity (0-127 - covering approximately0"/sec to 12"/sec.)

    A rough "odometer" for each of the 4 directions (a cumulativecounter of each direction's velocity sampled every 200ms)

    RS232 output either as a stream to be polled, or transmitted on-

    demand by host pulling a pin low.

    Advanced Capabilities

    It does not emulate a mouse (it cannot control your PC's mouse pointer).

    It does not make the low-level operation of the mouse available to you. So

  • 8/3/2019 Eye Ball Sensor

    5/14

    you cannotuse it to turn your mouse into an optical scanner like this one(http://sprite.student.utwente.nl/~jeroen/projects/mouseeye/) . It reads themouse's output protocol just like your computer does. It does not provideaccess to the low-level operations of the mouse circuitry.

    It is a black box that speaks "Mouse Language" and processes/interpretsfor you, not an interface into the guts.

    Uses, and What I Used It For

    I put it on a mini-sumo robot as a navigational sensor. Unlike wheel orshaft encoders (which sense movement of the wheels) the Seeing-EyeMouse tells me whether the robot is ACTUALLY, physically in motion.

    This is important information for a Sumo robot. (But so far as I know allcurrent ones are "blind" in this regard.) In normal robots, movement in adirection other than what is intended is usually indicative of a grossmalfunction or other error. In Robotic Sumo Wrestling, it happens all thetime - the whole point is to muscle the other robot around!

    So it is of obvious significance in situations such as robotic combat, oruseful for other feedback - to detect wheel slippage, poor traction, track orwheel failures, actual speed changes (due to going up/downhill), etc.

    When attached to a robot the Seeing-Eye Mouse, as a sensor, cananswer:

    Am I actually, physically moving? In what direction am I moving? About how fast am I going? Have I been moving lately? How much? In what directions? Have any of the mouse buttons been pressed or released?

    It can even move an unmodified R/C servo in proportion to the mousespeed in the X and/or Y axes (this makes an easy head-control that"looks" left-right in the direction a robot is moving.)

    Of course, you don't have to attach the mouse to a robot. You can also

    have the mouse stationary over something that moves (like a belt, wheel,track, etc) or move the mouse with your hand as an input device -- it allgenerates the same kinds of data in the same easy-to-read ways.

    Stuff it can not do:

    It is not a compass ("What is my heading?")

    http://sprite.student.utwente.nl/~jeroen/projects/mouseeye/http://www.robotgames.net/robotgames/Event_Rules/2002-minisumo.htmhttp://www.robotgames.net/robotgames/Event_Rules/2002-minisumo.htmhttp://sprite.student.utwente.nl/~jeroen/projects/mouseeye/
  • 8/3/2019 Eye Ball Sensor

    6/14

    It is not a locator ("Where am I?") It is not an object detector ("What's out there?") It is not an odometer/dead reckoner ("How far, exactly, have I

    gone?")

    What Does a Functional Seeing-Eye MouseConsist Of?

    The core pieces are:

    - The Seeing-Eye Mouse chip (consists of a PIC16F628A microcontroller)See the Downloads section below for the source code.

    - A mouse (PS/2 or USB) Note: all PS/2 mice should work but I havefound at least one USB mouse (a Microsoft one) that did not work when

    plugged into a USB->PS/2 adapter.

    - A regulated +5V power supply.

    What is the Simplest Way to Make it Work withthe Fewest Parts?

    Here is how to hook up the Seeing-Eye Mouse with no externalcomponents other than 4 LED indicators (with 4 resistors for the LEDs) forabsolute bare-bones operation (you do need to provide +5V though, and a

    0.1uF capacitor across the power to the PIC would be nice):

  • 8/3/2019 Eye Ball Sensor

    7/14

    Communication

    Once a mouse and power is supplied to the Seeing-Eye Mouse, it cancommunicate in several different ways, including:

    - Digital I/O (pin outputs for Forward, Back, Left, Right)- PWM output (suitable for controlling RC hobby servos directly, or forinterpretation by a host)- RS232 serial data (plain ASCII packets, either on-demand or as acontinuing stream). The data can be configured to communicate severaldifferent levels of complexity.

    The Seeing-Eye Mouse is intended to be used mainly as an outputdevice.

    Full details of the communication modes are in the documentation - seethe Downloads section below.

  • 8/3/2019 Eye Ball Sensor

    8/14

    Configuration

    The mode of operation (as well as some basic sensitivity) can be set bypin I/O (setting pins high or low) on the Seeing-Eye Mouse chip. Noprogramming or software configuration is necessary. Just some jumpersor some DIP switches.

    Full details of the operation modes are in the documentation - see theDownloads section below.

    If customization is desired, the source code is available for you to tweakthe source code and re-program the chip. You should be familiar with PICprogramming before you consider doing such a thing, however.

    Other Possible Uses

    (This one's been covered but it bears repeating.) When attached toa robot (ie the mouse is mobile over a surface), this allows you touse the mouse as a standalone sensor to detect direction andspeed of the host's motion. (This is different than shaft or wheelencoders, which only detect whether the motor or wheel is moving -not whether the robot is in fact in actual motion as a result.)

    If the mouse is instead held stationary over a moving object (suchas a belt, track, wheel, etc) it can be used to detect the directionand speed of the object's motion.

    The mouse can also be used conventionally (ie moved bysomething such as your hand) as a simple input device to almostanything.

    The mouse can control a standard RC Servo directly with it's PWMoutput mode. If you put the Seeing-Eye Mouse on a robot with aservo, the servo will automatically point in the direction the robot ismoving. Instant head/sensor cluster aiming!

    A SUMO robot can certainly benefit from being able to detect

    actual, physical movement in order to gain an edge. ("I know I toldthe motors to go, but am I actually moving in the direction andspeed I think I should be moving?") This means:

    1. If I am moving in an unexpected direction, I am being pushed bymy opponent! Must Escape!

    2. If I am moving forward slower than I should, I am pushing my

  • 8/3/2019 Eye Ball Sensor

    9/14

    opponent... and winning!

    3. If I should be moving forward, but am actually going BACKWARD -I am in a head-to-head, and LOSING! MUST ESCAPE!

    The Seeing-Eye-Mouse Used in my Mini-SumoRobot "Tricksy"

    I used the Seeing-Eye-Mouse on my Sumo Robot"Tricksy", which I made forthe WCRG (WesternCanadian Robot Games) in2004.

    Mini-Sumo robots are up to10cm x 10cm in size, andup to 500 grams in mass.The object is for one robotto push the other robot outof the ring (the ring is the

    raised black disc with a white edge).

    Unfortunately, I fell ill the night before and could not travel. Then, in 2005 Iwas unable to attend due to a time conflict. So... sadly, as of Feb 2006 ithas never seen action outside of my basement.

    Tricksy's "edge" would be the ability to tell in what direction it wasphysically moving. As explained in the previous on this page, thisinformation is of obvious use to a Sumo robot.

    I used a modified Solarbotics Sumovore kit as the base for "Tricksy". Theguts of an optical mouse are on the bottom (where 4 AA-cells used to be)and a custom daughterboard along with the Seeing-Eye-Mouse prototypePCB has been added. Would Tricksy with a Seeing-Eye-Mouse defeat"plain" sumovores (which are formidable opponents in their own right)? Ihoped so.

    http://www.robotgames.net/http://www.robotgames.net/http://www.solarbotics.com/http://www.solarbotics.com/http://www.robotgames.net/http://www.robotgames.net/
  • 8/3/2019 Eye Ball Sensor

    10/14

    So what did I do with the Seeing-Eye-Mouse on a sumo robot? Gave therobot a secret "Escape" move, of course!

    Side note: Normally I would design a Sumo Robot under the principle that the bestdefense is a good offense. Weight, power, and resources spent on a defensive aspectare just resources that aren't allocated to offense. Or put another way, the opponent can'tpush YOU if you've already found and are pushing THEM. So I can't really explain why Itook this route with Tricksy other than I think it was neat, and I wanted to take Sumorobots in a direction that I have not (yet) seen explored. The robot already had goodoffense (thanks to the excellent kit by Solarbotics, it is no entry-level beginner's dud - thekit makes a highly effective competition robot), so I tried to give it an "edge" on top ofthat.

    The concept for attaching the Seeing-Eye-Mouse and interfacing it to the

    Sumovore is straightforward. The basic Sumovore has a discrete "brain"built in to govern its behaviour. So I made a daughterboard that is like abreakout box. Instead of the motor signals going directly from the discretebrain to the motor drivers (to control forward, back, turn left, turn right) thesignals go to my daughterboard which can pass them (unchanged)through to the motors, or optionally override them. Mostly, thedaughterboard simply passes the signals through to the motors so therobot's basic behaviour is unchanged.... exceptfor when it's losing ashoving match! When the motors should be going forward but the robot ismoving backwards, the daughterboard overrides the discrete brain'scommands as needed - governed by what the Seeing-Eye-Mouse is

    telling it about detected movement.

  • 8/3/2019 Eye Ball Sensor

    11/14

    So, to explain further let's digress a little to Sumo Robots and how theywork and what happens in matches.

    Modern sumo robots with IR sensors are pretty good at detecting theiropponents. When the match is on, the robots plow forward, heading forthe other robot (the only other object in the ring). If they are lucky, theycatch the other robot on the side or the rear, and easily shove them out ofthe ring.

    But often, a match comes down to a head-to-head pushing match. Bothrobots plow (mostly dumbly) ahead, hoping to be the victor in this brute-force showdown.

    What "Tricksy" uses the Seeing-Eye-Mouse to do is detect if Tricksy islosing this shoving match.

    If the discrete brain is telling the motors "Full Speed Ahead" but theSeeing-Eye-Mouse tells Tricksy that the optical mouse stuck under it hasdetected that it is in fact moving backwards -- then Tricksy is losing theshoving match! And as anyone who has watched or competed in RoboticSumo wrestling knows, once you start to lose traction you tend to KEEPlosing it. Once one robot in the head-on "gives", it's usually a goner.

    So I am losing the shoving match - what do I do about it? Well, first I needto get out of the way. Then I need to counterattack. If I just keep plowingahead I am as good as eliminated!

    Steps:

    1. Get out of the way. Or in other words, break contact and retreat. Thisconsists of overriding the motor signals so that we back up and turn out of

  • 8/3/2019 Eye Ball Sensor

    12/14

    the way to the side, while still keeping our opponent in front of us -- likedoing a fish hook maneuver but while moving backwards. The idea here isto get a little room to maneuver to get out of the direct line of fire and endup pointing more or less in the direction of the opponent.

    2. Counterattack. This is nothing more than allowing the built-in"instincts" of the Sumovore to once again take over. In other words, we'refinished overriding the signals from the discrete brain. It will once againhome in and charge at anything detected by the object sensors. (Whichshould include the opponent which we have kept in sight while retreating.)Ideally we re-engage the opponent, but this time from the side or rear.

    I had to do a lot of tweaking for times, angle to turn, etc but I think I got itmostly right.

    This isn't a get-out-of-jail-free card for the robot, however. A fast robot

    with good sensors may just stick nose-to-nose with you like gluethroughout your attempt to break contact. But if you do what Sumo Robotsalways do when they are in a push-losing situation (i.e. nothing) thenyou're DEFINATELY a goner. At least this way there's a chance; you areprobably at least in a somewhat better position than before, and if nothingelse you might keep your traction this time around when you re-establishcontact.

    There is surely plenty of room for improvement all around, but I think it is agood first implementation.

    Video of "Tricksy"

    Here you can see a robot overview as well as ademonstration of the "Escape" special moveversus a couple of objects. It is not footage of anactual Sumo match for two reasons. One, myrobot has not yet competed (as you'll recall), andTwo - I think this is the clearest way todemonstrate the move. (NOTE: a regulation-size

    Mini Sumo ring is much bigger than the small black disc that I use fortesting in the video.)

    In the video I push the robot back so that the Seeing-Eye-Mouse sensesbackward movement when it knows the robot should be moving forward.This triggers the "Escape" move. The robot then does the fishhook-reverse to escape - we pretend the inert "opponent" still charges angrilyahead meanwhile - and then the regular behaviour of my robot takes overfor a counterattack.

    http://video.google.com/videoplay?docid=-3604473453772492383http://video.google.com/videoplay?docid=-3604473453772492383http://video.google.com/videoplay?docid=-3604473453772492383
  • 8/3/2019 Eye Ball Sensor

    13/14

    Possible Improvements

    It would be really neat if a lens could be added to an optical mouse inorder to allow it to work without needing to be so near to a surface. (April2008 - I used to have a link to another person's project that did exactlythat here, but it is no longer valid.)

    Downloads and Resources To Make Your OwnSeeing-Eye Mouse

    Seeing-Eye-Mouse-v1.0-Documentation.txt - Text file technicaldocumentation on operation, pins, and protocols used.

    Seeing-Eye-Mouse-v1.0-PIC_CODE-20041114.zip - All source code(ps2.c, ps2.h, servo.h) for use with the CC5x compiler. With the compilerand these files you can make a HEX file to program a PIC16F628A PICand make your own Seeing-Eye-Mouse version 1.0 chip. Does notinclude precompiled .hex file.

    Seeing-Eye-Mouse compiled HEX code for PIC16F628A - Pre-compiledHEX file for programming your PIC with any suitable PIC programmer.

    If you need them, the programming options are: WDT off, Powerup TimerOn, MCLR on, Brownout reset on, Low voltage programming off, CPD off.Don't forget to also set it to use INTRC (internal oscillator).

    Seeing-Eye-Mouse-v1.0 PCB file- Prototype board inExpressPCB format file. It is the board I used toprototype with. The annotations below go with thisboard. It could use an improvement or two, but itworks. (You do not need the PCB to use the Seeing-Eye-Mouse; it's just in case you might want to use itthat I include it here.)

    Graphic showing notes useful for assembling anddesigning with the Seeing-Eye-Mouse.

    Includes USB to PS/2 wiring, a general pinout for theSeeing-Eye-Mouse, and a possible simple inverter forthe RS232 output.

    http://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1.0-Documentation.txthttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1.0-PIC_CODE-20041114.ziphttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1.0-PIC16F628A.hexhttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1-bare.pcbhttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1-bare.pcbhttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1-pcb-annotation.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1-pcb-annotation.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1-bare.pcbhttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1.0-PIC16F628A.hexhttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1.0-PIC_CODE-20041114.ziphttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1.0-Documentation.txt
  • 8/3/2019 Eye Ball Sensor

    14/14

    A note about the RS232: The Seeing-Eye-Mouse uses noninvertedRS232 at TTL levels, meaning that to hook it up to a PC's serial port youneed a few extra parts as shown in the graphic above. I made it this waybecause as-is it is easier to wire up to another PIC or BASIC STAMP with

    no additional parts.

    To read the RS232 data with a BASIC STAMP for example, wire theRS232 out (pin 8 on Seeing-Eye-Mouse) to a pin on the BASIC STAMPand use SERIN mode T9600 (TTL True, 9600 baud) to read the data. Seethedocumentationfor details about the protocol.

    Main |Projects |About |Contact and Services

    Original Content - Copyright 2010 (Except where specified)

    http://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-notes.jpghttp://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1.0-Documentation.txthttp://imakeprojects.com/http://imakeprojects.com/Projects/http://imakeprojects.com/About/http://imakeprojects.com/Contact/http://imakeprojects.com/Contact/http://imakeprojects.com/feed.xmlhttp://imakeprojects.com/feed.xmlhttp://imakeprojects.com/Contact/http://imakeprojects.com/About/http://imakeprojects.com/Projects/http://imakeprojects.com/http://imakeprojects.com/Projects/seeing-eye-mouse/Gfx/downloads/Seeing-Eye-Mouse-v1.0-Documentation.txt