These sketches configure and read data from the PAA3905 optical flow sensor. The sensor uses standard SPI for communications at a maximum serial port speed of 2 MHz. The sensor data ready is signaled by an active LOW interrupt.
This sensor offers two sensitivities: standard detection and enhanced detection for rough terrain at > 15 cm height. The sensor can automatically switch between bright (>60 lux), low light (>30 lux), and super low light (> 5 lux) conditions. Bright and low light modes work at 126 frames per second. The super low light mode is limited to 50 frames per second.
The sensor uses typically 3.5 mA in operation and has a 12 uA shutdown mode The sensor can operate in navigate mode producing delta X and Y values which are proportional to lateral velocity. The limiting speed is determined by the maximum 7.2 rads/sec flow rate and by distance to the measurement surface; 80 mm is the minimum measurement distance. So at 80 mm the maximum speed is 0.576 m/s (1.25 mph), at 2 meter distance (~drone height) the maximum speed is 14.4 m/s (32 mph), etc.
I am using the STM32L432 Ladybug development board for testing.
The sensor can also operate in raw data (frame grab) mode producing 8-bit, 35 x 35 pixel images from the sensor at a frame rate of ~18 Hz. This makes the PAA3905 an inexpensive, low-resolution, infrared-sensitive video camera. I tested this using Adafruit's 160 x 128 pixel rgb TFT display on an STM32L476 Dragonfly development board.
In the main loop it takes 56 ms to grab a 35 x 35 pixel (each pixel is 1 byte) frame but the display rate seems more like about ~2 Hz or so.
I am plotting the data on the TFT display by mapping rgb colors to intensity. Since I am using the Dragonfly with its embedded 16 MByte SPI NOR flash I could also just store the 1225 bytes of data per frame on the flash for later download. I could record ~10 minutes of video at the ~18 Hz frame rate.
In the image below the PAA3905 is pointed toward a window with my hand in the field of view (basically backlit). In addition to faster display speed, using the PAA3905 as a video camera would benefit from using an IR (830 or 940 nm) led and the led sync pin for scene illumination. I might try this next.
The PAA3905 breakout board design is available at OSH Park.
Contact PixArt for data sheet and to order the PAA3905 and appropriate lenses.