Single Chip Compound Eye
The goal of this project was to make a simple compound eye, kind of like a compound eye of a bug. A secondary objective was to implement a simple two wire interface between the sensor chip and the rest of my system. I patterned the protocol after the sharp GP2D02 proximity detector. The third objective was to make this work on a Atmel 90S1200 - the least capable chip in the AVR series. I happen to have a handful of those chips and needed to start thinking of using them to help out in developing smart sensors for my robotics work.The interface works very well, the hard part is the photo sensor it self. Since I don't really know what I am doing with photo transistors, I kind of cut an tried until I got some thing that sort of worked. Pretty weak praise indeed! Anyway, I'll point out the problems and maybe some knowledgeable type can correct them and make this a killer sensor for a robot.
The eye's lens is just a slot. Sort of like a pinhole camera. One problem with this design is that I made it very wide angle. Due to parallax, the outer photo transistors have a very narrow slit to look through and their response is poor. The obvious solution is to simply not have such a short focal length.
The schematic is pretty simple. I used all spare pins on a 90S1200 as tri-state outputs. Each, in turn, drives low a photo transistor. The current flowing through the beast is mirrored through two PNP transistors (yeah, I know you are not suppose to be able to do this with discretes, but it seems to work just fine) and charges a small capacitor. The 1200 merely measures the amount of time it takes to charge the capacitor. It has a 12 bit counter counting the crystal frequency divided by 64, so there is a range of 1 (4 uS) in bright light, to 0xFFF (~16 mS) in the dark. There is a 100 us delay after switching transistors, to allow capacitive charges to bleed off and the current flow through the mirror to stabilize, before enabling the comparator and allowing the timing capacitor to be charged.
The communications protocol is as follows:
| At reset all lines are tri-stated and there is a pull-up on Vin (to suppress noise) | |
| The host initiates a measurement cycle by driving Vin low. The SerialAD chip acknowledges by driving Vout low (~500ns delay). | |
| When a measurement cycle is done (1-200ms later) Vout is driven high | |
| The host raises Vin to clock the next bit of data out. It reads the data when it drops Vin. The minimum timing is around 500ns (8 clock cycles of the 1200). There is a maximum duration of around 2ms - if that is exceeded on either the high or low period the 1200 will reset and start over. This timeout does not apply until after the host raises Vin the first time. | |
| There are 11 channels, each clocks out 16 bits of data. After 176 cycles the 1200 will start another measurement cycle when the Vin is driven down the last time. | |
| Alternatively, if Vin is held high (or low anytime prior to the last cycle) for 2 ms, communications is halted and the chip resets. | |
| Reset mode, for the 1200, is a low power state and is indicated by tri-stateing Vout. |
This is a bad photo of the AD timing/signal. Each sawtooth is an individual photo transistor charging up the timing capacitor via the current mirror. The wider the ramp the lower the light level on the photo transistor. The conversion starts with Vout being driven from Tri-state (middle trace) to low. After all conversions are done, then Vout is raised and then clocks out the data.
The next photo is the signals Vin (upper trace) and Vout (lower trace). When Vin drops, Vout is driven low. When Vout is driven high, then the host clocks out the data by toggling Vin. After all the data is received, Vin is held high for 2ms and Vout is tri-stated when the 1200 is reset.
2V / 5mS per division
To build the software you
need the IAR assembler, v1.30 and the following files:
| avriodef.inc | AVR peripheral definition file from AvrX | |
| hardware.inc | Hardware definition for this chip | |
| main.asm | Source code for SerialAD chip | |
| build.bat | Batch file to assemble and link the files | |
| TestingHost | Zip file for the test harness (S2313 or greater chip) |