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

DS1307 Sparkfun I2C


  • Please log in to reply
34 replies to this topic

#21 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 15 July 2011 - 11:39 AM

but if I can i would try to put a photo of whow I´ve got the connections.........

Would be lovely! I sure hope it's a small detail we're overlooking ;)
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#22 gomore11

gomore11

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts

Posted 15 July 2011 - 11:41 AM

OK, the code i used is the one that it´s at the biginnig but i would put it again :

namespace I2C_RTC 
{ 
    public class Program 
    { 
        public static void Main() 
        { 
            byte[] buffer_read = new byte[7]; 
            byte[] buffer_write = new byte[1]; 
 
 
            I2CDevice.Configuration config = new I2CDevice.Configuration(0x68, 100); 
            I2CDevice RTC = new I2CDevice(config); 
 
            buffer_write[0] = 0x00; 
 
            I2CDevice.I2CReadTransaction tran_read = I2CDevice.CreateReadTransaction(buffer_read); 
            I2CDevice.I2CWriteTransaction tran_write = I2CDevice.CreateWriteTransaction(buffer_write); 
 
             
 
            I2CDevice.I2CTransaction[] tran = new I2CDevice.I2CTransaction[]{tran_write}; 
 
            int data = RTC.Execute(tran, 100); 
 
            Debug.Print("\nThe number of data transfered is: "+ data.ToString()); 
 
            tran = new I2CDevice.I2CTransaction[] { tran_read }; 
            
            data = RTC.Execute(tran, 100); 
 
            Debug.Print("\nThe number of data transfered is: " + data.ToString()); 
 
        } 
 
    } 


I tried to do it with the call of Write and Read together in the same .Execute but it works the same, wrong jejejejejej

#23 Stuart Crawshaw

Stuart Crawshaw

    Advanced Member

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

Posted 15 July 2011 - 11:43 AM

Yes, I connected everithing well again......thank you very much for wasting your time with my problem, shure that the problem it´s a little detail(a dumb detail shure) but if I can i would try to put a photo of whow I´ve got the connections.........


You are not wasting our time i assure you. The success of a good community is mutual help. No problem is dumb, its all down to experience (I am not an expert in electronics at all, im a coder)

No question, big or small is a dumb question. The most intelligent thing people can do when unsure is to ask :)

P.S. Did you see my code example i posted on the previous page (hate pages :P) the attached library/wrapper may well prove useful.
Intelligent People Aren't Afraid To Ask For Help.

#24 mimtarsden

mimtarsden

    New Member

  • Members
  • Pip
  • 8 posts

Posted 15 July 2011 - 03:19 PM

Hi gomore11 I had exactly the same problem as you! No data was read from the Sparkfun I2C. I found out that the SDA and SCL lines needed 2k2 pullup resistors. The clock mudule does not have them onboard. Also after inserting the resistors in the circuit you need to cycle the power completely to the netduino. I dont really know C# so i converted your code in the first post to VB and on my netduino and DS1307 it works. I have attached a screenshot of the output, and an picture of how it's connected I hope it heps you.

Attached Files



#25 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 15 July 2011 - 04:25 PM

OK, the code i used is the one that it´s at the biginnig but i would put it again :

namespace I2C_RTC 
{ 
    public class Program 
    { 
        public static void Main() 
        { 
            byte[] buffer_read = new byte[7]; 
            byte[] buffer_write = new byte[1]; 
 
 
            I2CDevice.Configuration config = new I2CDevice.Configuration(0x68, 100); 
            I2CDevice RTC = new I2CDevice(config); 
 
            buffer_write[0] = 0x00; 
 
            I2CDevice.I2CReadTransaction tran_read = I2CDevice.CreateReadTransaction(buffer_read); 
            I2CDevice.I2CWriteTransaction tran_write = I2CDevice.CreateWriteTransaction(buffer_write); 
 
             
 
            I2CDevice.I2CTransaction[] tran = new I2CDevice.I2CTransaction[]{tran_write}; 
 
            int data = RTC.Execute(tran, 100); 
 
            Debug.Print("\nThe number of data transfered is: "+ data.ToString()); 
 
            tran = new I2CDevice.I2CTransaction[] { tran_read }; 
            
            data = RTC.Execute(tran, 100); 
 
            Debug.Print("\nThe number of data transfered is: " + data.ToString()); 
 
        } 
 
    } 


I tried to do it with the call of Write and Read together in the same .Execute but it works the same, wrong jejejejejej


With that exact code (and an additional closing bracket, one is missing), I got:

The number of data transfered is: 1
The number of data transfered is: 7
The thread '<No Name>' (0x1) has exited with code 0 (0x0).

So your code looks OK. I just got my board connected like the wiki page I posted previously.
Firmware: 4.2 beta 2
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#26 gomore11

gomore11

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts

Posted 16 July 2011 - 01:10 PM

Hi again everybody. Sorry for answering late but i´ve got problems with my internet connection.......Looking your answers i have to think that the code it´s ok so the problem has to be in the hardware connections.....I´ll put a picture of how i´ve got my connections done and tell me what do you think. Thus the connection problems i will not be able to write again till monday so, i hope to resolve the problem with your help then, thank you everybody!! Here goes the picture(it was taken with a movil phone camera so the quality is not the best but i think that the connections are clever......):

Attached Files



#27 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 16 July 2011 - 01:23 PM

It's not a very sharp picture but I see it's connected to 3.3V. The chip requires 5V to work, I can tell from experience it won't work on 3.3V. Also, it looks like you've swapped 5V and GND on the DS1307 board, but that could just look like that because of the image quality.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#28 gomore11

gomore11

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts

Posted 17 July 2011 - 09:55 AM

Hi Stefan. You are wrigth, in this picture it´s connected to 3.3v but it was taken in one of the lots of trys I made but connected to 5v it doesn´t work neither, and on the board the connections are well done, it looks like that becouse of the quality of the picture..........Tomorrow i will try to do everithing again(the coneections and the code)with my firmware actualized to 4.2 beta 2 and I will cross my fingers to have luck!!

#29 gomore11

gomore11

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts

Posted 18 July 2011 - 06:37 AM

Hi everybody! It works!! Finally i realized that the problem was the firmware of the Netduino, updated it to 4.1.1 or 4.2 and with the 2K2 pull up resistors it goes wright!! Thank you everibody, especially to Stefan for your help, I was freezed with it and now i can go on.......

#30 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 18 July 2011 - 06:43 AM

Hi gomore11, Glad I could be of help. Pullups are indeed required, but they are required on an arduino as well I suppose. Enjoy your time-aware Netduino! :D
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#31 gomore11

gomore11

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts

Posted 19 July 2011 - 07:46 AM

Hi again. I´ve got a new problem, the board and the I2C comunications works well, but when I set a new date with a new time, and then I try to see it, the time is set well, but it always gives me back the same day(the month and year are correct) ......why could happen this??(the code i used is the one that Stefan put before).

#32 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 July 2011 - 08:57 AM

Strange, I haven't got time to look into it today I'm afraid, but tomorrow eve I will see what I can reproduce. I also got all parts that are ont he sparkfun-shield seperately so I can actually build that exact shield.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#33 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 22 July 2011 - 07:39 AM

I can't seem to reproduce this problem, I'm sorry :( Here it just works as expected.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#34 Crispin

Crispin

    Advanced Member

  • Members
  • PipPipPip
  • 65 posts
  • LocationLondon, England, Earth

Posted 07 November 2011 - 10:45 PM

Hi gomore11,

Glad I could be of help. Pullups are indeed required, but they are required on an arduino as well I suppose. Enjoy your time-aware Netduino! :D


A bit of frustration here as the pullups were not needed on my arduino but refused to work on the netduino. A couple of 2k2s and all is peachy.

Thanks for jogging the memory
--
Take a seat, I'll be right with you.

#35 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 07 November 2011 - 11:37 PM

Arduinos I2C library uses the internal pullups of the microcontroller when it's not driving the line low - those are weak pullups, but since it only uses "slow" I2C, it works most of the time ... that's the reason you didn't need it, it's still better if you do have external pullups there.
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"




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.