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 LCD not working on Netduino Plus 2


  • Please log in to reply
19 replies to this topic

#1 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 23 May 2013 - 07:50 AM

I am trying to get an I2C LCD working with my ND Plus 2.  This is an ongoing project that has been running successfully on an original Netduino Plus "1".

 

  • The LCD, SCL/SDA pullups (4.7k) and some other buttons, etc for my project are all part of a prototype shield
  • The shield and software works fine on my ND Plus ("1" not 2).  That is, the exact same shield, LCD and software.
  • I have jumpered the new SCL/SDA pins to A4/A5
  • I am using firmware v4.2.2.2 on the ND2 Plus

I2C.Execute is returning 0 every time it gets called.  The rest of the application appears to be running OK (just no LCD output!).  Is there something else I need to do to migrate my I2C functionality from the original ND Plus to the "2" (other than the new I2C pins, that is)

 

The LCD is a DFRobot I2C/TWI LCD1602 (like this)

 



#2 Bi Qin

Bi Qin

    Member

  • Members
  • PipPip
  • 23 posts

Posted 23 May 2013 - 09:04 AM

well,for NP2+,you should connect I2C bus to the SCL/SDA pin?not A4/A5.

A4/A5 on NP2+ is PC4/PC5 on STM32F405,if you look into the datasheet,neither of them got I2C function,you can just  use them as ADC input pin.



#3 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 24 May 2013 - 03:07 AM

Thanks for your reply, but have already jumpered the new SCL/SDA pins to A4/A5, so it should be working.



#4 Bi Qin

Bi Qin

    Member

  • Members
  • PipPip
  • 23 posts

Posted 24 May 2013 - 03:03 PM

Thanks for your reply, but have already jumpered the new SCL/SDA pins to A4/A5, so it should be working.

If possible,I would suggest you to measure the waveform of the I2C bus to see if anything abnormal.



#5 ziggurat29

ziggurat29

    Advanced Member

  • Members
  • PipPipPip
  • 244 posts

Posted 24 May 2013 - 03:51 PM

I second bi qin's suggestion of taking an actual look at the waveform.  I want to add this from my recent experience if it's  useful:

 

*  I was needing a ds1307, and put it on the special sda/scl lines.  what could be simpler, right?  well it didn't work

*  I fiddled with it for quite a while but miraculously my scope arrived later that day.  guess what -- no output whatsoever.  hmm.

*  I flashed my NP2 with firmware 4.2.1.2, and guess what?  worked perfectly.

*  I flashed back to 4.2.2.1, and it failed.  Hmm

Ultimately in my case, I had to hook my device to the a4/a5 and bitbang i2c (I have an in-between shield that does not pass through the newer pins), which also worked fine for me, and so I haven't gotten back to looking at the firmware issue.

 

so, do look at the waveform -- it might not be you.



#6 yogotie

yogotie

    Member

  • Members
  • PipPip
  • 16 posts

Posted 27 May 2013 - 03:11 AM

I found some odd issues with I2C logic in the controller used for the NP2+.  The I2C state machine in this part has a locking condition, which is stated in the datasheet and errata for this part, but without and debugger and a scope it can be hard to determine if this is the issue.  I did verified that this is in fact a real issue with the latest firmware, thanks to ziggurat29's posts about how to compile the source.

 

http://forums.netdui...c-lockup-issue/



#7 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 27 May 2013 - 01:46 PM

Thanks for your reply, but have already jumpered the new SCL/SDA pins to A4/A5, so it should be working.

Perhaps I'm missing the point here, but why are you at all bridging the I2C pins - is it because you use some kind of shield with fixed wiring?

 

If you're otherwise not using A4/A5 from your Netdino, they could easily be in a default configuration where they have a strong negative effect on the I2C data line. You could try configuring them as digital inputs and see if that helps.



#8 ziggurat29

ziggurat29

    Advanced Member

  • Members
  • PipPipPip
  • 244 posts

Posted 27 May 2013 - 02:39 PM

...The I2C state machine in this part has a locking condition, which is stated in the datasheet and errata for this part, but without and debugger and a scope it can be hard to determine if this is the issue.  I did verified that this is in fact a real issue with the latest firmware...

Mmm! thanks, yogotie, for figuring that out and reporting it, along with your change to fix it.  To bad we don't have a process by which to submit patches (or even a reliable way to get the current and historic firmware source).



#9 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 27 May 2013 - 11:29 PM

 

A4/A5... is it because you use some kind of shield with fixed wiring?

 

In a sense, yes.  I have a shield based on a arduino protoshield, which I made for use with the original netduino plus.  My application ended up running out of memory, and then right on cue, along came the plus 2.  So I am using a board that was made for the old layout.

 

 

... bi qin's suggestion of taking an actual look at the waveform

 

I don't have an oscilloscope so I cannot test anything with that.  I have decided to make a new shield and use Mario's design (here: http://tinyclr.it/th...lcd-module.aspx), which uses straightforward digital I/O on the netduino rather than I2C.  As a plus, since it uses a shift register IC, I end up with a design with an LCD that I can buy for $3 instead of a $15 I2C one.

 

If you're otherwise not using A4/A5 from your Netduino, they could easily be in a default configuration where they have a strong negative effect on the I2C data line. You could try configuring them as digital inputs and see if that helps.

 I will give that a try, as it would be good to know if it works, even though I am going to use the shift register solution. 

 

Thanks all for your suggestions.



#10 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 28 May 2013 - 12:37 AM

Yes, Mario's SPI driven LCD Boost library using s shift reg is probably the badest boy in town right now. It would be nice if you came back with a post on how that turns out for you. I've been looking to use his lib myself one of these days...

#11 iced98lx

iced98lx

    Advanced Member

  • Members
  • PipPipPip
  • 134 posts
  • LocationSouth Dakota

Posted 28 May 2013 - 02:38 AM

FYI, I got a very similar one to work, using this post: http://forums.netdui...-i2c-interface/

 

I changed up the driver ever so slightly to use NooM's i2c method, set a few things public and I can now write without a problem on my N+2 with the latest firmware. I have a couple i2c devices on the bus (the LCD and a PWM controller) but now that the LCD works the PWM doesn't appear to be working.

 

EDIT: Whichever device I call first seems to work, haven't gotten'em both working on i2c. Figures. 

 

EDIT # 2 - Seems to be a timing + voltage spike when the power supply turns on + threading issue, probably can all work together fine.



#12 Bi Qin

Bi Qin

    Member

  • Members
  • PipPip
  • 23 posts

Posted 04 June 2013 - 02:32 AM

I've got an I2C LCD recently,and it's not working either.The label on the bottom of the PCB is"YwRobot LCM1602 IIC V1".

 

But the reason is found::There is no pull up resistor For I2C Bus on the LCD module.

 

So,might there be some different on I2C design between NP1+ and NP2+?Which makes NP1+ don't need external pull up resistor.

I've try to draw the schematic for that I2C To IO board and add pull up resistor later by myself.Wait for my update.



#13 Bi Qin

Bi Qin

    Member

  • Members
  • PipPip
  • 23 posts

Posted 04 June 2013 - 03:51 AM

OK,confirmed that add 2 pull up resistors will make I2C To IO expander work.I've draw a schematic for that board for your reference.Attached File  lcm1602.pdf   93.6KB   125 downloads



#14 Bi Qin

Bi Qin

    Member

  • Members
  • PipPip
  • 23 posts

Posted 06 June 2013 - 04:47 AM

I've already make an I2C 1602 LCD working with my netduino plus2:

 

http://lifetyper.com/post/52202466954



#15 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 11 June 2013 - 05:28 AM

Thanks Qi, my original board already had pullups on the I2C lines.  I have gotten the shift register to work OK, took a little while because I had accidentally swapped the wire from the shift register MR pin & R4 (they were each connected to the wrong wire on the transistor).  Once I figured that out it worked straight away :-)

 

Here's the fritzing diagram for those who are interested.  The shift register part is 100% based on Mario's breadboard layout here.

 

The resistors on the protoshield board and accompanying headers on the stripboard are pullups for three pushbuttons used to control a menu on the LCD, so if all you are doing is making an LCD you can ignore them.

 

This layout is definitely not the best, there are a number of mistakes which I will eventually need to fix:


    [*]The LCD has a female header block soldered onto the bottom which connects to the male header block at the right-hand side, which means the contrast adjustment is underneath the LCD!  I may end up just soldering the pot to the bottom of the board on my next revision (or move it).
    [*]There are a few more wires (the yellow ones) then there needs to be, on my next revision I will try to line up the LCD control wires with Q4,5,6 on the shift register to make it a little simpler.
    [*]And of course the board is fairly widely spaced out as its a version 1, it could be a little more compact.  Hopefully I can squeeze it into a protoshield size eventually.
    [/list]

    Attached Files



#16 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 11 June 2013 - 06:17 AM

Nice work! Everybody seem to use a potentiometer for brightness and/or contrast. Why not use PWM instead? Sure, it eats two more pins but personally I find it more elegant and you could easily implement ambient light auto-compensation with a photoresistor wired to the ADC.

#17 Bernd

Bernd

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts
  • LocationGermany

Posted 16 June 2013 - 02:08 PM

I use the NP2 and the V4.2.2.2. If I get it right, I have to use a pull up resistor on both wire to the positive potential. The I2C Output is 3.3V . Can i connect the pull ups to 5V or is it still better to connect the resistors to 3.3V ? ******* I just found a thread in the board that answer my question. So i think the Outputs are in the Open Collector mode and so the high signal must generate via pull up resistors. So I can pull up to 5V. I think this must be fine

#18 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 17 June 2013 - 07:13 AM

RE PWM: Wouldn't PWM only supply up to 3.3v?  So you could only set the contrast from 0-3.3V instead of the full range 0-5V?



#19 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 17 June 2013 - 11:16 AM

Yes, brightness will be slightly dimmer than it would with 5V but it's still bright enough. Contrast is "active low" so no problem there.



#20 gabesilva

gabesilva

    New Member

  • Members
  • Pip
  • 3 posts

Posted 20 June 2013 - 06:23 AM

I just got ND+2 and SainSmart IIC/I2C/TWI Serial 2004 LCD but am having problems getting it to work. My wiring diagram between the LCD and ND+2 is pretty simple: Vcc -> 5V, Gnd -> Gnd, SDA -> SD and SCA -> SC. I did not tie the A4 and A5 pins though. Do I have to do that? Also do I need pullup resistors for the SDA and SCA connections? I use the LCD library from http://microliquidcr...l.codeplex.com/ but no luck. If anyone has successfully get the ND+2 and said LCD to work, please help me by sending your wiring diagram and sample code with the library that you use. Many thanks.






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.