Let's Make Robots!

Slightly more advanced LDR eye

Read this history first, if you have an hour to kill.

The challenge: make your bot rove around your house. Use no active beacons. Use observations by your bot only. Now, does your bot know where it is?

One possible answer: an eye and a brain.

Room Recognition

Each room in the house has a unique lighting situation. A simple eye that looks around in eight directions would "see" a pattern of light and dark segments. Each cell is connected to one ADC on your uC.

eye_ldr_floorplan.png

I actually built this now!

octoeye_open_bright500.jpg

It's made from pbcb and has eight LDRs glued flat onto the floor. The yellow wire is common V+. The blank wires are the individual LDR leads.

Each LDR makes up a voltage divider with a fixed resistor, all of which have the (exact) same value. Here it is soldered to a Mr Basic breadboard.

octoeye_wiring.jpgoctoeye_voltagedividers.jpg

The little black strip in the DIL socket is a SIL resistor network. It holds eight 22kOhm resistors with one common ground. It has nine pins. Here is a schematic of one single divider and the eightfold voltage divider I built.

octoeye_schematic.png

These voltage dividers give a low voltage in the dark and a high voltage in bright conditions. The SIL resistor chip makes it easy to change the values. I experimented with values 2200 Ohm and 33  KOhm before choosing 22 KOhm. Also, the compact SIL package guarantees that the individual resistors all have the exact same value.

The second row of connectors in the socket connects to this Picaxe 40X2 board that you cannot buy anywhere in the world. But is very easy to make yourself. The flatcable also provides V+ and GND to the eye.

octoeye_40x2_board.jpg

The little chip is a 64 KiloByte eeprom that can be written/read through I2C. The potmeter is used as a user input device. I turn it all the way left to make the Picaxe take readings. I turn it all the way right to make it dump the bytes from eeprom to my PC. It actually has two more functions. In either half of the potmeter's arc, is an area that resets the internal address counter.

The current firmware in this eye just records eight byte values every 30 seconds. The memory dump can be captured to file using any terminal emulator (like Putty). I wrote a few programmes in Processing to visualize the data.

This is a part of the raw data represented as a linegraph. Each reading contains eight byte values (0-255). The device registered one reading every 30 seconds. The boring zero-values were removed manually.

octoeye_vis_linegraph.jpg

The thingy below represents the eye in its physical shape. Each cell in the eye is visualized as a segment of the circle, numbered 0-7. The beige segments indicate actual byte values. Those values are printed along the circle in grey. The red number indicates the highest value or brightest cell.

octoeye_vis_eye.jpg

The purple segments visualize the normalized values. Each value is "stretched" to be a proportional fraction of 255, relative to the brightest value in the series. The brightest in this example is 177. So the other values were Normalized:
N = value * (255 / 177)
The purple segment in the brightest cell is always filled to the edge.

The narrow segments (more saturated in colour) give values in 8 bit resolution. The wider segments (darker in colour) are values in reduced 2 bit resolution. Values 0-255 are reduced to values 0-3.

Each ring indicates one quarter of the full ADC range. The inner ring (filled in black) indicates 0, the next is 63 (or 1), the next is 127 (or 2). The outer ring indicates 191 (or 3).

The large text in the bottom is a binary number compiled by combining eight 2bit values, highest first. The highest normalized value (red) is always binary 11 (3 in human terms). So we might as well discard it. The remaining 14 bits make for the pattern I am really interested in. That could be the memory address where I store the room ID number.

 

I wrote a Processing "sketch" to visualize all the memory locations where the room number would end up, if I would process all data for a whole day. I set my eye on my dinner table for some 24 hours and let it soak up all the light information as the sun came up and went down again. And when I came home, I switched on the lights and TV, opened and closed a few doors. And all kinds of patterns were collected into the logfile. This is what my proposed algorithm would have memorized.

octoeye_vis_memmap.jpg

(All images are actually higher resolution: open them separately for a closer look.)

It would appear that my living room produces quite a few different "fingerprints". Hopefully these do not (all) clash with the fingerprints from other rooms in my house. I must write a programme to investigate how badly the patterns overlap. Only then will I be able to tell how distinctly my device can recognise an individual room or location in my house.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I have been designing so many PCB's lately and have such good luck with Sparkfun, I have started thinking about making a new 28x2 board. No one is really happy with the Picaxe 28x board, and I simply think I could do a lot better. I mean c'mon, no EEPROM on board, adding jumpers and resistors in place of the darlington. Who really needs the darlington anyway --are we turning christmas tree lights on? It needs the motor driver to run off of the hpwm outputs and for Christ sakes, everything should be a friggin' servo connector!! Oh, and what's the deal with the ADC's having the data pin in the center?!?!?

At any rate, if I ever get around to designing one, maybe I'll make a round one too!

Could we roll a piece of PCB into a cylinder shape?

Ohhhw, too bad.

I agree on the horrible design of the rev-ed board. And I've only made one custom picaxe board (see above) and I already understand how ridiculously easy that really is. It's just time consuming. So an LMR-designed project board sounds like an exellent idea.

How about break-away features? Areas of PCB that you could snap off if you don't need them. Just populate the areas you do need. Like a power regulator. An input device (like your switches/voltage dividers; I keep re-inventing that). Or just plain blank areas providing optional space for plenty fasteners. The 28x board has two puny screw holes and not enough space around them to put a decent screw through!

Double decker, my friend... sensor on the top deck and the picaxe down below on a round board. A few PCB stand-offs and you are all set.

Got that, Oddbot?

;-)

I am so glad that you didn't let this one die, rik. I love the 8 segment sensor but not as much as the patented rik-style charts and graphs! Looks like your system is rock solid... I wish you the best of luck on the eventual number crunching.

Go kick some 1 and 0 ass, buddy!

By the time Dagu starts producing these <BIG WINKY>, you will need approximately a 5x5 cm space on the upper deck. Plus a picaxe in its belly.
But.. what when like the sun moves?

Different circumstances (like a moving sun, or a light switching on/off) will present different lighting conditions to my device. My challenge is to distil a pattern from those conditions that is still representative for the location. Or, if that fails, mark an additional pattern as "typical" for that location.

This requires that the algorithm using this device, needs to be able to "learn" which locations go with each pattern.

In the above example, one location (living room table top) resulted in no less than 60 different patterns over the course of an entire day. Each yellow dot in the blue rectangle represents my living room under different conditions. Here's hoping that different rooms will occupy different spots in that rectangle! Or I will have a problem after all.

I had similar idea with a colour sensor except I don't have one yet. Each room would emit a certain pattern of colours. Except I wonder how location within the room would affect either idea?