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

Netduino Plus 2 I2C Issues


  • Please log in to reply
11 replies to this topic

#1 mobilegamer999

mobilegamer999

    Member

  • Members
  • PipPip
  • 12 posts

Posted 09 January 2013 - 03:44 AM

Hello, I have a netduino plus 2, and I have been trying to get the I2C working for the past little white, with no success :(.

As it stands, I have very simple code (copied below), and a scope hooked up to the I2C lines.

My netduino is fully upgraded 4.2.1.2 and I have the correct pull-up resistors on the I2C lines, but the pins never change state, they always stay at 3.3v, or 0v with no pullups.

As far as software goes, it appears that the writes are timing out, because when putting a timeout of 1000ms, the function takes one second before it attempts to execute again.

 

Here is my current code.

 

I2CDevice.Configuration accelConfig = new I2CDevice.Configuration(0x53, 50);byte[] data = new byte[6];I2CDevice.I2CTransaction[] ReadAccel;ReadAccel = new I2CDevice.I2CTransaction[]{     I2CDevice.CreateWriteTransaction(new byte[]{0x30}),     I2CDevice.CreateReadTransaction(data)};I2CDevice accel = new I2CDevice(accelConfig);while(true){     int read1 = accel.Execute(new I2CDevice.I2CTransaction[] { ReadAccel[0] }, 1000);}

 

 



#2 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 09 January 2013 - 04:45 AM

MobileGamer,

 

Welcome to the forum,

 

Which connections are you making to the board? A4 & A5 or the new connections SC & SD? The 2 analog connection are not currently used for I2C.

 

Chuck



#3 Alex W

Alex W

    Member

  • Members
  • PipPip
  • 16 posts

Posted 09 January 2013 - 05:48 AM

Also, what device are you testing against?  Are you sure that you have the correct address for it?



#4 jrc903

jrc903

    New Member

  • Members
  • Pip
  • 5 posts

Posted 09 January 2013 - 06:55 PM

Hello to you all.

 

LIke MobleGamer999, i just purchased a netduino 2 plus. I decided to try to get I2c connections to a working LM75 temperature sensor.

Got a working ardiunio card next to the new card, and  simply moved the wiires from one to the other in the same relative locations on the two boards.--plus i installed 3.3k pullup resistors.

 

I added a tiny bit of code to my Main in program.

 

my goal here was to try to do a read of two bytes of temperature data, after writing a 9  to the pointer register of this device. I may not have the exact command structure worked out but figured i would get something back.

 

  byte[] buffer = new byte[10];   I2CDevice.Configuration config = new I2CDevice.Configuration(0x90>>1, 50);   I2CDevice dev = new I2CDevice(config);

 

  I2CDevice.I2CWriteTransaction write = I2CDevice.CreateWriteTransaction(new byte[1] { 0 });   I2CDevice.I2CReadTransaction read = I2CDevice.CreateReadTransaction(buffer);   I2CDevice.I2CTransaction[] action1 = new I2CDevice.I2CTransaction[] { write};   I2CDevice.I2CTransaction[] action2 = new I2CDevice.I2CTransaction[] { read };   dev.Execute(action1, 1000); dev.Execute(action2, 1000);

 

At any rate, i am also getting timeout action on both of the execute method calls. My buffer remains unchanged.

 

I checked my version info. and it looks like a am using  SolutionReleaseInfo.solutionVersion 4.2.1.2

 

So.. i was wondering if there was some information as to why i am seeing this behavior?

 

 



#5 jrc903

jrc903

    New Member

  • Members
  • Pip
  • 5 posts

Posted 09 January 2013 - 07:03 PM

I just re-read part of the response to Moble999.. it is true that I should be using SC and SD pins instead of A4 and A5? for I2C on Netduino?



#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 January 2013 - 07:34 AM

Hi jrc903,
I just re-read part of the response to Moble999.. it is true that I should be using SC and SD pins instead of A4 and A5? for I2C on Netduino?
Yes, the new Arduino R3 shield format has dedicated pins for I2C. You can also use software I2C on any pins, and we are working on a software I2C feature which will work on A4/A5 as well. If you are using a pre-R3 I2C shields, try plugging jumper wires between A4/A5 and SDA/SCL. Chris

#7 mobilegamer999

mobilegamer999

    Member

  • Members
  • PipPip
  • 12 posts

Posted 11 January 2013 - 05:03 AM

I am just trying to get a single pin state change on the SDA/SCL lines to show up on my scope, but I have yet to see either pin change it's state ever, always staying at 3.3v.

I am not using A4/A5 nor am I going to any device, I am currently just feeding the output into a scope to examine the voltage levels.

Also, software I2C is out of the question because it is not fast enough.



#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 January 2013 - 08:06 AM

Hi mobilegamer999,
I am just trying to get a single pin state change on the SDA/SCL lines to show up on my scope, but I have yet to see either pin change it's state ever, always staying at 3.3v. I am not using A4/A5 nor am I going to any device, I am currently just feeding the output into a scope to examine the voltage levels. Also, software I2C is out of the question because it is not fast enough.
What value of pull-up resistors are you using? If you connect GND to pin SDA/SCL, do you see your scope's reading move to 0V? Also, can you try using a speed of 100,000 Hz and see if that changes anything? And pass in your full ReadAccel array instead of using the first element in the array? Finally...please try updating to the 4.2.2 firmware release. We haven't changed anything I2C related in the new release...but it will make sure that any diagnostics from our end match your configuration. Here is a snippet of code from Zakie Mashiah's port of Gravitech's 7-seg shield. We use this project to test I2C on Netduino Plus 2.    
        // Reads the 2 bytes temperature into the bufTemp array.        static public void ReadThermI2C()        {            byte[] bufTemp = new byte[2];            ipTemp = new I2CDevice(new I2CDevice.Configuration((ushort)0x49, 100));            I2CDevice.I2CReadTransaction[] readTemp = new I2CDevice.I2CReadTransaction[] { I2CDevice.CreateReadTransaction(bufTemp) };            ipTemp.Execute(readTemp, 1000);            ipTemp.Dispose();            // NOTE: bufTemp will now contain the temperature; temp sensor must be configured first        }
Chris

#9 mobilegamer999

mobilegamer999

    Member

  • Members
  • PipPip
  • 12 posts

Posted 11 January 2013 - 05:24 PM

Hi mobilegamer999, What value of pull-up resistors are you using? If you connect GND to pin SDA/SCL, do you see your scope's reading move to 0V? Also, can you try using a speed of 100,000 Hz and see if that changes anything? And pass in your full ReadAccel array instead of using the first element in the array? Finally...please try updating to the 4.2.2 firmware release. We haven't changed anything I2C related in the new release...but it will make sure that any diagnostics from our end match your configuration.

 

I had 5k pullups but just now switched to 3.2k pullups. At the same time I also upgraded to 4.2.2 and flashed the code that you posted. It looks like one of the many things that were done seemed to have fixed the issue. I will re-enable the I2C code in my main project and see if I can replicate my success. Thank you.



#10 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 January 2013 - 07:33 PM

Okay, great to hear. Let us know how it goes, and if you run into any other troubles. Chris

#11 mobilegamer999

mobilegamer999

    Member

  • Members
  • PipPip
  • 12 posts

Posted 14 January 2013 - 03:36 AM

My netduino seems to be working fine in my circuit for the most part. I did notice one odditity however and that is when using an ADXL345 breakout board along with both resistors, the chip 'hangs' on boot up and the blue LED never goes away, however if I only bring up the SCL line with 3.2k resistor and leave the SDA line with no pullup except for the one the breakout has built in(or so i assume it has one built in) the chip functions correctly.



#12 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 14 January 2013 - 01:03 PM

My netduino seems to be working fine in my circuit for the most part. I did notice one odditity however and that is when using an ADXL345 breakout board along with both resistors, the chip 'hangs' on boot up and the blue LED never goes away, however if I only bring up the SCL line with 3.2k resistor and leave the SDA line with no pullup except for the one the breakout has built in(or so i assume it has one built in) the chip functions correctly.

 

You may want to check out this article on the ADXL345 with the Netduino.  There are no built in resistors in the chip so you do need the pull up resistors.  In this article they are using 10K pullups.

 

The code in this article does several additional steps to check if the sensor is connected and configure it.  I've been using this code with an ADXL345 on the Netduino for about a year now through several hundreds of hours of testing and it has never failed or hung during boot up.






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.