Show Posts
Pages: 1 ... 26 27 [28] 29 30 ... 35
406  Using Arduino / Programming Questions / Re: Help Understanding #if directive on: March 25, 2012, 08:14:24 am
editor3000,

I don't think you understand what we are talking about.  You're examples are for if statements that are executed by arduino while the program is running.  The #if is something different, it's a pre-processor directive tells the IDE how to compile, not run, the program.

Check out:  http://www.cplusplus.com/doc/tutorial/preprocessor/
407  Using Arduino / Programming Questions / Re: Help Understanding #if directive on: March 24, 2012, 07:31:33 pm
Can you show the offending code? Do you have multiple tabs in your project?

I'm not using tabs.

EthernetDNS.h doesn't compile under Arduino 1.0. It doesn't really matter why. You can find the library here if you're interested:
http://code.google.com/p/arisgames/source/browse/trunk/arduino/libraries/EthernetDNS/?r=2002

I did a little experiment.  I wrote the following sketch.  The file ThisFileDoesNotExist.h does not exist.  This code compiles without errors.   This is what I would expect.  The #if statement is false, so it just skips the include directive.
Code:
#define TEST1 100
#if TEST1 < 100
 #include <ThisFileDoesNotExist.h>
#endif
void setup(){}
void loop(){}
#define TEST1 100

But, the sketch below does give me errors.  EthernetDNS.h does exist (but doesn't compile with Arduino 1.0).  It appears that since this file really exists, the IDE is processing it, even though it's supposed to skip it.

Code:
#define TEST1 100
#if TEST1 < 100
 #include <EthernetDNS.h>
#endif
void setup(){}
void loop(){}
408  Using Arduino / Programming Questions / Re: Help Understanding #if directive on: March 24, 2012, 04:11:08 pm
Basically the value of ARDUINO is given the numeric value of the release #. And the #if statement works like a C if statement. In this case you are including EthernetDNS.h only when the arduino version is < 100

That part I know.  But ARDUINO = 100, so it should not be including EthernetDNS.h, which it may not be when it's all done.  But it's not totally ignoring it when when I compile the sketch because EthernetDNS.h has errors when compiled in Arduino 1.0.  I was hoping that since my #if statement is false, the compile process would totally ignore EthernetDNS.h, but it doesn't.
409  Using Arduino / Programming Questions / Re: Help Understanding #if directive on: March 24, 2012, 02:36:00 pm
I'm using Arduino 1.0 on my Mac desktop, but I still have Arduino 0022 on my laptop.  I'll probably upgrade the laptop to Arduino 1.0 soon.  It's easy for me to comment the line out when using Arduino 1.0, but I really wanted to get a better understanding of how #if works.  It was not doing what I expected.

--Scott
410  Using Arduino / Programming Questions / Help Understanding #if directive on: March 23, 2012, 08:42:32 pm
I am using Arduino 1.0 and the EthernetDNS.h library isn't compatible with 1.0; I get errors when I try to compile.  Now with Arduino 1.0, I don't even need EthernetDNS.h library, so I tried to exclude it from being compiled when using Arduino 1.0, but I still get compile errors.  When I comment out EthernetDNS.h it compiles fine.  I didn't think the IDE would compile the library if I exclude it with an #if statement like below. 

#if ARDUINO < 100
  #include <EthernetDNS.h> 
#endif

--Scott
411  Using Arduino / Installation & Troubleshooting / Re: Upload Timeout Error on Mega 2560 - Not Sure What Changed on: March 22, 2012, 10:36:48 pm
I have the same problem.  I have a new Mega R3.  I tried both Arduino 0022 and 1.0 on my Mac OSX 10.6.8.  Sometime my sketch will upload fine, but most of the time it times out.  Doing some Google searches, I found this seems to be a known problem, but I'm not sure how to fix it.  I've seen some talk about avrdude, but I don't know anything about fixing, compiling and uploading a boot loader.  Since this problem seems to be kind of old and my hardware and software are new, I'm surprised this problem still exists.  What should I do?
412  Using Arduino / Sensors / Re: Thermocouple and AD8495 on: February 08, 2012, 11:29:32 pm
For the resistors and capacitors on the thermocouple inputs, I used the values shown in the schematic below.  For +5V I used what is shown in the data sheet: 0.1uF and 10uF.

413  Using Arduino / Sensors / Re: Thermocouple and AD8495 on: February 08, 2012, 11:10:42 pm
Did you implement the input filter and bypass capacitors as shown in Figure 33 of the datasheet?

http://www.analog.com/static/imported-files/data_sheets/AD8494_8495_8496_8497.pdf

No, not initially.  But I just did it now and it didn't improve things.  Now the ADC value is 4 and once in a while it jumps up to a bit, anywhere 15 - 22, for a second or less.
414  Using Arduino / Sensors / Thermocouple and AD8495 on: February 08, 2012, 08:06:42 pm
I'm trying to measure temperature with a thermocouple (k-type) and Analog Devices AD8495 thermocouple amplifier. The AD8495 outputs 5 mV/°C. I  have the AD8495 wired like this:

Pin 1: Thermocouple -
Pin 8: Thermocouple +
Pin 2 & 3: GND
Pin 5 & 6: Arduino input A0
Pin 7: +5v

I have a simple sketch where I read A0, print the value, wait 250ms and repeat.

The A0 input value is not very stable, they range from about 30 to 60.  This correspond temps in the 30s and 40s F.  Actual temperature is high 60F. And the temp in the room is not changing.  I don't understand why the temp in my sketch is changing so much.

Does anyone have experience with the AD8495?  Any suggestion for getting this to work better.

AD8495 info: http://www.analog.com/en/mems-sensors/analog-temperature-sensors/ad8495/products/product.html


415  Using Arduino / Project Guidance / Re: Analog input affected by it's neighbor on: February 07, 2012, 05:30:55 pm
Thanks for the suggestion.  Just so I'm clear, you're suggesting I connect the sponge between pins 3 and 4 of your diagram, right?

I looked on Digi-key for Rail-to-Rail op amps. This one looked like a good match (MCP6004):
http://search.digikey.com/us/en/products/MCP6004-I%2FP/MCP6004-I%2FP-ND/523060
I don't know much about op amps, but I narrowed it down to rail-to-rail output, through-hole, 4-circuit.  This one was the cheapest - only 48 cents.

I did a Google search on rail-to-rail op amps to understand what they are.  From what I found it means you can get the output voltage very close to the input voltage, does that sound accurate?
416  Using Arduino / Project Guidance / Re: Ethernet Voltage Meter? on: February 07, 2012, 04:35:45 pm
I suggest sending your data to Pachube.com and let them do the graphing.  There's an iphone app called Hubcape where you can see the data you're sending to Pachube.  There's a lots of code examples showing how to use an Arduino and Ethernet shield to send the data to pachube.

Here's a link to a guy with a wind farm who sends data to Pachube: http://code.google.com/p/arduwind/
417  Using Arduino / Project Guidance / Re: Analog input affected by it's neighbor on: February 07, 2012, 04:30:49 pm
When the sponge is dry, it's reads as an open circuit with my multimeter.  When wet the resistance is around 100kΩ.
418  Using Arduino / Project Guidance / Re: Analog input affected by it's neighbor on: February 07, 2012, 04:11:21 pm
Just analogue signals, it is caused by the high impedance signal having to charge the sample and hold capacitor. You would not run digital signals with such high resistances because they would not work.


The setup I described for the analog pins also applies to a few digital pins:

GND -----\/\/\/\----- (Digital Input) ---/\/\/\/----- +5v
      100KΩ (sponge)                     1MΩ

Will this setup not work because of the 1MΩ resistance?  I didn't mention it before because it seems to be working okay - but I've only done a little desktop testing.

Also, if I configure the analog inputs as a digital inputs, will the input behave as the other digital inputs or will it behave like the analog inputs - with respect to this issue of charging the sample and hold capacitor.

Thanks again for your feedback.  It's a big help in my understanding of how these inputs work.

419  Using Arduino / Project Guidance / Re: Analog input affected by it's neighbor on: February 07, 2012, 02:27:37 pm
...You don't need any delays, you just need to read each input twice. The first read switches the MUX to this input and takes a sample (which we expect to be inaccurate because the MUX hasn't had time to settle). The second reading of the same input gives you the accurate answer because now the MUX has had much longer to settle.

The settling time could be reduced by reducing the resistances, but without changing them just reading each input twice would work just as well.

Does this need to read the input twice apply to the digital inputs, or just analog inputs?
420  Using Arduino / Project Guidance / Re: Analog input affected by it's neighbor on: February 07, 2012, 07:56:28 am
Do I need to use pinmode() to configure them like you do with digital pins?
Pages: 1 ... 26 27 [28] 29 30 ... 35