Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

I2C/TWI LCD1602


  • Please log in to reply
6 replies to this topic

#1 PeterB

PeterB

    Member

  • Members
  • PipPip
  • 17 posts
  • LocationSydney, Australia

Posted 26 January 2011 - 12:13 AM

I have a DFRobot I2C LCD display that I can easily drive with the Arduino (a library is available). I have no idea of how or where to start to make something similar for the Netduino.

I have the I2CBus code and now I need to work out how the I2C bus works before I can attempt to build a driver for the display module.

Looking for any suggestions about how I should tackle the problem.

Thanks,

#2 phantomtypist

phantomtypist

    Advanced Member

  • Members
  • PipPipPip
  • 142 posts
  • LocationNew York, NY

Posted 26 January 2011 - 03:40 AM

http://microliquidcr...l.codeplex.com/

#3 PeterB

PeterB

    Member

  • Members
  • PipPip
  • 17 posts
  • LocationSydney, Australia

Posted 26 January 2011 - 12:24 PM

http://microliquidcr...l.codeplex.com/


Thanks for the link.

I downloaded the zip file and was able to run the HelloWorld_I2C solution. Running as per the download didn't work, that is it just ran to completion and no display. So I then changed the address to 0x27 (as per the DFRobot) and at that point it threw an exception in the I2CBus WriteRead function included below.

public void WriteRead(I2CDevice.Configuration Config, byte[] WriteBuffer, byte[] ReadBuffer, int TimeOut)
        {
            ThrowIfDisposed();
            lock(this.Device)
            {
                this.Device.Config = Config;
                I2CDevice.I2CTransaction[] xacts = new I2CDevice.I2CTransaction[] {
                    I2CDevice.CreateWriteTransaction(WriteBuffer),
                    I2CDevice.CreateReadTransaction(ReadBuffer)
                };

                // I2CDevice.Execute returns the total number of bytes
                // transfered in BOTH directions for all transactions
                int byteCount = this.Device.Execute(xacts, TimeOut);
                if(byteCount < (WriteBuffer.Length + ReadBuffer.Length))
                    throw new System.IO.IOException();
            }
        }

I am well and truly out of my comfort zone with this, it is very low level and I just don't have the wherewithall to understand this at present.

Looking at the local variables I can see that bytecount is 1 and the length of the WriteBuffer and ReadBuffer is 1 each so a total of 2, which is why it throws the exception. I have no idea as to what is really going on.

Before somebody suggest it, I have put pull-up resistors on the I2C bus (4k7).

Any further suggestions greatly appreciated (including suitable books as I am new to C#, .NET and uC).

Thanks

#4 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 09 July 2011 - 09:36 AM

Did you have any luck with this? I am in the same situation as you.

#5 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 13 July 2011 - 01:20 PM

Just a followup, I solved my problem (same as the original poster) by including 4.7k pull-up resistors on sca and scl. Or, more to the point, wiring them in correctly.

#6 travisbeard

travisbeard

    New Member

  • Members
  • Pip
  • 4 posts

Posted 19 June 2012 - 01:34 PM

Thanks for the link.

I downloaded the zip file and was able to run the HelloWorld_I2C solution. Running as per the download didn't work, that is it just ran to completion and no display. So I then changed the address to 0x27 (as per the DFRobot) and at that point it threw an exception in the I2CBus WriteRead function included below.

public void WriteRead(I2CDevice.Configuration Config, byte[] WriteBuffer, byte[] ReadBuffer, int TimeOut)
        {
            ThrowIfDisposed();
            lock(this.Device)
            {
                this.Device.Config = Config;
                I2CDevice.I2CTransaction[] xacts = new I2CDevice.I2CTransaction[] {
                    I2CDevice.CreateWriteTransaction(WriteBuffer),
                    I2CDevice.CreateReadTransaction(ReadBuffer)
                };

                // I2CDevice.Execute returns the total number of bytes
                // transfered in BOTH directions for all transactions
                int byteCount = this.Device.Execute(xacts, TimeOut);
                if(byteCount < (WriteBuffer.Length + ReadBuffer.Length))
                    throw new System.IO.IOException();
            }
        }

I am well and truly out of my comfort zone with this, it is very low level and I just don't have the wherewithall to understand this at present.

Looking at the local variables I can see that bytecount is 1 and the length of the WriteBuffer and ReadBuffer is 1 each so a total of 2, which is why it throws the exception. I have no idea as to what is really going on.

Before somebody suggest it, I have put pull-up resistors on the I2C bus (4k7).

Any further suggestions greatly appreciated (including suitable books as I am new to C#, .NET and uC).

Thanks


Did you ever get this to work?

#7 travisbeard

travisbeard

    New Member

  • Members
  • Pip
  • 4 posts

Posted 19 June 2012 - 01:35 PM

Just a followup, I solved my problem (same as the original poster) by including 4.7k pull-up resistors on sca and scl. Or, more to the point, wiring them in correctly.

Where did you change the address?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.