Show Posts
Pages: [1] 2 3 ... 5
1  Using Arduino / Networking, Protocols, and Devices / Re: I2C Multiple Pullup Resistors on: March 07, 2013, 01:42:02 am
Hi Grumpy_Mike,

Thank you very much for your quick reply, that answers my question perfectly!

2  Using Arduino / Networking, Protocols, and Devices / I2C Multiple Pullup Resistors on: March 07, 2013, 01:36:14 am
Hi all,

What are the effects of having multiple different pullup resistors and level shifters on one I2C bus?  For example, I have a DS1307 real time clock at 5V with pullups, a BMP085 pressure sensor breakout board with it's own pullups and level shifting, and a LSM303 digital compass breakout board with its own pullups and level shifters.  Using all three of them at the same time works just fine, but I am wondering what the side effects of having so many levels and different pullups are on the I2C bus.

Thanks in advance!
3  Using Arduino / Programming Questions / Re: Need help understanding a line of code... on: December 18, 2012, 12:01:38 pm
Yes indeed. The question mark denotes the thing that happens if "X" is true and the colon denotes the thing that happens if "X" is false.

Here's an example (pseudo code):

what_is_larger = (moon < sun) ? "The sun" : "The moon"

The test condition is "moon less than sun". Since the moon is smaller than the sun, "(moon < sun)" evaluates to "TRUE". Therefore, the string after the QUESTION MARK is the one that is placed into the variable "what_is_larger".

I could also write it this way:

what_is_larger = (moon > sun) ? "The moon" : "The sun"

Since, in this case, "(moon > sun)" is FALSE, the string after the COLON is placed into the variable "what_is_larger".

Got it?


@Krupkski,@AWOL,

Thank you for your help, it makes perfect sense.  The above explanation was very helpful.  Is there any reason (other than succinctness) to use this as opposed to an if-else statement?
4  Using Arduino / Programming Questions / Re: Need help understanding a line of code... on: December 18, 2012, 04:25:53 am
Another crazy way to write that would be:

leap = (yOff % 4) ? 0 : 1;

The ? and : operators are very handy. They simply work like this:

"IF X is TRUE then ? (THIS HAPPENS) otherwise : (THIS HAPPENS)"

I'm very glad you told me that!  The code actually uses this sytax later on and I was wondering what it did.  Do the question mark and colon operators have any special names so i can look them up?
5  Using Arduino / Programming Questions / Re: Need help understanding a line of code... on: December 17, 2012, 06:37:10 pm
Thank you all for your help, my guess was correct.  Personally, I have never seen anyone write code like that!
6  Using Arduino / Programming Questions / Need help understanding a line of code... on: December 17, 2012, 02:26:17 pm
Hi all,

Can anyone help me understand what is going on in this line of code?  I've never seen this kind of syntax before.
Code:
leap = yOff % 4 == 0;
Both "leap" and "yOff" are of uint8_t type.  As far as I can tell, if yOff divided by four has no remainder, leap will equal one.  The line is located in the following code block:
Code:
  for (yOff = 0; ;++yOff){
      leap = yOff % 4 == 0;
      if (days < 365 + leap)
          break;
      days -= 365 + leap;
  }
This code isn't mine, I'm simply trying to understand what is happening in Adafruit's RTC library (https://github.com/adafruit/RTClib).

Thanks in advance for any and all help!
7  Using Arduino / Sensors / Re: Basic ADC/Analog read question on: November 03, 2012, 02:58:41 am

AREF, IRV (internal reference voltage), and ADC (value from the analog-to-digital converter) are related by a ratio...

 AREF / IRV = 1023 / ADC

Solve for AREF...

 AREF = IRV * 1023 / ADC

The "+5L" rounds fractions up.  The "/10L" converts from millivolts to centivolts (volts * 100) giving three significant digits (which is the most we can expect from a 12 bit converter).  The basic equation is the one above.  The rest is to avoid floating-point math.

Make sense?

Makes perfect sense now, thank you for your help!
8  Using Arduino / Sensors / Re: Basic ADC/Analog read question on: November 02, 2012, 10:54:13 pm
Clarkwd, glad to see it works well!  Retrolefty, if you get a moment, could you explain what this line does?

Code:
int results = (((InternalReferenceVoltage * 1023L) / ADC) + 5L) / 10L; // calculates for straight line value

It may be obvious but I wasn't able to figure it out.
9  Using Arduino / Sensors / Re: Basic ADC/Analog read question on: October 31, 2012, 12:24:46 am
Hi Clarkwd,

What I would do is calculate the temperature from the TMP36 using the Vcc measurement.  For example, with no compensation, if you took an analog reading of the TMP36 of 512, the way you would convert it to volts is like such: 512*5/1023 = 2.502 Volts.  With compensation, you would calculate it like such: 512*VBatt/1023.  As long as you are running the TMP36 off of the 5V pin, you should be able to get an accurate measurement since you've accounted for any voltage variance.  If you don't mind me asking, what is the application of this project?  It sounds like you are working on a weather station, which is what I do most of my experimentation on as well.
10  Using Arduino / Sensors / Re: Basic ADC/Analog read question on: October 30, 2012, 08:03:25 am
Hi clarkwd,

So I'll try to answer the questions I know before going onto the things I'm more unsure of.  To begin, let's outline the differences between Vin, Vcc, and AVcc.  Looking at this image http://i.imgur.com/Ap12L.png, you can see that vin leads into the ncp1117 voltage regulator, which drops the Vin down to 5V.  So any battery you plug into the barrel jack connector or Vin pin will be fed into the voltage regulator and be converted into 5V.  Looking at page 3 of the atmega328 data sheet (http://www.atmel.com/Images/doc8161.pdf), you can see that Vcc is the digital supply voltage pin for the 328 chip itself. The 5V from the voltage regulator output will be connected to this pin to provide the Arduino with power.  Looking at page for of the atmega328 data sheet, you can also see that AVcc is the supply voltage pin for the analog components of the 328 chips such as the A/D converter.  The data sheet also says that AVcc should be connected to Vcc through a low pass filter.  This allows for more accurate A/D conversions.

Now let's break down retrolefty's code, focusing on the following groups of code:
Code:
const long InternalReferenceVoltage = 1115L;  // Adjust this value to your boards specific internal BG voltage x1000
The internal bandgap voltage should nominally be 1.1V, but is rarely ever perfectly 1.1V.  Therefore you should measure your bandgap voltage (let me know if you need to know how), multiply it by a thousand, and insert it where the "1115" is.  Retrolefty's bandgap must have been 1.115 volts.

Code:
     // For 168/328 boards
     const long InternalReferenceVoltage = 1056L;  // Adjust this value to your boards specific internal BG voltage x1000
        // REFS1 REFS0          --> 0 1, AVcc internal ref. -Selects AVcc external reference
        // MUX3 MUX2 MUX1 MUX0  --> 1110 1.1V (VBG)         -Selects channel 14, bandgap voltage, to measure
     ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
This chunk of code essentially sets up an analogRead() with some custom parameters.  It sets the analog reference to the AVcc pin, and then tells the arduino to read the ADC channel connected to the internal bandgap voltage.  The next few lines in the code start the reading and waits for it to finish. 

Unfortunately, I don't exactly understand what is happening in the following line of code where all the magic happens:
Code:
int results = (((InternalReferenceVoltage * 1023L) / ADC) + 5L) / 10L; // calculates for straight line value
  However, retrolefty says it computes the voltage at the AVcc pin, which is simply the filtered, regulated five volts discussed above. 

Looking at your usb serial monitor output, it seems like you are getting Vcc voltages of 4.74 volts.  Looking at the voltages you pasted in your original post, the USB gives you a Vcc of 4.72V, a dead 9V battery gives you a Vcc of 4.60 volts, and a fresh 9V gives you a VCC of 4.74 volts.  What you may have to do is find a correlation between Vcc an Vin.  Then you can put your cutoff point in the code.  Alternatively, the TMP36 is an analog temperature sensor, correct?  You can run the sensor off of the 5V pin, and correct for the deviation in low power by measuring Vcc.  Let me know if you want to know more about that. 

I'm sorry if you knew most of this stuff, it's a bit of a long post.  Hopefully it helps!
11  Using Arduino / Sensors / Re: Basic ADC/Analog read question on: October 29, 2012, 10:59:52 pm
Hi Bill,

Welcome to the Arduino Forum!  I didn't find anything in your code that was drastically different from what retrolefty has posted so your code seems good.  However, retrolefty specified that this method measures the voltage on the AVCC pin on the atmega328, while you said that you are measuring from the Vin pin.  You may be trying to read your battery voltage, while retrolefty's code is reading the Avcc pin.  Do you have any raw output values from your experimentation?

Also, for future reference, try to remember to put all code between the code tags that can be made by clicking the pound sign button when commenting.  It will turn this:

void setup(){
}

into this:

Code:
void setup(){
}


which will make it easier to read for people.
12  Community / Products and Services / Re: Highly Anticipated 32-bit "Due" due When? on: October 23, 2012, 02:22:29 pm
Quote
Arduino Due now available for order at Mouser (A000062)!  Small quantity on the way with a large order coming in November.

-Tim

Just went to your link - I'm assuming the 36.99 price I saw was wrong.

It may not be wrong.  Mouser often has cheaper prices than anywhere else for Arduinos.  Arduino Mega2560 for ~39.00 USD: http://www.mouser.com/ProductDetail/Arduino/A000067/?qs=sGAEpiMZZMt0re6d%252b2Rx9v%252bc%252bQEIaOW9
13  Community / Products and Services / Re: Highly Anticipated 32-bit "Due" due When? on: October 22, 2012, 02:50:42 am
Here is the sparse but "official" announcement: http://arduino.cc/en/Main/ArduinoDUE
14  Using Arduino / Programming Questions / Re: DS1307 RTC Giving Wrong Values After Running for a Few Days on: August 31, 2012, 10:43:38 am
@Riva.  Riva, thank you for telling me about that!  I was wondering what the emissivity packet was but I never did find out.  The difference between the TN9 and the DS1307 is that the DS1307 is inside an enclosure, which gets up to the 55C I was talking about, but the TN9 is left in a separate more ventilated enclosure.  According to the TN9's onboard ambient temperature sensor, the TN9 enclosure never goes above ~37C.  See .
15  Using Arduino / Programming Questions / Re: DS1307 RTC Giving Wrong Values After Running for a Few Days on: August 31, 2012, 10:05:30 am
Hi everyone, Thanks for all your help!

I will be moving it inside today and running it for a while to see if I can duplicate the problems in a more temperature normalized environment. 

@tasosstr.  My data lines are pretty short already.  The chip lies next to pins 20/21 on the shield (I'm using a mega).  My shield eagle schematic can be found here: https://github.com/madvoid/LEMS_PCB  They are the .brd and .sch files, though I can also upload pdfs if anyone wants them as well.

@gardner.  Can you expound on that?  I just finished an email conversation with someone from maxim and they said something along the lines that you did, though I did not completely understand it.  I am using an established library, so maybe some other people have had this problem?  If not, I am going through the library right now but since I don't really know what I'm looking for, I'm hoping the problem will jump out at me smiley-razz
Pages: [1] 2 3 ... 5