Show Posts
|
|
Pages: 1 2 3 [4] 5 6 ... 18
|
|
46
|
Using Arduino / Displays / 2.8" TFT Touch Shield
|
on: July 13, 2011, 09:00:14 am
|
Hy I just got the new 2.8 TFT Touch Shield from SeeedStudio: http://www.seeedstudio.com/depot/28-tft-touch-shield-p-864.html?cPath=132_134First I used the sketch below which worked great. Then I added a few Rectangles and more circles but suddenly the Screen stayed white even after disconnecting from the Arduino and reattaching. I then just tried the example sketch but the Display stays white.... I tried several things but still it won't change anything... Is the Display already dead? // Draw Circles - Demonstrate drawCircle and fillCircle APIs
#include <stdint.h> #include <TouchScreen.h> #include <TFT.h> #define SEEEDUINO
#define YP A2 // must be an analog pin, use "An" notation! #define XM A1 // must be an analog pin, use "An" notation! #define YM 14 // can be a digital pin, this is A0 #define XP 17 // can be a digital pin, this is A3
void setup() { Serial.begin(19200);
Tft.init(); //init TFT
Tft.drawCircle(100, 100, 30,YELLOW); Tft.drawCircle(100, 200, 40,CYAN); Tft.fillCircle(200, 100, 30,RED); Tft.fillCircle(200, 200, 30,BLUE); }
void loop() {
}
|
|
|
|
|
47
|
Using Arduino / Programming Questions / Re: How can an Arduino crash?
|
on: June 17, 2011, 01:37:55 am
|
Thx for the explenation. Thats why I use: counter++; if (counter == (BUFFSIZ-1)){ counter = 0; break; }
so if counter for the buffer is equal to the BUFFSIZ, the counter value gets back to 0 and the buffer won't get over its edge. The Message in the buffer will be worthless but in general i do send just SMS with 10 characters to the Arduino so every other SMS it gets will be rejected.... But can someone tell me how to parse the Information from a GSM Module. Not every sentence will start with a $ sign like the GPS they are different. Sometimes they start with "+" or "/n" or even "*"....
|
|
|
|
|
48
|
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...
|
|
|
|
|
49
|
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. 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...
|
|
|
|
|
51
|
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...
|
|
|
|
|
52
|
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...
|
|
|
|
|
53
|
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...
|
|
|
|
|
54
|
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
|
|
|
|
|
55
|
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/* 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
|
|
|
|
|
56
|
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.... 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(); } } } }
|
|
|
|
|
58
|
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
|
|
|
|
|
60
|
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
|
|
|
|
|