Optical Finger Navigation (OFN) Module [DISCONTINUED]
NOTE: This product is currently discontinued. We leave the documentation page for reference but we no longer manufacture or sell this product.
The Optical Finger Navigation (OFN) Module can add a unique human interface component to your Microcontrller projects. OFN Modules are quickly becoming popular as user input devices in many smart phones as a replacement for trackballs, which are subject to mechanical wear and tear.
OFN technology is very similar to the technology used in optical mice, and movement across the sensor can be read by any microcontroller using I2C communication.
- Built-in center select button
- Onboard red LED which lights when finger movement is detected
- Easy I2C communication interface with virtually any microcontroller
- Onboard voltage regulator conditions I/O to 3 V max for compatibility with 3.3 V devices even when 5.5 V is supplied to Vdd
- User-selectable 500 or 1000 counts per inch (cpi)resolution
- User-definable 0 or 90° module orientation
- Breadboard-friendly package with 0.1” pin spacing
- Power requirements: 3.3-5.5 VDC; 25 mA active, 1 mA standby
- Communication: Two-Wire Serial I2C (400 kHz)
- Operating temp range: 32 to 158 °F (0 to 70 °C)
- Dimensions: 1.0 x 1.0 x 0.55 in (25.4 x 25.4 x 13.97 mm)
- Video game input
- Mouse replacement
- User input for computing devices
The instructions that follow outline how to wire and test that your OFN Module is operating correctly when used with the BASIC Stamp 2 and Propeller microcontrollers. The simple test code provided will read the product ID and display it on a serial terminal.
NOTE: Before using your OFN module, be sure to remove the plastic film placed over the optical sensor to allow the device to function properly.
For use with the example programs included on the OFN Module product page and in the test programs included below.
Resources and downloads
BASIC Stamp 2 Test Code
This is a simple program designed to test serial communication between the BASIC Stamp 2 and the OFN Module. If working properly, the OFN Module should return $83 (the product ID). This program uses the Debug Terminal, which is built into the BASIC Stamp Editor software.
BASIC Stamp® Example Code
Also included on the OFN Module page is demo code to display movement along the surface of the OFN Module on the Debug Terminal. Figure 5 below shows the expected display on the Debug Terminal and the proper hardware orientation on a BASIC Stamp HomeWork Board.
Propeller P8X32A Test Code
This is a simple program designed to test serial communication between the Propeller P8X32A and the OFN Module. If working properly, the OFN Module should return $83 (the product ID).
Note: This application uses the I2C.spin object, zipped in the OFNModule_PropellerDemo included on the OFN Module product page. It also uses the Parallax Serial Terminal to display the device output. The PST.spin object and the Parallax Serial Terminal itself are included with the with the Propeller Tool v1.2.7 or higher, which is available from the below link.
Propeller™ P8X32A Example Code
Also included on the OFN Module page is demo code to display movement along the surface of the OFN Module on the Parallax Serial Terminal. Figure 6 below shows the expected display on the Parallax Serial Terminal and the proper hardware orientation on a Propeller Demo Board.
Theory of Operation
Optical Finger Navigation (OFN) Technology is very similar to the technology used for optical mice. When a finger moves across the surface of the OFN Module, an onboard LED is activated to light up the surface of the finger. The onboard Image Acquisition System then obtains microscopic images of the finger surface, and those images are processed by the Digital Signal Processor.
The Digital Signal Processor then mathematically determines the direction and magnitude of the finger’s movement and calculates the delta-x and delta-y relative displacement values. A microcontroller can then read these values using simple I2C communication. A block diagram of the OFN sensor can be seen in Figure 2, and an I2C timing diagram can be found in Figure 3.
Note that the OFN Module contains an onboard voltage regulator which conditions I/O to 3 V max, making the OFN module compatible with 3.3 V devices even when 5.5 V is supplied to Vdd.
|1,2||GND||G||Ground -> 0V|
|3,4||Vdd||P||Supply Voltage -> 3.3 – 5.5 VDC|
|6||DO+||O||Switch, Active Low|
|8||CLK||I||Serial Clock Input (400 kHz)|
|9||SDA||I/O||Serial Data Line|
Pin Type: P = Power, G = Ground, I = Input, O = Output
Communicating with the OFN Module is done through an I2C interface. A write operation is defined as data going from a microcontroller to the OFN Module, and a read operation is defined as data going from the OFN Module to a microcontroller. Below is a table of the most commonly used registers and their default values.
Writing Data to OFN Sensor Registers
Certain Register Addresses allow for the configuration of certain aspects of the OFN Module, which require specific values to be written to that address. A detailed listing of selected configuration options is included below.
Register Address 0x02: Motion
Data Type: Bit field Usage: Allows the user to determine if motion has occurred since the last time it was read. If the MOT bit is set, then the user should read registers 0x03 and 0x04 to get the accumulated motion. Read this register before reading the Delta_Y and Delta_X registers.
Writing anything to this register clears the MOT and OVF bits, Delta_Y and Delta_X registers. The written data byte is not saved.
Internal buffers can accumulate more than eight bits of motion for X or Y. If either of the internal buffers overflows, then absolute path data is lost and the OVF bit is set. This bit is cleared once motion has been read from the Delta_X and Delta_Y registers, and if the buffers are not at full scale. Since more data is present in the buffers, the cycle of reading the Motion, Delta_X and Delta_Y registers should be repeated until the motion bit (MOT) is cleared. Until MOT is cleared, either the Delta_X or Delta_Y registers will read either positive or negative full scale. If the motion register has not been read for long time, at 500 cpi it may take up to 16 read cycles to clear the buffers, at 1000 cpi, up to 32 cycles. To clear an overflow, write anything to this register.
|MOT||Motion since last report
0 = No motion
1 = Motion occurred, ready to read Delta_X & Delta_Y
|OVF||Motion overflow, ΔY and/or ΔX buffer has overflowed
0 = No overflow
1 = Overflow has occured
|PIXFIRST||Reports GPIO status (read only)
0 = Low
1 = High
Register Address 0x11: Configuration_Bits
Data Type: Bit field
Usage: Selectable 500 or 1000 cpi resolution
0 = 500
1 = 1000
Register Address 0x77: OFN_Orientation_CRTL
Data Type: Bit field
Usage: Sets sensor orientation control
|XY_SWAP||0 = Normal sensor reporting of DX, DY (default)
1 = Swap data of DX to DY and DY to DX
|Y_INV||0 = Normal sensor reporting of DY (default)
1 = Invert data of DY only
|X_INV||0 = Normal sensor reporting of DX (default)
1 = Invert data of DX only
|ORIENT1:0||Read only bits of orientation pin
0x00 = Mounted 90° clockwise (orient pin low)
0x01 = Mounted 0° (default, orient pin is high)
== Module Orientation ==
Figure 4 below demonstrates the proper orientation of the OFN Module for use with the example programs included the next sections.