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 problems interfacing TPIC2810 Led Driver


  • Please log in to reply
9 replies to this topic

#1 Matteo Defanti

Matteo Defanti

    New Member

  • Members
  • Pip
  • 3 posts

Posted 19 July 2011 - 09:05 PM

Posted Image

Hello everybody
I'm trying to interface my Netduino standard to a Texas Instrument TPIC as shown up in the image!

That's the code:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace i2cMaster2._0
{
    public class Program
    {
         
        static OutputPort Gneg = new OutputPort(Pins.GPIO_PIN_D0, true);
         
        public static void Main()
        {
            OutputPort SDA = new OutputPort(Pins.GPIO_PIN_A4, false); // read in the forum to reset the 2 ports
            OutputPort SCK = new OutputPort(Pins.GPIO_PIN_A5, false);
            SDA.Dispose();
            SCK.Dispose();

            I2CDevice.Configuration cnf = new I2CDevice.Configuration(0x60, 400);

            I2CDevice TPIC2810 = new I2CDevice(cnf);

            byte[] outBuffer = new byte[] { 0x44, 0x64 }; 

            I2CDevice.I2CWriteTransaction writeTransaction = I2CDevice.CreateWriteTransaction(outBuffer);
            

            I2CDevice.I2CTransaction[] transactions = new I2CDevice.I2CTransaction[] 
                                                               {
                                                                    writeTransaction
                                                               };
            while (true)
            {
               
                TPIC2810.Execute(transactions,  100);
            }
             
        }

    }
}

and that's the sequence to send to the device in order to have 0x64 in the 8 leds.

Posted Image



I couldn't get it works so I have tried to test SDA and SCK with the oscilloscope and i just see a +5volts continue line without signals...

Where am i making mistakes? Has anyone got the same problem?

Thank you! :)

Here is the link of the TPIC2810 datasheet Click Here

#2 Stuart Crawshaw

Stuart Crawshaw

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts
  • LocationLeeds, United Kingdom

Posted 20 July 2011 - 10:11 AM

Hi again Matteo,

Did you try with the pull-up on the SCL line as well as the SDA?

Also,
Im not sure of the calculation needed to work out the resistor values for the pull-up resistors (sure someone could teach us both there)

But looking through the various articles it seems it can play a big part, See Here

Also, Could you advise where you attached your scope probes, just so any of these guys on here can replicate how you have your setup to see how their tests differ.

Additionally, could you explain to me the setup of your A0-A2 pins (just for my knowledge) why you set them up in such a way?
From what i can see, these would result (with the switches made) in a Logic-High? where as the address you supplied in code is all A0-2 pins being in a LOW state.

Hope we can get this resolved for you.

P.S. My old old old scope packed in last night :( so im on the lookout for a new fangled replacement and couldnt test my I2C signals as i said i would.
Intelligent People Aren't Afraid To Ask For Help.

#3 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 20 July 2011 - 10:12 AM

I couldn't get it work so I have tried to test SDA and SCK with the oscilloscope and i just see a +5volts continue line without signals...

Unfortunately, I don't have the device to check that, but you should see at least several pulses on the signal lines. Apart from the usual 'check the wiring' advice, there are several things to consider:

  • The device requires logic high voltage VIH to be at least 0.7*VCC (see datasheet p. 4), at 5V power this is 3.5V, which Netduino cannot provide on its 3.3V outputs. You probably need to use 3.3V VCC (and separate 5V for DRAINx, if needed, or change the current limiting resistors for 3.3V),
  • Strangely, there is no pull-up resistor for the clock line in the datasheet circuits, but according to the I2C specification "Both SDA and SCL are bidirectional lines, connected to a positive supply voltage via a current-source or pull-up resistor". So if the communication does not work properly (assuming it works at all, i.e. there are signal transitions on the lines, but for example no or invalid response), I would try adding the pull-up,
  • If the state of address switches is as shown, the device address is 0x67,
  • I don't understand exactly how instantiating and disposing OutputPort objects is supposed to 'reset' the ports, the pin is set back to input state ('floating high') when disposed. I would start with commenting this code out.
Edit: What is the return value of Execute() method call?

Edited by CW2, 20 July 2011 - 10:15 AM.


#4 Stuart Crawshaw

Stuart Crawshaw

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts
  • LocationLeeds, United Kingdom

Posted 20 July 2011 - 10:25 AM

[*]I don't understand exactly how instantiating and disposing OutputPort objects is supposed to 'reset' the ports, the pin is set back to input state ('floating high') when disposed. I would start with commenting this code out.[/list]

Hi CW2,

This was suggested by Chris Walker, as he advised in another post that there could be a bug in the firmware and this sometimes fixes it.

Link Here - At the bottom of post #2
Intelligent People Aren't Afraid To Ask For Help.

#5 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 20 July 2011 - 10:40 AM

The device requires logic high voltage VIH to be at least 0.7*VCC (see datasheet p. 4), at 5V power this is 3.5V, which Netduino cannot provide on its 3.3V outputs.

Correction: It should work fine for VCC = 5V, because the desired level will be achieved by the pull-ups.

#6 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 20 July 2011 - 10:43 AM

Link Here - At the bottom of post #2

I see, thanks for the link. But if I understand it correctly, this was supposed to reveal a possible bug (in A4/A5 multiplexing), which was not confirmed (?)

#7 Stuart Crawshaw

Stuart Crawshaw

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts
  • LocationLeeds, United Kingdom

Posted 20 July 2011 - 10:48 AM

I see, thanks for the link. But if I understand it correctly, this was supposed to reveal a possible bug (in A4/A5 multiplexing), which was not confirmed (?)


Agreed, but worth a try :)


I am in aggreement that Matteo does need a pull-up on the SCL line too...

What i am not aware of is the calculation needed to work out the value of the resistor needed, can you shed some light?
Intelligent People Aren't Afraid To Ask For Help.

#8 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 20 July 2011 - 11:06 AM

What i am not aware of is the calculation needed to work out the value of the resistor needed, can you shed some light?

Usually, anything between 1.5k - 10 kΩ should work fine, ~2.2 - 4.7 kΩ are commonly used. For the exact formulas, please refer to section 7.1 Pull-up resistor sizing of the I2C specification, with the increasing number of devices the bus capacitance increases and the pull-up resistance must be decreased to maintain edge transition times.

#9 Matteo Defanti

Matteo Defanti

    New Member

  • Members
  • Pip
  • 3 posts

Posted 21 July 2011 - 01:15 AM

Hi everybody and thanks everybody for your contribute...

i'm sorry for the image i upload yesterday. i didn't pay attention enought to notice that the switches where high...

Thank you Stuart giving me suggestion of the hint about what information to write in order of being more specific for you.... :)

And CW2... yes what you said about the device address is right but i posted the wrong picture... sorry, my fault

I've created a new image about the connection and the probing connection...
Posted Image
As you can see i put a pull up resistor even on clock, but unfortunately it doesn't work...

I cannot understand why i don't get any data passing even if i disconnect netduino from the device... as i espected... is that wrong to probe SDA and SCK?
Is I2C supported on Netduino standard with .net microframework 4.1?

Edit: What is the return value of Execute() method call?


I can't get what you mean... di you mean why i don't get return value?

OutputPort SDA = new OutputPort(Pins.GPIO_PIN_A4, false); // read in the forum to reset the 2 ports
            OutputPort SCK = new OutputPort(Pins.GPIO_PIN_A5, false);
            SDA.Dispose();
            SCK.Dispose();




it was an attempt to reset the port but it seems unuseful!


this is the while (true) new code
while (true)
            {
               
              int outp =  TPIC2810.Execute(transactions,  100);

              Gneg.Write(true);
              Thread.Sleep(100);
              Gneg.Write(false);
            }


Gneg is primarly used to see that the program is running and cycling!
cause for the moment I2C is not working

#10 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 21 July 2011 - 06:45 AM

Is I2C supported on Netduino standard with .net microframework 4.1?

I don't understand that either, I2C should be working fine. Could you please try probing SDA a SCK pins with the following code (TPIC disconnected)?

public static void Main()
{
  var SDA = new OutputPort(Pins.GPIO_PIN_A4, false);
  var SCK = new OutputPort(Pins.GPIO_PIN_A5, false);
         
  while(true)
  {
    SDA.Write(true);
    SCK.Write(true);
    Thread.Sleep(100);
    SDA.Write(false);
    SCK.Write(false);
    Thread.Sleep(100);
  }
}
If there is no signal on the pins, there is probably a hardware defect.

I can't get what you mean... did you mean why i don't get return value?

I mean what is the value of outp? It should be the number of bytes transferred, in this case 2.




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.