Show Posts
Pages: 1 2 3 [4] 5 6 7
46  Using Arduino / Programming Questions / Re: IDE 1.0 and sleep question on: August 23, 2012, 11:21:47 am
that makes sense, thanks for explaining it to me.
47  Using Arduino / Programming Questions / IDE 1.0 and sleep question on: August 23, 2012, 10:37:23 am
I have a sketch that I developed in IDE 0023 and I have transitioned it to IDE 1.0.1. I have it working now but I found a discrepancy that I don't understand and hope that someone could help explain. I trimmed out all my code except for the area that gives me trouble. My code below is a simple for loop that prints a variable and right after the loop I put the unit to sleep. The loop should run 25 times but it only prints 20 times and then goes to sleep. If you uncomment the delay between the loop and going to sleep it completes all 25 print statements and then goes to sleep. I did not encounter this in IDE 0023 and it took me a while to figure out what was going on. It is a simple thing to add a small delay but shouldn't the loop complete first before it moves to the next thing? Just to clarify I am running the breadboard boot loader using the internal 8mhz clock with an external 32khz crystal for timer2 when in sleep mode. Thanks in advance for any help explaining why I need the delay.

Code:

#include <avr/sleep.h> //Needed for sleep_mode

int time[30] = {
  2,5400,6300};


void setup() {


  Serial.begin(9600);
  Serial.println("this is setup");

  for(int i = 1; i < 26; i++){
    int j = i * 2;
    Serial.print("time ");
    Serial.println(i);
    Serial.println(time[i]);
   
  }
 
  //delay(200); //with this commented out it only prints until 20. With the delay it prints everything.
 
 
  set_sleep_mode(SLEEP_MODE_PWR_SAVE);
  sleep_enable();


  //Power down various bits of hardware to lower power usage
  ADCSRA &= ~(1<<ADEN); //Disable ADC
  ACSR = (1<<ACD); //Disable the analog comparator
  DIDR0 = 0x3F; //Disable digital input buffers on all ADC0-ADC5 pins
  DIDR1 = (1<<AIN1D)|(1<<AIN0D); //Disable digital input buffer on AIN1/0


  //Setup TIMER2
  TCCR2A = 0x00;
  TCCR2B = (1<<CS22)|(1<<CS21)|(1<<CS20); //Set CLK/1024 or overflow interrupt every 8s
  ASSR = (1<<AS2); //Enable asynchronous operation, 32kHz xtal needed
  TIMSK2 = (1<<TOIE2); //Enable the timer 2 interrupt

  sei(); //Enable global interrupts


}


void loop(){

 
  sleep_mode(); //Stop everything and go to sleep.


}


48  Using Arduino / Project Guidance / Re: Weatherproof Arduino and components on: August 15, 2012, 09:29:27 pm
I have built a GPS project that has constant outdoor exposure and I ran into a lot of problems despite having an airtight case.  What tends to happen is the moisture in the air from when you seal it condenses when you put it out in the cold. This condensation causes all kinds of problems and it will kill your system VERY quickly. I have done 2 things that work well to combat this. The first is to bake everything in the oven at about 120 degrees for a couple hours to bake the moisture out of everything. Then I seal up the case with just 2 small holes in it. I then blow nitrogen through the case and quickly seal up the holes. I buy the nitrogen cheaply from a local welding supply store. I am also spraying conformal coating over components which to helps prevent problems. I know this sounds like a lot of work and fairly extreme but I have a pile of failed units that show anything less is prone to problems when you leave it for an extended period exposed to the elements.
49  Using Arduino / Project Guidance / Re: GPS Tracking device on: July 27, 2012, 01:28:10 pm
I just remembered that I have an old GoPhone SIM that I am not using nor will I ever use. It still has $33 of credit on it and it is active until February 2013. I would be happy if the credit did not go to waste so if you PM with your address i will send it to you.

In terms of cost I still think the GoPhone SIM is better. You pay $100 for 12 months and you then use that $100 to buy "feature packages". 50MB costs $5 a month which takes $60 per year out of your $100. That leaves you with $40 per year for SMS which gives you 200 SMS updates per year. If you are sending more SMS you can pay $5 per month for a 200 message plan. This takes your yearly total up to $120 and I cant imagine you could possibly go over 50MB and 200 MS per month.

50  Using Arduino / Project Guidance / Re: GPS Tracking device on: July 26, 2012, 09:45:13 pm
I do not have any experience with this board but i do have a lot of experience with GSM and GPS in general. This board is using a rather small patch antenna for the GPS and I strongly suspect it will have trouble getting a reliable lock if it is tucked away someplace out of view. I see a 50ohm wire running to the GPS antenna and I am willing to bet it would be very easy to just unscrew that top board and get access to the solder pad or connector for the GPS antenna. Just unsolder the existing wire and solder on a lead for your external GPS antenna. I never used this board so I cant say for sure that you have access to the pin/pad or connector but it sure looks like you would. This would allow you to mount the board under the dash and then put the GPS antenna in a proper location.

 For a SIM card I have used the GoPhone prepaid SIM from any AT&T store. Make sure to go an an actual AT&T store, not an authorized reseller who will charge more. They have some data and SMS plans that are pretty good and they have always worked well for me. Initiating a data transfer can be done but is harder to do. SMS is much easier to manage and with GoPhone you can buy a $5 plan that gets you 500 SMS per month. GoPhone also has a free E-mail to SMS service so you can just send a free E-mail such as phonenumber@att.txt.com.
51  Using Arduino / Programming Questions / Re: Sketch runs perfectly in IDE 0023 but hangs in IDE 1.0.1 on: July 25, 2012, 01:50:56 pm
You both make some great points and I will work on improving in all of these areas. Learning arrays is something I have been working on recently but my attempts to implement it here have not worked properly so far so I kept with what I know for purposes of this poster. I know that this is how it should be done and I am actively working on learning it though. My goal is to get everything working in IDE 1.0.1 first so I can practice some of the concepts you both mentioned.

I did try trimming my sketch down to 6 variables from 25 and removed many of the print statements. I know my sketch is still not very clean but this should have made a significant difference in SRAM and it still hangs in IDE 1.0.1. Is there a way to track SRAM usage and find out for sure if this is the problem?

I will remove Serial.flush(). I was using it because I turn on/off the device it is connected to frequently and when it tuns on it was sending some junk. It takes at least a few minutes before I get any serial data so I was just flushing it to get rid of any junk while it waits for valid data. I did not know the meaning changed in the new IDE so I will look that up as well.

I was setting the pins high to keep current consumption in sleep mode low since I use a battery. Clearly based on your comment I implemented this wrong so I will try to read up on this more.

I will have to read more about NULL termination because I thought I was. I look for a "#" and use that to mark the end of the transmission.

 

52  Using Arduino / Programming Questions / Sketch runs perfectly in IDE 0023 but hangs in IDE 1.0.1 on: July 25, 2012, 01:11:36 pm
I am working with a sketch that I developed in IDE 0023 with the bread board bootloader. The sketch has worked very well for me in that environment. However, I decided it is time to move to IDE 1.0.1 and I have updated the libraries with Arduino.h. Also with help from the forum I got the bread board boot loader to work with IDE 1.0.1. The sketch compiles and starts to run but then hangs part way through. When I load an older version of my sketch in IDE 1.0.1 that does not include EEPROM Anything it runs fine, but when I introduce my latest version with EEPROM Anything it always hangs. Any suggestions on why it would run well on IDE 0023 but hang when using IDE 1.0.1 when using EEPROM Anything? I attached my sketch because I get errors about the size when I try to place it here.
53  Using Arduino / Microcontrollers / Re: breadboard bootloader error in IDE 1.0.1 on: July 24, 2012, 03:23:00 pm
I changed the file name as suggested and that corrected the Arduino.h compile error. However, it started to give me an error that it could not find pins_arduino.h. The solution was to add
Code:
atmega328bb.build.variant=arduino:standard
. I am now able to compile with no errors using the breadboard boot loader. Here is the full code for the boards.txt file in case it might help someone else.

Code:
##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard

Thanks everyone for all the help, I really appreciate it!
54  Using Arduino / Microcontrollers / Re: breadboard bootloader error in IDE 1.0.1 on: July 24, 2012, 11:09:40 am
I had a look at that link but I am not using any libraries so I don't think that is my issue. Here is my sketch
Code:
void setup(){
  int test = 5;
}

void loop(){
}

My code does not do anything at all and it is just used to see if I can compile something with IDE 1.0.1. It keeps looking for Arduino.h and does not seem able to find it. As soon as I try to compile the sketch with another bootloader such as UNO it will compile with no issue. So the problem has to be with the breadboard bootloader. The only file I can find that is related to the bootloader is a boards.txt file. Here is the code I find in the boards.txt file
Code:
##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=arduino.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduinoatmega328bb.build.variant=standard

##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=arduino.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduinoatmega328bb.build.variant=standard

I looked through this and I do not see any reference to WProgram.h so I don't see what I can change to Arduino.h. When I try to compile do you know where it is going to look for the Arduino.h file? Should that reference be in the boards.txt file or am I barking up the wrong tree?

55  Using Arduino / Microcontrollers / Re: breadboard bootloader error in IDE 1.0.1 on: July 24, 2012, 09:55:06 am
wanderson, do you know where it is looking for arduino.h? I looked through the boards.txt file and can not find a reference to Wprogram.h so I am not sure where to make this change.
56  Using Arduino / Microcontrollers / breadboard bootloader error in IDE 1.0.1 on: July 24, 2012, 08:50:44 am
I am running the breadboard bootloader which can be found here http://arduino.cc/en/Tutorial/ArduinoToBreadboardon a stand alone 328P. This has worked very well for me using IDE 0023 but I am trying to use IDE 1.0.1 now and I am getting an error that I can not resolve. When I try to compile I get this error "sketch_jul23a.cpp:1:21: error: Arduino.h: No such file or directory". I know that IDE 0023 used wprogram.h and that IDE 1.0.1 uses Arduino.h so this seems to be the issue. However I do not know how or where to look to make the change. I did look in the boards.txt file but I do not understand it well enough to know what to change. Has anyone else run into this or have suggestions on where to look?
57  Using Arduino / Programming Questions / Re: load EEPROMAnything library on: July 13, 2012, 08:01:44 pm
Thank you for the help, I never would have figured that out! Changing the library so it looks for WProgram.h instead of Arduino.h fixed it and it now compiles in 0023.
58  Using Arduino / Programming Questions / Re: load EEPROMAnything library on: July 13, 2012, 06:08:27 pm
I am using 023 because the breadboard bootloader I am using has trouble with 1.01 for reasons that I can not explain. However, I did consider that I and I tried the IDE 1.01 with the same results.
59  Using Arduino / Programming Questions / Re: load EEPROMAnything library on: July 13, 2012, 04:56:12 pm
I thought it might be helpful f I post the error I am getting as well so here it is.

Code:
In file included from sketch_jul13b.cpp:2:
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:2:46: error: Arduino.h: No such file or directory
In file included from sketch_jul13b.cpp:2:
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h: In function 'int EEPROM_writeAnything(int, const T&)':
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:6: error: expected initializer before '*' token
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:9: error: 'p' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h: In function 'int EEPROM_readAnything(int, T&)':
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: 'byte' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: 'p' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: expected primary-expression before ')' token
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: expected primary-expression before 'void'


60  Using Arduino / Programming Questions / load EEPROMAnything library on: July 13, 2012, 03:10:47 pm
I am looking for a way to store variables in the event the Arduino is rebooted. I got the built in EEPROM working but it only stores values from 0-255 and I need to be able to store larger values. I found the EEPROMAnything library here

http://arduino.cc/playground/Code/EEPROMWriteAnything.

However this is my first time trying to load a new library and it is giving me trouble. I followed the instructions and saved this code as EEPROMAnything.h and put it in a new folder I created called EEPROMAnything under the libraries section.
Code:
#include <EEPROM.h>
#include <Arduino.h>  // for type definitions

template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
    const byte* p = (const byte*)(const void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
          EEPROM.write(ee++, *p++);
    return i;
}

template <class T> int EEPROM_readAnything(int ee, T& value)
{
    byte* p = (byte*)(void*)&value;
    unsigned int i;
    for (i = 0; i < sizeof(value); i++)
          *p++ = EEPROM.read(ee++);
    return i;
}

After that I reboot the IDE and try to compile the sample code from the playground which does not compile. Here is the sample code I am using.

Code:
#include <EEPROM.h>
#include "EEPROMAnything.h"

struct config_t
{
    long alarm;
    int mode;
} configuration;

void setup()
{
    EEPROM_readAnything(0, configuration);
    // ...
}
void loop()
{
    // let the user adjust their alarm settings
    // let the user adjust their mode settings
    // ...

    // if they push the "Save" button, save their configuration
    if (digitalRead(13) == HIGH)
        EEPROM_writeAnything(0, configuration);
}

What confuses me is that the libraries I see have a .h and a .c file and this only has a .h file so I think I am missing something. Or maybe I am putting the .h file in the wrong place? If anyone has suggestions on what I am doing wrong I would appreciate it.
Pages: 1 2 3 [4] 5 6 7