Connecting Robot Electronics modules to the Propeller (PropSTICK) using the I2C Bus
Introduction
This example shows how to connect the LCD03 module to the Propeller, and
provides the source code for other modules at the bottom of the page. The LCD03 is used in I2C
mode, I2C mode is selected by removing the link on the
2 pin header on the LCD03 module. The PropSTICK we used also provides a
regulator for the 3.3V required by the Propeller and an RS232 interface to the
PC. A schematic of the PropSTICK is available here: PropStick-v1.2.pdf
Circuit Schematic for connecting the PropSTICK to the I2C bus
Diagram shows How to connect the PropSTICK for
use with The I2C examples on this page. Note 5V supplied to the
PropSTICK is regulated to 3.3V for the Propeller chip by a regulator
mounted underneath the chip.
The I2C example uses the pull up resistors for positive output by setting the tri-states to input, the only output that is needed from the propeller is to pull down the voltage to ground. |
Software for Propeller
The following code is for the Propeller to control an LCD03 and requires the below
functions from our simplified i2cObject.spin
Init (SDA line, SCL line) - sets up the SCL and SDA pins
readLocation( address, register, data ) - READ from a single specified register
writeLocation( address, register, data ) - WRITE to a single specified register
'******************************************************** '* Controlling The LCD03 using the Parallax Propeller * '* Written by C Clarke * '* 16/02/2007 * '******************************************************** con _clkfreq = 5_000_000 '5mhz xtal _CLKMODE = xtal1 + pll16x 'phase lock loop to multiply clock to 80mhz (5mhz*16) i2cSCLLine = 13 'SCL is on Propeller pin A13 i2cSDALine = 12 'SDA is on Propeller pin A12 LCD03_Addr = $c6 'LCD03 address (default) at 0xC6 LCD03_CMD_REG = 0 LCD03_KEYL_REG = 1 LCD03_KEYH_REG = 2 LCD03_VER_REG = 3 OBJ i2cObject : "i2cObject" 'include the I2C handler Num : "numbers" 'number handler allows keypad states to be formatted as ascii text string 'note numbers is an object file included in installation directory var byte version,keyl,keyh,length
|
Examples available for download
i2cobject.spin
- control any Devantech I2C module from your propeller using these functions
lcd03.spin
- the example above available as a .spin file
md23simple.spin - a simple
program that reads the md23 encoders and reverses the motors after a count is
reached
md23.spin
- an example of a md23 and a lcd03 on the i2c bus
srf08.spin
- displays range and light sensor data from an srf08