Show Posts
Pages: [1] 2 3
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: Serial - Interrupt on: October 16, 2008, 02:22:53 am
Ok, I investigated a little bit more and it seems that Arduino-12 adds avr/power.h that allows you to have a fine grained power reduction managament. By using POWER_MODE_IDLE and shutting down unused modules I managed to wake the Arduino as soon as it gets serial data (the USART is still working on POWER_MODE_IDLE). The source code is in http://rubenlaguna.com/wp/2008/10/15/arduino-sleep-mode-waking-up-when-receiving-data-on-the-usart/


2  Forum 2005-2010 (read only) / Syntax & Programs / Re: Serial - Interrupt on: September 23, 2008, 12:53:36 pm
About the baud rate. 9600 8-N-1 needs 10 bits to transmit 1 byte, right? so 9600 bauds translates to 960 bytes. or am i missing something?  :-?

http://en.wikipedia.org/wiki/Measuring_network_throughput#Overheads_and_data_formats

3  Forum 2005-2010 (read only) / Syntax & Programs / Re: Serial - Interrupt on: September 23, 2008, 10:36:43 am
Ok, so delay() doesn't save any power. bummer!. Good to know, thanks to that I searched more and I found  about real sleep on http://www.arduino.cc/playground/Learning/ArduinoSleepCode. Thx.
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: Serial - Interrupt on: September 23, 2008, 09:50:45 am
I´m very interested on this topic. I´m currently working on a project involving XBee and i want the Arduino to "sleep" until it receives serial data from XBee module.

If I follow the pattern described by mem, that is, waiting in a loop until  Serial.available() > 0 then the Arduino power consumption will be max, right? or am i wrong here? I plan to run my project on batteries so it would be very nice to reduce Arduino power drain to a minimum.

Right now, i'm doing something like this

Code:
void loop() {
   while (Serial.available() < 1) {delay(1)};
   processResponse();
}

But I'm not really sure if this saves power at all (I mean, using delay(1) to sleep). Another question is how much can I increase the delay without risking losing characters? At 9600 baud/s,  up to 960 bytes per second means 1 character per millisecond. But how big is the buffer in the atmel uart?

Looking forward to hear from you. Thx in advance.


5  Forum 2005-2010 (read only) / Syntax & Programs / Re: including a library from a cpp on: November 10, 2008, 12:07:16 pm
This thread (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1224470702) talks about the same issue. You have to add the library to the main pde file, it's the way it works.
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: including a library from a cpp on: October 19, 2008, 09:56:34 am
It seems that if I add

#include <Wire.h>

to the.pde file (the main sketch file) then the #include <Wire.h> in the cpp file works.

 http://www.arduino.cc/en/Hacking/BuildProcess says that the include path include library directories which contain a header file which is included by the main sketch file. So I guess that including Wire.h in the main sketch file is the way to go if I need Wire.h in the cpp file.  

Quote
The include path includes the sketch's directory, the target directory (<ARDUINO>/hardware/core/<CORE>/) and the avr include directory (<ARDUINO>/hardware/tools/avr/avr/include/), as well as any library directories (in <ARDUINO>/hardware/libraries/) which contain a header file which is included by the main sketch file.
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: including a library from a cpp on: October 19, 2008, 03:02:18 am
#include <eeprom.h> doesn't work either. Both includes work if I put them in the pde file. But they don't work if I put them in a cpp file.

And yes, mikalhart, I mean multiple tabs.
8  Forum 2005-2010 (read only) / Syntax & Programs / including a library from a cpp on: October 18, 2008, 04:27:27 pm
I'm trying to use Wire.h in a multisketch project. I have a cpp file that must use Wire.h but I cannot include it. I always get "No such file or directory"


I tried

#include <Wire.h>
#include "Wire/Wire.h"
#include <Wire/Wire.h>

#include <libraries/Wire/Wire.h>
#include "libraries/Wire/Wire.h"

#include <../libraries/Wire/Wire.h>
#include "../libraries/Wire/Wire.h"


but no luck. How am i suppose to use libraries from cpp files?
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: Sending an int. Xbee on: November 04, 2008, 12:09:42 pm
Post the source code that you are using in both sides if you want people to look at your problem. My guess it that you should be using

Serial.print(x>>8,BYTE); //send first 8 bits
Serial.print(x & 0x00FF,BYTE); //send last 8 bit

To send the int value via the serial port instead of the ASCII reprentation of the int value.



10  Forum 2005-2010 (read only) / Syntax & Programs / Re: arduino reset when instantiating an object on: October 02, 2008, 07:13:48 am
I'm pretty new at this so it didn't occur to me that arduino has a pretty limited amount of RAM. It seems that this could be the cause indeed. I'm using a lot of Serial.print("debug statements") and as I read on http://itp.nyu.edu/~gpv206/2008/04/making_the_most_of_arduino_mem.html this literals take ram space as well.

Thank you very much, from now on I will keep an eye on the RAM usage.
11  Forum 2005-2010 (read only) / Syntax & Programs / arduino reset when instantiating an object on: October 02, 2008, 06:14:49 am
Hello,

I'm experiencing an strange reset problem.

It seems that arduino resets when I do
Code:
 struct zigbee a;
  XBee xbee(a);

The XBee class and the struct zigbee forms part of an XBee library I'm developing.

The XBee class has a bunch of functions but I'm not calling any of those functions(I commented out all calls to xbee.xxxx() in the sketch).

The strange thing is that this reset doesn't seem to be related with any code running on XBee constructor neither, because I commented out all statements inside the constructor and the reset keeps ocurring. The reset always comes when instantiating the object. The funny part is that if I remove/change the a string literal from "12345678" to "1234567" on the XBee class then it doesn't reset anymore. But that code that I'm changing it's never executed!!. I never call that code

So I'm wondering if it could be a linking error or something like that.

My real question is how to I debug such an error? Do I need to buy an JTAG debugger, (AVR Dragon?) or is there any way to spot the problem usign avr-objdump?

What could I do to find out what's happening?

12  Forum 2005-2010 (read only) / Syntax & Programs / Re: Is it possible to write the OSCCAL register? on: September 05, 2008, 01:44:30 am
Quote
If you know your calibration value I don't know why you'd have to write it to EEPROM first before you burn your code.  I would think you'd be able to hard code it into your sketch and write it directly, unless the OSCCAL register is located in EEPROM, which wouldn't make sense to me.


Of course you can hardcode into the sketch, but if you are going to write the same sketch to 5 arduinos/atmegas then you have to have 5 differentes sketches each one with a different calibration byte hardcoded in it. If you have the calibration byte on the EEPROM (in the same position in every arduino) then you can upload the same sketch to all of them. But you´re right for my hobbyist purposes hardcoding it should be enough.
13  Forum 2005-2010 (read only) / Syntax & Programs / Re: Is it possible to write the OSCCAL register? on: September 04, 2008, 01:31:59 pm
Thank you, I will try to read the datasheet more in detail as well.

But is good to know that the syntax is supposed to be just OSCCAL=0x3D. I will try that and see if it compiles at least.

By the way, at http://www.avrfreaks.net/modules/FreaksArticles/files/21/Why%20you%20need%20a%20Clock%20Source.pdf they say that the procedure is more or less the following one:

1) use STK500 or similar to do the calibration and get the calibration byte value that you should use.
2) write that value to the eeprom to some known position
3) read that value from your sketch and copy it to OSCCAL,

Do you know if the contents of the eeprom will be erased when loading a new Arduino sketch? or does it only overwrites the data it needs? I was thinking that maybe I can store it at the end of the eeprom.


Anyway, I will try this when I receive my AVR programmer and I will post the result in here.
14  Forum 2005-2010 (read only) / Syntax & Programs / Re: Is it possible to write the OSCCAL register? on: September 04, 2008, 05:10:40 am
Quote
Don't quote me on this, but I'm pretty sure you'd have to change the bootloader to change the clock frequency aswell as some of the arduino core. Can anyone else confirm?

Sure in http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1163418637

they explain that you must modify arduino settings file to
build.f_cpu=1000000L

but let´s say that I´m using arduino without a bootloader, imagine that I program it directy via ICSP, but using Arduino generated hex files. Is it possible to set the OSCCAL from Arduino language?

I guess that I can modify the bootloader to do it but I wonder if there is any other way.
15  Forum 2005-2010 (read only) / Syntax & Programs / Is it possible to write the OSCCAL register? on: September 03, 2008, 03:10:18 am
Is it possible to write the OSCCAL register from Arduino language?

I want to use atmega168 with internal RC oscillator (outside arduino board) and I want to write to OSCCAL to calibrate the oscillator. (as recommended at http://www.avrfreaks.net/modules/FreaksArticles/files/21/Why%20you%20need%20a%20Clock%20Source.pdf)

Did anybody tried that with Arduino language?
Pages: [1] 2 3