Home
ARMexpress drives Serial LCD
Contents
1. ARMexpress drives Serial LCD Dr Claus K hnel ARMexpress supports several serial interfaces Using serial interfaces to peripheral devices helps in cases of low pin count microcontrollers This article describes writing data to a LCD using the I C interface 1 PC Bus The I C bus was developed for data exchange between different devices as EEPROMs RAMs AD and DA converts RTCs and microcontrollers in a networked environment Figure 1 shows all required connections in a typical I C bus network The lines SDA and SCL connect all members of the network PullUp resistors connect these lines to the supply voltage Vcc and guarantees the Hi level Vee O Figure 1 IC Bus Network In an I C bus network several masters can be connected with several slaves Multi Master System The I C bus protocol addresses the members of the network The peripheral functions depend on the specific device Beside EEPROMs and RAMs from numerous manufacturers there are a lot of further I C bus devices as I O expander and LCD and LED driver devices etc I2C LCD doc 2006 08 13 Page1 von 10 1 1 Some Basics For an interface built by such simple hardware the software protocol must secure the communication Figure 2 shows the protocol for writing and reading of one byte There are further functions as sequential write and read We will concentrate us to the basic functions only Byte Write Random Read Slave Address Word Address Slave A
2. Purpose Character Output on LTED204T DY Macrin Orbital Author Claus Kuhnel 1 SEGCESCl as Z2OWG Ce 12 Updated r This program explains using the I2COUT instruction for writing data to an I2C driven text LCD LCD2041 from Matrix Orbital was used For detailed description of LCD2041 read the LCD2041 user manual Look at www matrixorbital ca manuals LCDVFD series LCD2041 CONST wraddrLCD 5C CONST Instr 254 CONST Autoscrollon 81 CONST Autoscrolloff 82 CONST Setcursor 71 es I CONST Cursorhome 72 I2C LCD doc 2006 08 13 Page6 von 10 I2C LCD doc 2006 08 13 Page7 von 10 I2C LCD doc 2006 08 13 Page8 von 10 I2COUT DataPin wraddrLCD For I 1 To 20 y bw Be Jaw f 20 I2COUT DataPin wraddr wait 10 Next i I2COUT DataPin wraddrl txt Bargraph tl len txt I2COUT DataPin wraddrl wait 3000 SEIN HBargraph I2COUT DataPin wraddrl DataPin wraddrl DataPin wraddrLC I2COUT DataPin wraddr DataPin wraddrl I2COUT DataPin wraddrl I2COUT DataPin wraddr txt Bargraph I2COUT I2COUT d I2COUT tl len txt I2COU1 wait 3000 return Listing LCD Demo I2C_LCD BAS Bessere re oo af Se Se a SS DataPin wraddrl Lastr Pensite I insiese txts yeli masice Emoen Linsey ete STS ister INSEE MSE IE nsien jes VELI Initwvbargraph Drawvbargraph Cursorhome Cleardi
3. bar graphs to be displayed on the screen Text fonts are built in and use standard ASCII mapping Provision is made for up to 8 user defined characters The screen is backlit for low light situations Backlighting may be turned on or off under program control Contrast is adjustable to compensate for differing lighting conditions and viewing angles A general purpose output allows the controller to switch an electronic or electro mechanical device by issuing commands to the display unit This can be used for controlling LEDs relays etc I2C LCD doc 2006 08 13 Page3 von 10 The LCD2041 supports RS 232 and I C bus interface Due to the possibility of networking we use here the I C bus interface Up to 16 LCD2041 modules can be connected on the same I C bus interface The slave address can be configured by jumpers J4 J1 on the LCD2041 module according to Table 1 Slave Address 50 Out Out Out Out 52 Out Out Out In 54 Out Out In Out 56 Out Out In In 58 Out In Out Out 5A Out In Out In 5C Out In In Out 5E Out In In In 60 In Out Out Out 62 In Out Out In 64 In Out In Out 66 In Out In In 68 In In Out Out 6A In In Out In 6C In In In Out 6E In In In In Table 1 Configuration of Slave Address In Table 1 the configuration used in the program sample following is coloured Table 2 shows the commands for programming the LCD2041 COMMAND Auto lin
4. ddress Data Byte Figure 2 Writing and Reading of one Byte For data exchange between I C bus devices the master starts data exchange with a start condition S followed by an address byte containing the slave address The structure of the slave address byte for a PCF8591 device as example is B7 B6 B5 B4 B3 B2 B1 BO 1 0 0 1 A2 A1 AO R W The bits Bit7 B4 characterize the I C devices The bits B3 to B1 are address selectors sub addresses and BitO defines read BO 1 or write BO 0 operation Due to this addressing structure it is possible to connect eight PCF8591 devices in one I C bus network beside other I C bus devices The individual byte sent by the master will be acknowledged A from the addressed I C bus device to the master signalizing an error free data exchange After the slave address a word address follows This word address points to a register of the addressed I C bus device The data byte will be saved into this register or will be read from this register The data exchange will be finished by a stop condition P The start and stop conditions mentioned a characterized by a certain phase layer of the signals SCL and SDA Figure 3 explains the details i i Bm ICS kl I e TZN A i START STOP Figure 3 Start amp Stop Condition 12C LCD doc 2006 08 13 Page2 von 10 1 2 ARMexpress I C Support It is possible to organize data exchange between I C bus devices by bit banging the SCL and SDA l
5. e wrap on Auto line wrap off Auto scroll on Auto scroll off Set cursor position 4 254 67 254 68 254 81 254 82 254 71 col row NOTE Enables line wrapping not word wrap Disables line wrapping Enables scroll at bottom of screen Text will push display up one line to make room for new line Disables auto scroll Text will wrap to top left and overwrite existing text Moves cursor to the specified column and row The cursor marks the text insertion point in this and all commands This command moves the cursor to the top left Send cursor home 254 82 i of the display area Underline cursoron 254 74 Turns on the underline cursor Underline cursor off 254 75 Turns off the underline cursor Block cursor on 254 83 Turns on the blinking block cursor Block cursor off 254 84 Turns off the blinking block cursor Moves the cursor one position to the left If the cursor is Cursor left 254 76 already at the beginning of a line it will move to the end of the other line I2C LCD doc 2006 08 13 Page4 von 10 COMMAND BYTES Cursor right 254 77 Initialize thick vertical 254 118 bar graph Initialize thin vertical 254 115 bar graph Initialize horizontal 254 104 bar graph 254 61 Draw vertical bar graph col length 254 124 Draw horizontal bar c r d length graph Initialize large digits 254 110 Place large digits 254 35 col digit Define custom 254 78 c 8 bytes character Clear di
6. ines For BASIC Stamp microcontrollers BS1 and BS2 we had examples we had examples in 1 and 2 This way is possible for ARMexpress too But there are special instructions that hide all the details as start and stop condition the acknowledge bit and changing data direction of SDA line for the programmer For a write access to an I C bus device we can use the instruction I2COUT I2COUT Data pin slaveADDR OutputList Data pin defines the I O pin used for SDA line For SCL we have to use the I O pin Data pin 1 definitely The slave address selects the I C bus device for the following read or write access For a read access to an I C bus device we can use the instruction I2CIN I2CIN Data pin slaveADDR opt1 opt5 InputList Before reading data from accessed I2C bus device into the InputList it is possible to send out up to five optional byte values The I2C bus is byte oriented so each transaction will either send a byte value 0 to 255 or receive a byte to from an I2C bus device If a value in the OutputList is larger than 8 bits the MSBs will be truncated Data is shifted out and in at 380 kbits sec The program sample describing the use of an I C bus driven LCD shows the use of instruction I2COUT in detail 2 Character Display LCD2041 Matrix Orbital as manufacturer of the LCD2041 designed it as a display unit for an associated controller The LCD2041 provides a simple command structure to allow text and
7. ompensates for viewing angle Contrast is a value between 0 and 255 hex 0 to FF Larger darker Backlight will stay on for minutes If minutes 0 backlight will stay on permanently Turns off backlight Sets display brightness Brightness is a value between 0 and 255 hex 0 to FF Larger brighter Turns the general purpose output OFF Turns the general purpose output ON Table 2 LCD2041 Commands I2C LCD doc 2006 08 13 Page5 von 10 3 Program Sample I2C_LCD BAS The program sample listed in the next chapter explains using the I2COUT instruction for writing data to an I C driven text LCD LCD2041 from Matrix Orbital was used For detailed description of LCD2041 read the LCD2041 user manual The program samples shows some features of the LCD2041 as e Output of text messages e Output of big digits in combination with normal text e Speedometer display Medienclip e Wide Vertical Bargraph e Horizontal Bargraph Double click the media clip button on the right and you can see a short video clip of the display output The video clips shows an ARMexpress module placed on an old BS2p demo board and the connected LCD2041 with its changing display content think there are no further hints needed Have a look to the source code of I2C_LCD BAS and refer the commands and its parameters to Table 2 4 Source code 12 Title 1 T PLleooncos 12e leches US
8. splay Inithbargraph Drawhbargraph Drawhbargraph Drawhbargraph Drawhbargraph BPR BwWNE Sa 55 Sees oo fs aa oS SG S 100 Sal za 133 The source code listed here can be downloaded from ARMexpress User Group or author s homepage 5 Links Manuals for LCD2041 Coridium Homepage ARMexpress User Group Author s Homepage I2C LCD doc 2006 08 13 http www matrixorbital ca manuals LCDVFD_series LCD2041 http www coridiumcorp com http groups yahoo com group ARMexpress http www ckuehnel ch Page9 von 10 6 Literature 1 Kuhnel C Zahnert K BASIC Stamp 2p Commands Features and Projects Parallax Rocklin CA 2003 ISBN 1 928982 19 0 2 Kuhnel C Zahnert K BASIC Stamp 2 Ed Newnes Boston et al 2000 ISBN 0 7506 7245 5 I2C LCD doc 2006 08 13 Page10 von 10
9. splay a Set contrast 254 80 contrast Backlight on 254 66 minutes Backlight off 254 70 254 153 Set Brightness brightness General purpose output off 254 86 General purpose 254 87 output on NOTE Moves the cursor one position to the right If the cursor is already at the end of a line it will move to the beginning of the other line Initializes the user character set to make wide vertical bar graphs Initializes the user character set to make narrow vertical bar graphs Initializes the user character set to make horizontal bar graphs Draws a vertical bar graph at column col of length length Length is measured in pixels 0x00 to 0x20 User must first use the v or s command to initialize characters Draws a horizontal bar graph starting at column c on row r with direction d 0 is right 1 is left of length length Length is measured in pixels 0x00 to 0x64 if starting in column 1 User must first use the h command to initialize characters Initializes the user character set to make large digits Place large digit number digit in column col of the display Cursor moves to bottom right of large digit digit is 0x00 to 0x09 col is 0x01 to 0x12 i e 1 to 18 decimal Defines one of 8 custom user characters Character number is c between 0x00 and 0x07 The 8 bytes are described in section 4 1 8 Clears screen of text and graphics places text cursor at top left Sets display contrast C
Download Pdf Manuals
Related Search
Related Contents
Torniquete Inner Plus user manual - Institute of Bioinformatics Telular SX5D GSM User's Manual Samsung Mustavalkolasertulostin M3325ND Käyttöopas MJ-906S SUNRISE ミニジブ 取扱説明書 Bijoux en béton Puritan Bennett pdf, Job 152 Copyright © All rights reserved.
Failed to retrieve file