Web Site: www.parallax.com
Forums: forums.parallax.com
Sales: sales@parallax.com
Technical: support@parallax.com
Office: (916) 624-8333
Fax: (916) 624-8003
Sales: (888) 512-1024
Tech Support: (888) 997-8267
OFN Module (#27903)
The Optical Finger Navigation (OFN) Module can add a unique human interface component to your BASIC
Stamp or Propeller 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 I
2
C communication.
Features
Built-in center select button
Onboard red LED which lights when finger
movement is detected
Easy I
2
C 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
Key Specifications
Power Requirements: 3.3-5.5 VDC; 25 mA active, 1 mA standby
Communication: Two-Wire Serial I
2
C (400 kHz)
Operating temperature: 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)
Application Ideas
Video game input
Mouse replacement
User input for computing devices
Quick-Start Guide
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.
Copyright © Parallax Inc.
OFN Module (#27903)
v1.1 1/14/2011 Page 1 of 9
Quick-Start Circuit
For use with the example programs included on the OFN Module product page and in the test programs
included below.
* Vdd = 3.3V–5.5 VDC
Figure 1: OFN Module connection diagram
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. The software is a free download
from
www.parallax.com/basicstampsoftware.
' OFNModule_Simple.bs2
' Tests serial communication between BS2 and OFN Module.
' {$STAMP BS2}
' {$PBASIC 2.5}
SDA
CLK
ID
I2CAck
INPUT SDA
PIN
PIN
VAR
VAR
1
2
Byte
Bit
' Serial Data IO
' Serial Clock
' Variable space for Product ID
' Acknowledge bit
' I2C Start Condition
Copyright © Parallax Inc.
OFN Module (#27903)
v1.1 1/14/2011 Page 2 of 9
INPUT CLK
LOW
SDA
SHIFTOUT SDA, CLK, MSBFIRST, [%01100110]
SHIFTIN SDA, CLK, MSBPRE, [I2CAck\1]
SHIFTOUT SDA, CLK, MSBFIRST, [0]
SHIFTIN SDA, CLK, MSBPRE, [I2CAck\1]
INPUT SDA
INPUT CLK
LOW
SDA
SHIFTOUT SDA, CLK, MSBFIRST, [%01100111]
SHIFTIN SDA, CLK, MSBPRE, [I2CAck\1]
SHIFTIN SDA,CLK,MSBPRE,[ID\8]
SHIFTOUT SDA,CLK,MSBPRE,[1]
LOW
SDA
INPUT CLK
INPUT SDA
DEBUG "Product ID (Hex): ", HEX ID
END
' Set to write serial data
' Send address 0 to read Product ID
' I2C Start Condition
' Set to read serial data
' Get Product ID
' I2C Stop Condition
' Display Product ID (default 83)
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 Downloads link at
www.parallax.com/Propeller.
{{ OFNModule_Simple.spin:
Tests serial communication between Propeller P8X32A and OFN Module. }}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
Debug : "Parallax Serial Terminal"
I2C : "I2C"
PUB Main : ID
Debug.start(57600)
waitcnt(clkfreq/100 + cnt)
Debug.Clear
WriteRegister($00)
ID := ReadRegister
' Start PST & set Baudrate as 57600
' Wait for PST to start up
' Clear the screen
' Write operation to obtain Product ID
' Retrieve Product ID
debug.str(string("Product ID (Hex): ")) ' Display Product ID as hexadecimal value
debug.hex(ID, 2)
Copyright © Parallax Inc.
OFN Module (#27903)
v1.1 1/14/2011 Page 3 of 9
PUB WriteRegister(RegisterAddress)
I2C.DeviceStart
I2C.SendOut(%01100110)
I2C.SendOut(RegisterAddress)
PUB ReadRegister : RData
I2C.DeviceStart
I2C.SendOut(%01100111)
RData := I2C.Receive_NAck
I2C.DeviceStop
'
'
'
'
Start Condition
Read operation
Read data - no acknowledge
Stop Condition
' Start Condition
' Write operation
' Write register address
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 I
2
C communication. A block diagram of the OFN sensor can be seen in
Figure 2, and an I
2
C timing diagram can be found in Figure 3.
Figure 2: Optical Finger Navigation Senor Block Diagram
Copyright © Parallax Inc.
OFN Module (#27903)
v1.1 1/14/2011 Page 4 of 9
Figure 3: I
2
C Timing Diagram
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.
Pin Definitions and Ratings
Pin
1,2
3,4
5
6
7
8
9
10
Name
GND
Vdd
MOT
DO+
SHD
CLK
SDA
RST
Type
G
P
I/O
O
I
I
I/O
I
Function
Ground -> 0V
Supply Voltage -> 3.3 – 5.5 VDC
Motion Detect
Switch, Active Low
Shutdown
Serial Clock Input (400 kHz)
Serial Data Line
Hardware Reset
Pin Type: P = Power, G = Ground, I = Input, O = Output
Copyright © Parallax Inc.
OFN Module (#27903)
v1.1 1/14/2011 Page 5 of 9