Shop OBEX P1 Docs P2 Docs Learn Events
Need Help getting started with "MODTRONICS LCD2S-162YhY" - I2C LCD Display — Parallax Forums

Need Help getting started with "MODTRONICS LCD2S-162YhY" - I2C LCD Display

DavidMDavidM Posts: 626
edited 2008-04-06 12:41 in Propeller 1
HI,

I have an 2 x 16 LCD which can be controller via I2C.

I have it hooked up to the prop via ( with pullups on both lines 10K each)

SDA = pin 28
SCL = pin 29

It runs off 5V.

the LCD is from MODTRONICS ( in Australia ) http://www.modtronix.com.au , model no LCD2S-162YHY

www.modtronix.com.au/product_info.php?currency=AUD&cPath=96_137&products_id=266&osCsid=fea8cc75370a45582690f9113ab1aa4e

the documentation is here..
www.modtronix.com.au/products/lcd2s/lcd2sr1_v120.pdf
It powers up ( the LCD that is ) and I have communications with the prop for the rest of my circuit working , but now I just want to test out the LCD.

I am using i2cObject.spin V1.3 by James Burrows

The LCD device address is $51 for writing commands

the first command I want to test out is setting the startup screen which is command address $90

It expects the next parameter to be the lcd line ( in my case its a 2 x 16 display so I use $1
It then expects a string up to 16 characters so that can be displayed on the LCD, but I can't get this to work or figured out.

Heres what I have tried so far..


i2c.init ( SDAPin , SCLPin, True )
i2c.writelocation ( $51, $90 , $1 , "MY LINE ONE TEXT" , 8 , 8 )


but nothing happens?? I don't believe the "writelocation" command will allow for a string to be used!

can anyone please advise

The info for I2c for the LCD starts on Page 10 of the manual

regards


Dave M

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2008-04-06 10:23
    hello David,

    as a general advice: if a complex command like

    ( $51, $90 , $1 , "MY LINE ONE TEXT" , 8 , 8 )

    does not work go back to a more simple example.

    Did you try the example in chapter 10.3 Writing to the LCD2S

    it sends just one byte for the command Backlight On

    Next step could by to send some hex-values instead of a string

    if you take a look onto the methob i2cwritelocation

    the first parameter is the deviceadress
    second parameter is the deviceREGISTER

    in the example chapter 10.3 there seems to be no deviceREGISTER
    after the deviceadress you start directly with the command

    if i try to compile your example writelocation ( $51, $90 , $1 , "MY LINE ONE TEXT" , 8 , 8 )
    i get the error expected ")" after the "M"

    further on the writelocation-command takes

    the "$51" as device adress
    the "$90" as the device-register
    the ,"$1" as the datavalue
    the "M" as the number of adressbits

    for this example i guess for a first try you have to call something like

    i2c.i2cStart
    i2c.i2cWrite($50,8)
    i2c.i2cWrite($28,8)
    i2c.i2cStop

    this example will not check for ACK or NAK in the acknowledge-bit


    question to all that know more about i2C:

    what value should the deviceREGISTER-parameter have in this case

    here the description of the example

    10.3 Writing to the LCD2S
    Writing a command to the LCD2S via I2C follows the standard I2C format for doing a byte write. It is initiated with an I2C start
    condition. The I2C Start condition will reset the internal command state machine of the LCD2S. The next byte received will be
    seen as the first byte of a new command. The current command is ended as soon as a stop condition is detected. To send any of the
    commands listed in the commands section of this document, it has to be preceded by a start condition and the device address. For
    example, to send a “Backlight On” command to a LCD2S with an I2C write address of 0x50 (both DIP switches set to off), the
    following bytes have to be sent:
    [noparse][[/noparse]I2C Start Condition] [noparse][[/noparse]0x50 byte] [noparse][[/noparse]0x28 byte] [noparse][[/noparse]I2C Stop Condition]



    i guess the writepage-command will be more useful than the writelocation

    with the writepage-command you can pass a "pointer to an array" that contents the charactercodes of the string you want to send to the LCD

    best regards

    Stefan
  • DavidMDavidM Posts: 626
    edited 2008-04-06 11:14
    Hi StfanL38,

    Thanks for your detailed reply,

    While I was waiting I did try a simpler command , The one you mentioned in fact, It did not work at first, But I think I had a constant for my pin definitions wrong, So I changed it and I got a command to work ( this was accidental)

    So far this works

    I2c.WriteLocation ($51, $28, 0, 8, 8)


    I think for outputting strings to the LCD I have to write my own method..

    Like..

    LCDWriteString (DeviceAddress, Command, "String",8,8) or similar

    Anyhow, I have it working ( at least I know its communicating with the prop, which is a very good start.


    Thanks

    Dave M
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-04-06 12:41
    You need at least to use the str modifier:
    LCDWriteString (DeviceAddress, Command, str("String"),8,8)

    regards peter
Sign In or Register to comment.