Friday, April 1, 2016

The Mouse Robot, Part 2 - THE HARDWARE

(Looking for the introduction to the project? Here it is!)

The robot mouse is a simple affair - essentially 3 photo sensors connected to motors; if it sees white, photo sensor goes off; if it seems black, photo sensor does not. Think of the motors as directly connected to the photo sensors (although, they are not, of course, there are transistors, and ICs, and a whole bunch of stuff along the way) - but it helps to think of it this way.

If the photosensor sees white (while the others see black) it simply turns on the corresponding motor. Turning on the left motor turns the mouse right, so that way it aligns itself to see more black. It's quite elegant, really.

And also, perfect for hacking. Simply hijack the signal from the photoreceptors to the logic board, and wham! Robot mouse does your bidding. They even conveniently have the photoreceptors and sensor board completely apart from the main logic and motor control board and connect them with a ribbon cable, easily connectable to boards of your own choosing.

A few notes on the Mouse -

1. it is horrible on carpeted surfaces. You can possibly wrap around rubber bands around the wheels or something, but I didn't bother. You can certainly hack the code and use something more beefy, like this robot kit - if you have any luck - post about your adventures and misadventures in the comments below!

2. my personal mouse won't stop - no matter what combination of photoreceptors it sees. It seems to have only "forward", "right", and "left". When it doesn't have a valid response from the photoreceptors, it chooses "right" (i.e.  - activate left wheel). I have a feeling that is a deliberate design - it is so if it can't find anything it starts rotating around looking for the black line again. But I can't be sure. Maybe I just soldered something wrong :)

In other words, the logic table of the mouse seems to be (I didn't bother testing things like 110 and 011, maybe it would be a good idea when I'm bored):
Left sensor Middle sensor Right sensor Expected left motor Expected right motor Real left motor Real right motor
0000010
0011010
0101111
1001010

The next component I have is a Particle.io board; I still have the first Kickstarter version, then named "Spark". Your mileage may vary with your specific board. With Particle.io, everybody can write a web connected device. So can you.

Begin by assembling your mouse robot according to the instructions - make sure it works by testing it on a black line and seeing that it properly follows. Relish in your newfound soldering ability. Cry profusely at the times you accidentally soldered incorrectly and struggled valiantly with a blob of solder that threatened to short out all your board. Wipe the sweat off your brow and have a beer. You've earned it, my friend.

Once you're done with the mouse, take one of the small PCB layout boards, and solder on two female header sets, the length of your Photon board, and space them the width of your board apart. Additionally, solder a 5 pin male header strip as well. This is what mine looked like:




You can see I marked + and - on the male headers where the positive and the negative would go, and the USB side of the photon board - so I make sure I put it correctly every time.

On the back, solder a wire connecting one side (the + side) of the male header to the vin pin of the photon, the other (- side) to the gnd pin, and the other 3 to pins 5, 6, and 7 in order. (The one closest to your - side should be to pin 5, middle to pin 6, and the one closest to the + side to pin 7)

This how the back of mine looks:




I never said I was any good at soldering.

You can now slot your photon in the headers:


And you're done! You can plug the ribbon cable (ensuring correct polarity, in my case the yellow ribbon was the DC voltage) into your new "sensor board" and hopefully, everything will light up.

In the next part, we will start showing your the backend code and testing it with curl, the final part will talk about the Android app. All source code will be available on github, of course.

Here's the link to the backend part!

No comments:

Post a Comment