Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: ADC Noise Reduction code please on: January 22, 2011, 11:26:34 pm
Quote
Have you noticed a problem with analogRead?

My analogRead values have been jumping around a bit. Admittedly, this could be due to any number of reasons.  However, I figured Atmel must have put the noise reduction mode in for a reason and thought I'd give it a try first.  But this didn't turn out to be so straightforward with Arduino, so I'm on to looking at my hardware now.
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: ADC Noise Reduction code please on: January 22, 2011, 09:19:52 pm
Well, I'm sure a lot of people would find it useful to have a function that reads an analog input using ADC noise reduction, defined as such:

int analogNoiseReducedRead(int pinNumber)

But coding this is beyond my knowledge and skills. Anyone feel like taking it on and posting it here?
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: ADC Noise Reduction code please on: January 22, 2011, 07:55:45 pm
Would this work?

Code:
#include <avr/sleep.h>

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  int reading;
  
  reading = analogNoiseReducedRead(0);
  Serial.println();
  delay(500);
}

int analogNoiseReducedRead(int pinNumber)
{
  int reading;
  
  ADCSRA |= _BV( ADIE );             //Set ADC interrupt
  set_sleep_mode(SLEEP_MODE_ADC);    //Set sleep mode
  reading = analogRead(pinNumber);   //Start reading
  sleep_enable();                    //Enable sleep
  do
  {                                  //Loop until reading is completed
    sei();                           //Enable interrupts
    sleep_mode();                    //Go to sleep
    cli();                           //Disable interrupts
  } while(((ADCSRA&(1<<ADSC))!= 0)); //Loop if the interrupt that woke the cpu was something other than the ADC finishing the reading
  sleep_disable();                   //Disable sleep
  ADCSRA &= ~ _BV( ADIE );           //Clear ADC interupt
  sei();                             //Enable interrupts
  
  return(reading);
}
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: ADC Noise Reduction code please on: January 22, 2011, 07:44:50 pm
Thanks Coding Badly.  The thread you've linked to is too long and complex for a noob like me.  Where is the analog pin to be read defined? Where is the call made to read it with the ADC?
5  Forum 2005-2010 (read only) / Syntax & Programs / ADC Noise Reduction code please on: January 22, 2011, 05:44:23 pm
Can someone please provide code for using ADC Noise Reduction when reading an analog input? Thanks!
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: Waking Arduino once per minute on timer based int on: May 14, 2009, 01:27:14 am
I'd definitely be interested to see the results. Thanks Brian!
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: Waking Arduino once per minute on timer based int on: May 14, 2009, 12:22:40 am
Hi Brian,
Your code is great, but unfortunately the ATMega168 and ATMega328 (which I believe come with the Arduino Duemilanove, which I have on order) do not have watchdog clock dividers, unlike the AT90USB82 that you are using.

This means that the maximum time between watchdog interrupts for the Arduino Duemilanove is 8 seconds... Bummer!

Looks like the best I can do is what r55boy suggested... waking it up every 8 seconds to increment a counter then putting it back to sleep again... On every n wake ups execute the main code.
8  Forum 2005-2010 (read only) / Development / Re: Who needs a Software Real Time Clock? on: May 13, 2009, 11:42:20 pm
Thanks Brian,
I've worked out a new control algorithm that doesn't require date/time, so now I just need to put the arduino to sleep and wake it every few minutes to conserve energy. Looks like the thread you've linked to will do the trick.

Cheers,
Todd
9  Forum 2005-2010 (read only) / Development / Re: Who needs a Software Real Time Clock? on: May 13, 2009, 10:35:18 am
I'm still waiting for my first Arduino in the post, so excuse my ignorance...

I'm looking to use the software real time clock in my first project as I need to trigger a function twice a day at certain times. I'm also looking at using the watchdog timer and sleep functions to save energy (http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/).

Are the two compatible, or is there some way to make them compatible? I realise that I might need to use a different sleep mode than that used in the example linked to above (maybe "power save" mode instead of "power down" mode).

Any help would be appreciated!
10  Forum 2005-2010 (read only) / Development / Re: byte sized datalogger, anyone? on: June 01, 2009, 11:02:36 am
You can download a zip file containing all of the relevant files plus an example here:

http://sites.google.com/site/toddsstuffnthat/arduino-code-1/ByteSizedDataLoggerLibrary.zip

Extract the DataLogger folder to ..\hardware\libraries\ in your Arduino directory.

Please let me know if you end up using it.
11  Forum 2005-2010 (read only) / Development / Re: byte sized datalogger, anyone? on: May 31, 2009, 09:05:42 pm
Hi Nachtwind,
As it stands it only uses built-in EEPROM, but I'm sure it could be adapted. Being very new to all of this I'm not really sure how easy or difficult it would be to do so.

Personally I don't have much need for more memory. I'm using an ATMega328, which (I am led to believe) has 1024 bytes of EEPROM available. So, it can fit 40 days worth of 1-hour time step data for one variable, which is plenty for my application.

I will post some files in the next few days if people are interested.
12  Forum 2005-2010 (read only) / Development / byte sized datalogger, anyone? on: May 31, 2009, 05:05:11 am
I have just finished building a byte-sized (literally & figuratively) DataLogger library for EEPROM data storage and retrieval. It includes the following functions:
  • .AddVariable(int Size, Int Cycle): Adds variables to the data logger of a given size and cycle*
  • .Write(int VarNum, int Value): Stores a value for a given variable
  • .Read(int VarNum, int ValNum): Retrieves a value for a given variable
  • .Encode(float Value, float Min, float Max): Encodes (scales between Min and Max) a value into 1-byte ready for storage
  • .Decode(int Value, float Min, float Max):  (The inverse to encode) Decodes a retrieved value, ready for use
  • .Export(): Writes all data to the serial port in CSV format for easy copy-and-pasting from the serial monitor into a spreadsheet for analysis (columns = variables, rows = values).
  • Additional functions for retrieving specific information about the DataLogger and its variables; for clearing values from one or all variables; for initialising a variable of the DataLogger class type.
* A variable being cycled (Cycle ==1) means that values are progressively overwritten once the variable's memory block is full. (Cycle == 0 [ch8594] not cycled)


Would others find this useful? If so, let me know and I will document and post it.
13  Forum 2005-2010 (read only) / Interfacing / Re: How to change ADC resolution? on: May 31, 2009, 08:51:18 pm
You're right, processing time for a division by 4 is no big deal for my application. Thanks.
14  Forum 2005-2010 (read only) / Interfacing / How to change ADC resolution? on: May 31, 2009, 04:41:24 am
I'd like to change the ADC resolution to 8-bit. I am using a Duemilanove with ATMega328.

I understand that the default resolution of the Ardiunio's analog inputs is 10-bits (1024 levels). I am storing analog values as single bytes in EEPROM, so the additional 2-bits of resolution is unnecessary. I could mathematically convert 10-bit to 8-bit and then store, but thought it would be more efficient to just reduce the ADC resolution to 8-bit (1 byte) if possible.

Does anyone know how to do this?
15  Forum 2005-2010 (read only) / Interfacing / Easiest way to add more memory? on: May 01, 2009, 03:30:08 am
What is the easiest way to add more memory to an Arduino Duemilanove (above the 512 bytes EEPROM available)?
Pages: [1]