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.

w3n

Member Since 17 Sep 2014
Offline Last Active Jan 07 2015 10:39 AM
-----

Topics I've Started

Netduino plus 1 and I2C

29 December 2014 - 02:31 AM

Hi guys I need some help with I2C and Netduino plus 1.

 

Actually I'm using the A4-A5 Pins to try to communicate with an Adafruit servo shield but just noticied something that's getting me totally confused -I have to say I'm totally new on this but.. seems no sense-

 

Actually the Shield should be at the address 0x40 as documentation says.

 

Running the following test code I got confusing outputs:

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

namespace NetduinoPlusApplication2
{
    public class Program
    {
     
        static I2CDevice.Configuration _i2cdevice;
        public static void Main()
        {

                try
                {
                    Debug.Print("Trying addr: " + 0x38+ "------------------------------------");
                    _i2cdevice = new I2CDevice.Configuration(0x38, 400);
                    I2CDevice MyI2C = new I2CDevice(_i2cdevice);


                    I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[2];

                    byte[] RegisterNum = new byte[1] { 2 };
                    xActions[0] = I2CDevice.CreateWriteTransaction(RegisterNum);

                    byte[] RegisterValue = new byte[1];
                    xActions[1] = I2CDevice.CreateReadTransaction(RegisterValue);

                    
                    if (MyI2C.Execute(xActions, 1000) == 0)
                    {
                        Debug.Print("Failed to perform I2C transaction");
                    }
                    else
                    {
                        Debug.Print("Register value: " + RegisterValue[0].ToString());
                    }
                }
                catch
                {
                    Debug.Print("EXCEPTION  "  );
                }

       
        }
    }
}

Notice I'm trying to setup it wrong, I2CDevice.Configuration(0x38, 400); ..but the output:

 

Trying addr: 56------------------------------------
Register value: 0
The thread '<No Name>' (0x1) has exited with code 0 (0x0).
Done.

 

Ok, Trying the 0x40 (64)

 

Trying addr: 64------------------------------------
Register value: 0
The thread '<No Name>' (0x1) has exited with code 0 (0x0).
Done.

 

and here comes the fun...I unplug the a4 and a5 and ..

 

First time I try: -It should say it failed as it does, so I guess this is right -

 

Trying addr: 64------------------------------------
Failed to perform I2C transaction
The thread '<No Name>' (0x1) has exited with code 0 (0x0).
Done.

 

Ok ..now let's try again -nothing is plugged-

 

The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Trying addr: 64------------------------------------
Register value: 0
The thread '<No Name>' (0x1) has exited with code 0 (0x0).
Done.

How's this possible? first it reads something for an non present address, second time it reads from the 0x40, when it's unplugged it says it failed as expected the first time, but the second time says it was fine... I'm totally confused

 

Any idea on this? Thank you very much in advance

 


Adafruit 16-channel 12-bit pwm/servo shield

29 December 2014 - 01:08 AM

Hi guys,

 

This is my very first project and I'm trying to make work this shield http://www.adafruit.com/product/1411 with my netduino plus 1 for almost 3 days with not success. I followed all the instructions at the adafruit page on soldering, and so on, but netduino 1 SCL and SDA ports are missing so I need to use the analogic pins4 and 5.

 

I made the red led to turn on, feeding the shield with the 5v output from the netduino, added an extra 5v by the V+, so green and red leds are turned on.

 

I tried to plug the analogic pins 4-5 to the SDA & SCL shield pins, even feeding the line with 3v, but no way to get anyresponse from the device when I try to write or read from the device, for example when I try to read the register MODE1, allways returns 0, no matter what I do, no matter what I write, randomly sometimes writes 2bytes others writes 1byte.. I'm totally lost and confused, so any help/advice/direction  will be wellcome.

 

 


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.