Netduino home hardware projects downloads community

Jump to content


Photo

I2C + AnalogInput = Messed up


  • Please log in to reply
10 replies to this topic

#1 H07R0D

H07R0D

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 24 May 2012 - 03:46 PM

So ive got a DS1307 attached to the I2C lines (AnalogIn 4 & 5) and it works fine (pullups where needed). If I add an analog input reading while the DS1307 is attached, I don't get a reading at all. Voltmeter on the same analog input reads like 15mV. If I disconnect the DS1307 from AIN 4&5, I get perfect results. What am I missing here? Do I need to isolate the I2C lines or something?
H07R0D - Fish For Nerds - Nerdiest Reef Tank

#2 H07R0D

H07R0D

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 25 May 2012 - 01:29 PM

A little more detail, in the hopes someone sees something I'm missing. Attached File  DS1307-with-Thermistor_bb.jpg   55.96KB   52 downloads When the DS1307 is connected, I can get the time from it no problem, and I2C communication works fine. If I attach the thermistor to AIN0, it reads basically 0V. All other pins read 3.3V. When I disconnect AIN4 and AIN5 and don't call any I2C functions, I get the readings I expect on AIN0. It's a RevB N+ so no ARef connection needed. What am I not doing?
H07R0D - Fish For Nerds - Nerdiest Reef Tank

#3 mastronic

mastronic

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationFrench - France (Lille)

Posted 25 May 2012 - 04:11 PM

Maybe the card I2C outputs are 5V? NetDuino I2C is 3.3V.
Send a link of card incorpored the DS1307.
And Send code source.

#4 H07R0D

H07R0D

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 25 May 2012 - 04:48 PM

Maybe the card I2C outputs are 5V? NetDuino I2C is 3.3V.
Send a link of card incorpored the DS1307.
And Send code source.


Thanks for the suggestions.

Board I'm using is this one from Sparkfun.
Using code from here that I found on the forums, which didn't mention any issues with 5V I2C

I didn't realize the I2C was 3.3 on the netduino, as the DS1307 from Sparkfun definitely runs against 5V.
I assume that's the problem. My electronics skills are rather limited, so I have no idea how to resolve that.

It's an N+, so maybe I'll just use NST instead of an onboard RTC.
H07R0D - Fish For Nerds - Nerdiest Reef Tank

#5 65tux

65tux

    Advanced Member

  • Members
  • PipPipPip
  • 38 posts

Posted 25 May 2012 - 06:54 PM

Thanks for the suggestions.

Board I'm using is this one from Sparkfun.
Using code from here that I found on the forums, which didn't mention any issues with 5V I2C

I didn't realize the I2C was 3.3 on the netduino, as the DS1307 from Sparkfun definitely runs against 5V.
I assume that's the problem. My electronics skills are rather limited, so I have no idea how to resolve that.

It's an N+, so maybe I'll just use NST instead of an onboard RTC.


Haven't tried one, but ADA has a cheap logic-level chip that works with I2C: ADA level shifter

#6 mastronic

mastronic

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationFrench - France (Lille)

Posted 26 May 2012 - 12:46 AM

Hello, H07R0D,
yes, this is problem 5V to 3.3V.

For test:
Disconnect pull up resistor to 5v
Connect pull up resistor to 3.3v
Soon to be this will solve the problem. but we must see if the DS will still work.

if not, try a converter: Example: DFRobot I2C logic level converter

Schémat

Regard.

#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7165 posts
  • LocationNew York, NY

Posted 26 May 2012 - 01:33 AM

Pins A4/A5, when used in I2C mode, are both 5V and 3.3V tolerant. The analog pins going to A4/A5 are also electronically disconnected when using A4/A5 in digital/I2C mode. Is there any chance that the current flowing to your analog sensor is too weak to drive the analog measurement circuitry? I know that sounds like a funny question. :) Chris

#8 H07R0D

H07R0D

    Advanced Member

  • Members
  • PipPipPip
  • 94 posts

Posted 28 May 2012 - 12:23 PM

Pins A4/A5, when used in I2C mode, are both 5V and 3.3V tolerant. The analog pins going to A4/A5 are also electronically disconnected when using A4/A5 in digital/I2C mode.

Is there any chance that the current flowing to your analog sensor is too weak to drive the analog measurement circuitry? I know that sounds like a funny question. :)

Chris


The measurement is just a thermistor, and when A4/A5 are disconnected, I see the expected voltage (1.5-1.6V ish for my ambient temp)
But as soon as I connect A4/A5 back up, A0 reading drops right down. I'm taking those readings with a voltmeter, so not even through the ADC yet (although the ADC reads the same as the voltmeter).

I did notice that when I connect A4/A5, A0 reads basically nothing (15mV) A1, A2 and A3 all read 3.3v (nothing connected to them) and A4/A5 are about 3.9v.

If I disconnect the pullup resistors, what effect should that have?
H07R0D - Fish For Nerds - Nerdiest Reef Tank

#9 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 31 January 2014 - 06:28 AM

Hi Guys,

 

I'm working with DS1307... it's attached on A4/A5. time reading is great. but something happen to my analog pin 0 -3. All those Analog pins read 3.3V.

 

when I deploy a program to read Analog pins (without RTC) it goes fine. Once I attached the RTC all pins goes to 3.3 v..

 

what should I do?



#10 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 31 January 2014 - 07:14 AM

Add details,

protected static SecretLabs.NETMF.Hardware.AnalogInput A0 = new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0);

when I delete this declaration, All analog pins (Analog 0-3, A4/A5 use to I2C) goes normal, reads 0.45mv.  but when I use this code, with RTC pluged all the rest Analog in reads become 3.3V. Please anyone suggest a solution....



#11 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 31 January 2014 - 09:05 AM

Done...

 

this my Note.

 

1. Power RTC to 5v, but pull up SDA/SCL to 3.3v (here I'm using 4.7k and time readings work fine). as suggested by mastronic.

2. At Any rest analog (A0-A3), it will have 1.5v before declared to use ( as analoginput ) and 0mv after declaration...

 

But I dont have any explaination, why is it happen? as Crish mentioned above that, once A4/A5 is declared as I2c device, there's no more connection or relation to other analog pins. then why the pull up to 5v affecting them? :wacko:

 

anyway... my RTC and analog input works fine now.  :rolleyes: but very appreciate for any detail explaination (I've used to write it on to my thesis) :P

 

Cheers :lol:






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2010-2014 Secret Labs LLC  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.