Show Posts
Pages: 1 ... 125 126 [127] 128 129 ... 289
1891  Using Arduino / Microcontrollers / Re: Atmega328 at 4 MHz ? on: March 23, 2013, 08:07:01 am
Hello all.
Is it possible to run a Atmega328 at 4 MHz or even lower to save battery power?

Yes, absolutely. I've used 1MHz and I believe the internal 128kHz oscillator can also be used as a system clock, but I've read that is probably beyond the point of diminishing returns. Additional entries in the boards.txt file will be needed for alternate clock frequencies. I don't try to use a bootloader below 8MHz, and if using the internal 8MHz oscillator (either direct or divided), it may not be accurate enough for serial comm without some tuning.

Quote
Would the arduino code work like on a 16 MHz Atmega328 ?

Yes.
1892  Using Arduino / Project Guidance / Re: Advice for wireless connectivity on: March 21, 2013, 07:46:50 am
Actually, not to hijack this thread, anyone knows how much current an deep sleep Arduino Uno draws?

I measured my Arduino Uno at 42mA when running.
With the MCU in power-down mode (the deepest sleep mode), it still draws 31mA.
The ATmega328P microcontroller alone uses around 0.1µA in power-down mode.
I'm currently designing an Arduino-based data logger using an ATmega328P on a custom PC board. There are one or two other components that draw small idle currents as well, but when it's sleeping the whole board draws < 5µA. A "sleeping" Uno draws 6200 times more current.
1893  Using Arduino / Project Guidance / Re: Advice for wireless connectivity on: March 21, 2013, 01:33:24 am
Not sure why you would need an arduino at all.

Depending on the sensors, perhaps not!
1894  Community / Bar Sport / Re: Idiot spammers on: March 20, 2013, 09:59:52 pm
Much of that stuff is so poorly done that I'm surprised that they get any bites at all.

Umm, no, wait. I'm not completely surprised. smiley-grin
1895  Using Arduino / Project Guidance / Re: Advice for wireless connectivity on: March 20, 2013, 09:46:29 pm
For low power applications, Arduino boards are out. They are just not designed for it. There is ancillary circuitry that continues to draw more power than the microcontroller even when the MCU is sleeping. This is not a criticism, they are designed as prototyping boards.

This means that you are looking at a custom circuit and possibly a custom PC board.

I haven't used any of the various WiFi modules but my perception is that they're not necessarily designed with low power in mind, i.e. may not have a sleep mode.

This seems to me to be a perfect XBee application. On the one end, sensors, a microcontroller and an XBee. On the other end, either (a) just an XBee connected to the computer, or (b) an XBee and a microcontroller. Depending on what kind of programming you want to do. Not sure if it's important to your application, but if having a computer running all the time isn't necessary or desirable, a microcontroller on the receiving end could store the data on a micro SD card, for instance.

I'm sure that a properly designed sensor board with an XBee and an ATmega328P microcontroller like used in the Arduino Uno (and others) could run maybe six months on a pair of AA alkaline cells, transmitting data once every ten minutes, and sleeping the MCU and the XBee in between. Assuming that the sensors themselves are not terrible power hogs or need to be powered on for relatively long periods.
1896  Using Arduino / Project Guidance / Re: Advice for wireless connectivity on: March 20, 2013, 09:25:47 pm
- Arduino + Wireless shield + Xbee module: seems like an ok option but I will need to get some good examples because the v2 stuff is tricky to setup.  I couldn't find too many arduino projects using xbee.  This is where I am leaning right now.

Why would both an XBee and a Wireless Shield (I'm reading that to mean WiFi) be needed?

Quote
In my ideal world, I would like an extremely reliable wifi interface that could reliably be put into and out of sleep mode for long periods to preserve battery life.

Is Wifi (IEEE 802.11) an absolute requirement, or is just getting the sensor data wirelessly from the Arduino into the computer reliably and efficiently with respect to power sufficient?
1897  Using Arduino / General Electronics / Re: power supply on: March 20, 2013, 04:58:26 pm
any suggestions would be appreciated!

If you have a schematic, posting that would be best. Pretty hard to tell what we're looking at otherwise.
1898  Community / Bar Sport / Re: What they teach in school. on: March 19, 2013, 01:41:39 pm
Very good and interesting speech, actually. Food for thought. While she did an absolutely super job, she impressed me as being maybe just a bit uncomfortable. Power of suggestion perhaps, or maybe it just takes one to know one smiley-wink
1899  Community / Bar Sport / Re: What they teach in school. on: March 19, 2013, 01:21:18 pm
Quote
A third to a half of the population are introverts.

It's actually quite a bit higher than that, but they're not standing up to be counted.
1900  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 19, 2013, 08:18:26 am
Being naive here, Is the pulse width from the RTC 500ms?

I assume so, or darn close to it. By definition if it's truly a "square wave" it should have a 50% duty cycle but that's a term that might be somewhat loosely applied.
1901  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 18, 2013, 10:31:34 pm
Ok,  so it seems like I need to keep track of the number of mills from when the PPS goes off and then count up 500 mills and then set the time.

I'll try and write up a simple sketch to test it out.  Thanks!

It's simpler than that. When the pulse from the GPS occurs, get the time from the GPS, set the RTC with RTC.set() and the system time with setTime(). The falling edge of the 1Hz signal from the RTC should then be synchronized with the pulse from the GPS.

Be sure to call setSyncProvider() in setup() to keep the system time in sync with the RTC time.
1902  Using Arduino / General Electronics / Re: Chronodot - Sync 1hz square wave? on: March 18, 2013, 10:07:54 pm
From the datasheet, p12:

Quote
The countdown chain is reset whenever the seconds register
is written. Write transfers occur on the acknowledge
from the DS3231. Once the countdown chain is reset, to
avoid rollover issues the remaining time and date registers
must be written within 1 second. The 1Hz square-wave output,
if enabled, transitions high 500ms after the seconds
data transfer, provided the oscillator is already running.

What you're trying to do should certainly be possible to within 50ms.
1903  Using Arduino / Project Guidance / Re: XBee Antenna on: March 18, 2013, 12:25:58 pm
The robot I have is 4 feet tall. The body is made of wood and it has a outer shell of aluminum flashing.

So essentially one of these. They have some interesting properties. I wouldn't think much will be heard from an XBee or any other radio transmitter inside that robot.

Quote
The electronics including the XBee are in the center of the robot.

I'd look at relocating the XBee to some position where it can see the light of day without a layer of aluminum (or aluminium for GM et al.) in the way. The serial data lines to the XBee should be ok running a few feet.

Quote
I was hoping to put a 1 foot antenna above the robot for better range and to reduce interference with an on board wireless netgear router.

A Wi-Fi router will not interface to an XBee, so that would be futile. It'd be overkill even if it did; the Pro XBee should have more than ample range, but it can't be in a can.
1904  Using Arduino / Programming Questions / Re: How to declare arrays in another (not main) tab? on: March 17, 2013, 10:20:15 pm
In storage, you have only a limited amount of FLASH memory (see your board specs for details, but the UNO has 2k)

In execution, you have a limited amount of SRAM (again see your board specs for details but the UNO has 32k)

Other way 'round actually, 32K flash program memory, 2K static RAM for data, stack, etc.
1905  Using Arduino / Programming Questions / Tips and Tricks to Optimize Your C Code on: March 17, 2013, 09:54:13 pm
I've been reading this application note from Atmel:
Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers
http://www.atmel.com/Images/doc8453.pdf

It's interesting reading. One of the things I found that I do frequently wasn't obvious to me until I read Tip #2.

I had a few variables that I used both in setup() and in loop() so I declared them as global variables. However, they were not used to communicate values between the two functions. Therefore, they could just as well be declared as automatic (local) variables in each function. This sounds like duplication, but in fact it saves both flash program memory and SRAM. Global variables must go into SRAM, whereas local variables can go on the stack or in registers. In addition to saving SRAM, this also shortens the code (and probably makes it faster as well), as addressing the variables can be done with shorter instructions.

Here's an example I cooked up. Declaring the variables twice, once in setup() and once in loop() results in saving 136 bytes of flash and 6 bytes of SRAM. The more references there are to the variables, the more flash is saved.

Code:
//Arduino 1.0.3, Board = Arduino Uno
//Binary sketch size: 3,252 bytes (of a 32,256 byte maximum)
//Free SRAM = 1819 bytes
//See Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers
//http://www.atmel.com/Images/doc8453.pdf

unsigned long n1;
byte n2, n3;

void setup(void)
{
    Serial.begin(115200);
    delay(2000);
    //just some meaningless assignments and calculations
    n1 = millis();
    n2 = n1 % 10;
    n3 = n1++;
    Serial.println();
    Serial.print("mem=");
    Serial.println(freeMemory());
    Serial.println(n1);
    Serial.println(n2);
    Serial.println(n3);
    n1 = millis();
    n2 = n1 % 10;
    n3 = n1++;
    Serial.println(n1);
    Serial.println(n2);
    Serial.println(n3);
}

void loop(void)
{
    delay(5000);
    n1 = millis();
    n2 = n1 % 10;
    n3 = n1++;
    Serial.println();
    Serial.print("mem=");
    Serial.println(freeMemory());
    Serial.println(n1);
    Serial.println(n2);
    Serial.println(n3);
    n1 = millis();
    n2 = n1 % 10;
    n3 = n1++;
    Serial.println(n1);
    Serial.println(n2);
    Serial.println(n3);
}

extern unsigned int __bss_end;
extern unsigned int __heap_start;
extern void *__brkval;

int freeMemory() {
  int free_memory;

  if((int)__brkval == 0)
     free_memory = ((int)&free_memory) - ((int)&__bss_end);
  else
    free_memory = ((int)&free_memory) - ((int)__brkval);

  return free_memory;
}


Code:
//Arduino 1.0.3, Board = Arduino Uno
//Binary sketch size: 3,116 bytes (of a 32,256 byte maximum)
//Free SRAM = 1825 bytes
//See Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers
//http://www.atmel.com/Images/doc8453.pdf

void setup(void)
{
    unsigned long n1;
    byte n2, n3;

    Serial.begin(115200);
    delay(2000);
    //just some meaningless assignments and calculations
    n1 = millis();
    n2 = n1 % 10;
    n3 = n1++;
    Serial.println();
    Serial.print("mem=");
    Serial.println(freeMemory());
    Serial.println(n1);
    Serial.println(n2);
    Serial.println(n3);
    n1 = millis();
    n2 = n1 % 10;
    n3 = n1++;
    Serial.println(n1);
    Serial.println(n2);
    Serial.println(n3);
}

void loop(void)
{
    unsigned long n1;
    byte n2, n3;

    delay(5000);
    n1 = millis();
    n2 = n1 % 10;
    n3 = n1++;
    Serial.println();
    Serial.print("mem=");
    Serial.println(freeMemory());
    Serial.println(n1);
    Serial.println(n2);
    Serial.println(n3);
    n1 = millis();
    n2 = n1 % 10;
    n3 = n1++;
    Serial.println(n1);
    Serial.println(n2);
    Serial.println(n3);
}

extern unsigned int __bss_end;
extern unsigned int __heap_start;
extern void *__brkval;

int freeMemory() {
  int free_memory;

  if((int)__brkval == 0)
     free_memory = ((int)&free_memory) - ((int)&__bss_end);
  else
    free_memory = ((int)&free_memory) - ((int)__brkval);

  return free_memory;
}



Pages: 1 ... 125 126 [127] 128 129 ... 289