Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 19
61  Using Arduino / Programming Questions / Re: How can an Arduino crash? on: June 16, 2011, 04:13:30 pm
Hmm but I do read first the data into a buffer until a new line "\r" does show up. This gets then parsed by the code.

There is a mistake with the  while(x < 20 && millis() <= (milliSMS + 200)) this routine is just to clear the buffer of
sms_number to store the new number. Actually I don't need this one because it gets overwritten by the new number...

by the way the parsing works I can decode those message with this code...
62  Using Arduino / Programming Questions / Re: How can an Arduino crash? on: June 16, 2011, 09:55:06 am
The code is just too big but here is a part of my GSM data parsing.


Code:
void readGSM(int val){

  while(Serial1.available() > 0){
    if(unlock_sms==0){
      ReadSerial[0]=Serial1.read();
      if(debug > 1)
        Serial.print( ReadSerial[0]);

      if(ReadSerial[0]=='\n' || ReadSerial[0]=='*' || ReadSerial[0] == '+'){
        unlock_sms=1;
      }
    }
    else{
      ReadSerial[counter]=Serial1.read();
      if(debug > 1)
        Serial.print(ReadSerial[counter]);
      if(ReadSerial[counter] == '\r'){
        unlock_sms=0;

        if (strncmp(ReadSerial, "+CMTI:",6) == 0){
          char *parseptr_read = ReadSerial+7;
          parseptr_read = strchr(parseptr_read, ',') + 1;
          char *token = strtok_r(parseptr_read, ",", &brkb);
          int value = atol(token);

          send_serial("AT+CMGF=1");
          delay(50);
          Serial1.print("AT+CMGR=");
          Serial1.println(value);
        }


        if (strncmp(ReadSerial, "CMGR:",5) == 0){
          char *parseptr_read = ReadSerial+6;
          parseptr_read = strchr(parseptr_read, ',') + 2;
          //sms_number = strtok_r(parseptr_read, "\"", &brkb);
          //Serial.println(sms_number);

          int cou=0;
          int cou1 = 0;

          int x = 0;
          unsigned long milliSMS = millis();
          while(x < 20 && millis() <= (milliSMS + 200)){
            sms_number[x] = 0;
            x++;
          }

          milliSMS = millis();

          while(parseptr_read[cou1] != '"' && millis() <= (milliSMS + 1000)){
            if(parseptr_read[cou1] == '+'){
              sms_number[cou] = '0';
              cou++;
              sms_number[cou] = '0';
            }
            else{
              sms_number[cou] = parseptr_read[cou1];
            }
            cou++;
            cou1++;
          }
          if(debug > 0){
            Serial.println();
            Serial.print("-> SMS from: ");
            Serial.println(sms_number);
          }
        }

        if (strncmp(ReadSerial, "NORMAL POWER DOWN",17) == 0) {
          Serial.println("-> GSM OFF");
        }

        if (strncmp(ReadSerial, "+CFUN: 1",8) == 0) {
        }

        if (strncmp(ReadSerial, "Call Ready",10) == 0) {
        }

        if (strncmp(ReadSerial, "0",1) == 0){
          if(debug > 0)
            Serial.println("-> OK");
          if(val == 1)
            sms_send_best = 1;
        }
        if (strncmp(ReadSerial, "+CRING:",7) == 0 && calling < 1){
          if(debug > 0)
            Serial.println("-> ding dong");
        }

        if (strncmp(ReadSerial, "+CMS ERROR: 515",15) == 0){
          if(debug > 0)
            Serial.println("-> PS Busy....");
        }


        if (strncmp(ReadSerial, "+CLIP:",6) == 0){
          char *parseptr_read = ReadSerial+8;
          int cou=0;
          unsigned long milliSMS = millis();
          while(parseptr_read[cou] != '"' && millis() <= (milliSMS + 200)){
            calling_number[cou] = parseptr_read[cou];
            cou++;
          }
          if (calling == n_of_calling){
            send_serial("ATH");
            calling = 0;
            sms_senden = 2;
          }
          else{
            calling++;
          }
        }

        if (strncmp(ReadSerial, "3",1) == 0){
          Serial.println("-> NO CARRIER");
          calling = 0;
        }
        if (strncmp(ReadSerial, "4",1) == 0){
          Serial.println("-> ERROR");
        }
        if (strncmp(ReadSerial, "6",1) == 0){
          Serial.println("-> NO DIALTONE");
        }
        if (strncmp(ReadSerial, "7",1) == 0){
          Serial.println("-> BUSY");
        }
        if (strncmp(ReadSerial, "8",1) == 0){
          Serial.println("-> CONNECT OK / NO ANSWER");
        }

        for(int a=0; a<=counter; a++){
          ReadSerial[a]=0;
        }
        counter=0;
      }
      else{
        counter++;
        if (counter == (BUFFSIZ-1)){
          counter = 0;
          break;
        }
      }
    }
  }
}

maybe there is a better way...
The "ReadSerial" variable is a 120 Char so it might be too big...

63  Using Arduino / Programming Questions / Re: How can an Arduino crash? on: June 14, 2011, 05:24:04 pm
for the GPS decoding I use the "tinygps" library.
Mine isn't running continuously just for about ~10hours and gets
afterwards switched off...
64  Using Arduino / Programming Questions / Re: How can an Arduino crash? on: June 14, 2011, 04:15:17 pm
I tested the device several or better many many times and it old worked very well until
today where it got stuck...
The while loop is the only thing I do know directly so that was also the reason why asked
you here what other problems could occur...


65  Using Arduino / Programming Questions / Re: How can an Arduino crash? on: June 14, 2011, 03:54:35 pm
I know, but I just asked if there is a possibility that the program stops without a loop that is running mad.

Could it be an Available Memory problem (to large char's)? but my tests showed it does just reset itself...

66  Using Arduino / Programming Questions / Re: How can an Arduino crash? on: June 14, 2011, 03:40:27 pm
I can't show the code but there are only to while loops for checking whether there is serial data or not so one
is while (Serial1.available()) the other with serial2. So this shouldn't create that kind of stop...
67  Using Arduino / Programming Questions / How can an Arduino crash? on: June 14, 2011, 03:32:42 pm
Hy

The title maybe a bit strange but I got following problem:

My device has some LEDs with an GPS and GSM modem.
The LEDs just light up when the GPS has a Fix otherwise they switch off.
With a call to the Arduino I get the actual GPS position. Now after testing it for
several month!!! The Arduino got stuck the first time.
That means that even if I put int into a room the LEDs for the GPS fix still stays on
and when I call it I won't get anything.

So I checked my code and there is no while loop where the program could stop.

So I'm asking myself how this could happen. What are other possibilities???

thx
Andy


68  Using Arduino / Programming Questions / Re: Arduino does a self reset on: May 11, 2011, 12:49:18 pm
hmm tryed to use the sketch from
http://www.arduino.cc/en/Reference/PROGMEM
Code:
/*
 PROGMEM string demo
 How to store a table of strings in program memory (flash),
 and retrieve them.

 Information summarized from:
 http://www.nongnu.org/avr-libc/user-manual/pgmspace.html

 Setting up a table (array) of strings in program memory is slightly complicated, but
 here is a good template to follow. Setting up the strings is  a two-step process.
 First define the strings.

 */

#include <avr/pgmspace.h>

char string_0[] PROGMEM = "String 0";   // "String 0" etc are the strings to store - change them to your text.
char string_1[] PROGMEM = "String 1";
char string_2[] PROGMEM = "String 2";
char string_3[] PROGMEM = "String 3";
char string_4[] PROGMEM = "String 4";
char string_5[] PROGMEM = "String 5";


// Then set up a table to refer to your strings.

PGM_P PROGMEM string_table[] =    // change string_table to anything you wish
{
  string_0,
  string_1,
  string_2,
  string_3,
  string_4,
  string_5 };

char buffer[30];    // make sure this is large enough for the largest string it must hold

void setup()
{
  Serial.begin(19200);
      Serial.println( "Test" );
}


void loop()
{
  /* Using the string table in program memory requires the use of special functions to retreive the data.
   The strcpy_P function copies a string from program space to a string in RAM. Make sure your receiving string
   in RAM is large enough to hold whatever you are retreiving from Program space.
   There is some neccessary casts and dereferencing going on, just follow the template.  */

  for (int i = 0; i < 6; i++)
  {
    strcpy_P(buffer, (char*)pgm_read_word(&(string_table[i])));
    Serial.println( buffer );
    delay( 500 );
  }
}
 

but when I look into the Serial Monitor it does always reset after the Setup routine has called.
So I just see my "Test" in the serial monitor....

I do use Arduino 0022 and an Arduino Mega 1280...
What's wrong with the code?

thx
69  Using Arduino / Programming Questions / Re: Arduino does a self reset on: May 07, 2011, 05:37:12 pm
I would like to be more precise of course but my research shows that I can't force the reset by sending a huge message or with lots of special characters so it's kinda random....
Code:
while(Serial1.available() > 0){
  if(unlock_sms==0){
    bufferReadGSM[0]=Serial1.read();
    if(debug > 1)
      Serial.print(bufferReadGSM[0]);

    if(bufferReadGSM[0]=='\n' || bufferReadGSM[0]=='*' || bufferReadGSM[0] == '+'){
      unlock_sms=1;
    }
  }
  else{
    bufferReadGSM[counter]=Serial1.read();
    if(debug > 1)
      Serial.print(bufferReadGSM[counter]);
    if(bufferReadGSM[counter] == '\r'){
      unlock_sms=0;


      if (strncmp(bufferReadGSM, "*121*",5) == 0){
        char *parseptr_read = bufferReadGSM+5;
        int cou = 0;
        int value = int(parseptr_read[0])-48;   

        switch (value){
        case 1:
          sms_senden = 1;
          break;
        case 2:
          SmsMeldungOff = 1;
          if(debug > 0)
            Serial.println("-> SMS senden werden abgestellt");
          break;
        case 3:
          GSMoffStart = 1;
          if(debug > 0)
            Serial.println("-> GSM wird abgestllt, vor dem Start");
          break;
        case 4:
          wichtigeVariablen = 1;
          sms_senden = 1;
          if(debug > 0)
            Serial.println("-> Wichtige variablen werden gesendet");
          break;
        }
      }
      if (strncmp(bufferReadGSM, "Call Ready",10) == 0) {
        Serial.println("-> GSM Ready!");
      }

      if (strncmp(bufferReadGSM, "0",1) == 0){
        if(debug > 0)
          Serial.println("-> OK");
      }
      if (strncmp(bufferReadGSM, "+CRING:",7) == 0 && calling < 1){
        if(debug > 0)
          Serial.println("-> ding dong");
      }

      if (strncmp(bufferReadGSM, "3",1) == 0){
        Serial.println("-> NO CARRIER");
        calling = 0;
      }
      if (strncmp(bufferReadGSM, "4",1) == 0){
        Serial.println("-> ERROR");
      }
      if (strncmp(bufferReadGSM, "6",1) == 0){
        Serial.println("-> NO DIALTONE");
      }
      if (strncmp(bufferReadGSM, "7",1) == 0){
        Serial.println("-> BUSY");
      }
      if (strncmp(bufferReadGSM, "8",1) == 0){
        Serial.println("-> CONNECT OK / NO ANSWER");
      }

      for(int a=0; a<=counter; a++){
        bufferReadGSM[a]=0;
      }
      counter=0;
    }
    else{
      counter++;
      if (counter == bufferSize){
        counter = 0;
        if (debug > 1)
          Serial.println("-> Buffer uerblauf");
        Serial1.flush();
      }
    }
  }
}
70  Using Arduino / Programming Questions / Re: Arduino does a self reset on: May 07, 2011, 05:20:49 pm
thx for the advice,

I will post some code as soon as possible.
I use a Arduino Mega 1280 so should have some more RAM.
Can I determine how much RAM is used during a sketch is running?

Thx
Andy
71  Using Arduino / Programming Questions / Arduino does a self reset on: May 07, 2011, 07:19:33 am
hy

I got a GSM Module hooked up to the arduino. I do parse the SMS
that get in from the Module and do some things afterwards.

Sometimes it can happen that a message does come in and the
Arduino does self reset and starts again in the void Setup().

Why does this happen? It can't be a buffer overflow I got a big
buffer and a routine to determine when a buffer does overflow...

Thx
Andy
72  Using Arduino / Networking, Protocols, and Devices / Re: GPS Satellite problem on: April 07, 2011, 12:17:36 am
I do use the Antenna Antenna GPS Embedded SMA http://www.sparkfun.com/products/177 from Sparkfun...
Are there better antennas in the same size range?

Thx
Andy
73  Using Arduino / Networking, Protocols, and Devices / GPS Satellite problem on: April 06, 2011, 12:30:57 pm
Hy

Got a GPS (Copernicus Module from Sparkfun) connected to an Arduino. Everything works find that means that I get
the NMEA sentence but it won't find any satellites.
But when I touch the Antenna or a metal part it does discover immediately the
satellites.
What's the problem?

Thx
Andy
74  Using Arduino / General Electronics / Re: measure battery voltage on: March 08, 2011, 01:11:51 am
Do you have a link to that DC/DC converter? I'm wondering if it could be an isolated converter (no ground continuity from input to outout) ?  If not, can you use a ohm better and see if the negitive in and out pins show continuity?

 The first way you showed it wired up should work if it's not a isolated converter. Not sure about it being a noise issue or not, only a scope would verify that or not.


Lefty


The converter is this one.
http://www.bodhilabs.com/vpackbareaaa.html

Do you know a better one?
75  Using Arduino / General Electronics / Re: measure battery voltage on: March 07, 2011, 04:23:41 pm


R1=56k
R2=15k

Battery is 4.1V
Arduino gives me back: 1.94V this would mean =7.24V?????

(If I calculated right the Arduino should read 0.866V or am I wrong?)
Pages: 1 ... 3 4 [5] 6 7 ... 19