Pages: [1]   Go Down
Author Topic: Locosys LS20031 and Mega ADK  (Read 2492 times)
0 Members and 1 Guest are viewing this topic.
Hamburg, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
im new here and startet programming only a few weeks before. My english is not the best and i hope it's understandable. I got some experience with Basic and Turbo Pascal 6 in school and now started with an Arduino mega ADK. The basic exercises went great so i bought an LS20031. If i got the GPS unit to pin 0 and 1 on the Board (RX => TX / TX => RX) i could read some data with GPS Fox oder MiniGPS @ 57600-baud. But the example for TinyGPS doesn't work so I used an FTDI Breakout Board and changed the gps to 1Hz and 4800-baud and the sentence GPRMC and GPGGA.
Since the change the Data with only GPS-TX connected to the RX are fine, with RX and TX connected sometimes the new line signal got lost and instead there are strange signs (like a wrong baud in the serial monitor).

Quote from: Only TX
$GPGGA,203619.000,5341.2901,N,01008.3782,E,1,7,1.02,42.9,M,45.8,M,,*6F
$GPRMC,203619.000,A,5341.2901,N,01008.3782,E,1.02,133.48,211211,,,A*61
$GPGGA,203620.000,5341.2901,N,01008.3789,E,1,7,1.02,42.9,M,45.8,M,,*6E
$GPRMC,203620.000,A,5341.2901,N,01008.3789,E,1.01,127.36,211211,,,A*6F
$GPGGA,203621.000,5341.2897,N,01008.3794,E,1,7,1.02,43.1,M,45.8,M,,*64
$GPRMC,203621.000,A,5341.2897,N,01008.3794,E,0.67,128.16,211211,,,A*60
$GPGGA,203622.000,5341.2893,N,01008.3798,E,1,7,1.02,43.0,M,45.8,M,,*6E


With the Example from the TinyGPS Libary the only Lines apperaring in the Serial Monitor window are these but nothing about the position.
Quote
Testing TinyGPS library v. 10
by Mikal Hart

Sizeof(gpsobject) = 103
(Only TX GPS => RX Arduino), i've tried to find a mistake now for two weeks but i've no idea where to search now, i hope someone could help me.

The Example sketch:
Code:
#include <TinyGPS.h>
#include <NewSoftSerial.h>


/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of NewSoftSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 2(rx) and 3(tx).
*/

TinyGPS gps;
NewSoftSerial nss(2, 3);

void gpsdump(TinyGPS &gps);
bool feedgps();
void printFloat(double f, int digits = 2);

void setup()
{
  Serial.begin(9600);
  nss.begin(4800);
 
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS));
  Serial.println();

}

void loop()
{
  bool newdata = false;
  unsigned long start = millis();

  // Every 5 seconds we print an update
  while (millis() - start < 5000)
  {
    if (feedgps())
      newdata = true;
  }
 
  if (newdata)
  {
    Serial.println("Acquired Data");
    Serial.println("-------------");
    gpsdump(gps);
    Serial.println("-------------");
    Serial.println();
  }
}

void printFloat(double number, int digits)
{
  // Handle negative numbers
  if (number < 0.0)
  {
     Serial.print('-');
     number = -number;
  }

  // Round correctly so that print(1.999, 2) prints as "2.00"
  double rounding = 0.5;
  for (uint8_t i=0; i<digits; ++i)
    rounding /= 10.0;
 
  number += rounding;

  // Extract the integer part of the number and print it
  unsigned long int_part = (unsigned long)number;
  double remainder = number - (double)int_part;
  Serial.print(int_part);

  // Print the decimal point, but only if there are digits beyond
  if (digits > 0)
    Serial.print(".");

  // Extract digits from the remainder one at a time
  while (digits-- > 0)
  {
    remainder *= 10.0;
    int toPrint = int(remainder);
    Serial.print(toPrint);
    remainder -= toPrint;
  }
}

void gpsdump(TinyGPS &gps)
{
  long lat, lon;
  float flat, flon;
  unsigned long age, date, time, chars;
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned short sentences, failed;

  gps.get_position(&lat, &lon, &age);
  Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
 
  feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors

  gps.f_get_position(&flat, &flon, &age);
  Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  feedgps();

  gps.get_datetime(&date, &time, &age);
  Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print(" Time(hhmmsscc): "); Serial.print(time);
  Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

  feedgps();

  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  Serial.print("Date: "); Serial.print(static_cast<int>(month)); Serial.print("/"); Serial.print(static_cast<int>(day)); Serial.print("/"); Serial.print(year);
  Serial.print("  Time: "); Serial.print(static_cast<int>(hour)); Serial.print(":"); Serial.print(static_cast<int>(minute)); Serial.print(":"); Serial.print(static_cast<int>(second)); Serial.print("."); Serial.print(static_cast<int>(hundredths));
  Serial.print("  Fix age: ");  Serial.print(age); Serial.println("ms.");
 
  feedgps();

  Serial.print("Alt(cm): "); Serial.print(gps.altitude()); Serial.print(" Course(10^-2 deg): "); Serial.print(gps.course()); Serial.print(" Speed(10^-2 knots): "); Serial.println(gps.speed());
  Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): "); printFloat(gps.f_course()); Serial.println();
  Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): ");  printFloat(gps.f_speed_mph());
  Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): "); printFloat(gps.f_speed_kmph()); Serial.println();

  feedgps();

  gps.stats(&chars, &sentences, &failed);
  Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: "); Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed);
}
 
bool feedgps()
{
  while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}

greetings from germany
Arne
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am having troubles with TinyGPS with possibly the same reason.

Here is what I concluded:

If it wont print your "Acquired Data" it may be because newdata is never set to true.
And this again might be due to feedgps() never gets set to true.
And this might be due to gps.encode().

I changed.
Quote
bool feedgps()
{
  while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}
to
Quote
bool feedgps()
{
  if (nss.available())
  {
    ctemp=nss.read();
    Serial.print(ctemp);
    gps.encode(ctemp);
      return true;
  }
  return false;
}

So changing the code leeds to receiving the characters the nmea setence, posting them to serial and posting the "Aquired data" part in between, yet the Aquired data is trash.

My conclusion. gps.enable() fails to write into gps structure.

Probaly also your problem. Has anyone out there an idea?



Greetings from germany aswell

Ps.: I am using, an Arduino Duemilanove and arduino 1.0, and you?
Ps2: I had to make a change in TinyGPS.h WProgram.h to Arduino.h to be able to compile under 1.0
« Last Edit: January 24, 2012, 02:09:23 am by Migeria » Logged

Hamburg, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
i use the Mega ADK with Arduino 023 or 022 but i tried Arduino 1.0 too.
I got it work by using one of the onboard Serial Ports. I don't know the Duemilanove but i think only the Mega Boards has 4 Serial interfaces.
Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I am having the same problem it looks like everyone else is having.
I am sorry if this is not in the format that everyone is used to, but I am trying to make sure it’s readable.

First I started off over at Sparkfun's Tutorial >> http://www.sparkfun.com/tutorials/176 to see what I could find on this subject. I am using the 1.0 IDE so I did some modification on their code (which they posted) so the Arduino 1.0 IDE would work with their "Quick-Test" example >>

Quote
/*********** Quick_Test_for_LS20031 GPS *******************
The circuit:
Pin assignments for the LS20031 GPS:
• GPS Pin 5 (left-most when viewed from above) : No connection (or ground)
• GPS Pin 4 : to Arduino ground (GND) pin
• GPS Pin 3 : to Arduino pin 0
• GPS Pin 2 : No connection
• GPS Pin 1 (right-most when viewed from above) : to Arduino 3.3V pin
*/
void setup(){
  Serial.begin(57600);  
}

void loop() {
  static int headcount;
  if (Serial.available()) {
    #if ARDUINO >= 100 //---------------------------------- FOR ARDUINO IDE 1.0
    Serial.write(Serial.read());
    #else //--------------------------------------------------- FOR ARDUINO IDE <.23
    Serial.print(Serial.read(), BYTE);
    #endif
   }
   }
 }


That gave me clean NMEA sentences. Which looked like this >>
Code:
$GPRMC,183446.600,A,4751.6605,N,12142.3934,W,0.01,241.74,140212,,,A*7C
$GPVTG,241.74,T,,M,0.01,N,0.01,K,A*39
$GPGGA,183446.800,4751.6605,N,12142.3934,W,1,6,2.24,63.6,M,-16.9,M,,*53
$GPGLL,4751.6605,N,12142.3934,W,183446.800,A,A*44
$GPGSA,A,3,03,18,06,19,22,27,,,,,,,3.38,2.24,2.53*0B
$GPGSV,3,1,12,18,69,061,37,22,63,252,45,06,52,253,42,21,51,114,21*7F
$GPGSV,3,2,12,03,46,270,46,48,33,195,29,15,30,051,21,19,29,311,35*71
$GPGSV,3,3,12,14,19,186,16,27,16,069,22,09,13,095,,16,05,246,16*70
$GPRMC,183446.800,A,4751.6605,N,12142.3934,W,0.01,241.74,140212,,,A*72

Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In case you have not heard: Mikal Hart has pointed out, over at his web site { http://arduiniana.org/libraries/tinygps/ , that if you are using Arduino 1.0 IDE, the TinyGPS 12 is now compatible with the 1.0 IDE. Also you will want to use SoftwareSerial that comes with the 1.0 IDE, instead of the NewSoftSerial.

So next I wanted to see what SoftwareSerial was putting out being feed by the Locosys LS20031 GPS module.
This is where things don’t looked so good. I am using part of Lady Ada “Goodnight Moon!” code from Adafruit.com here. Also I am using part of Mikal Hart’s example that is a lot more easy to read in the setup, then what comes with TinyGPS’s example code >>

Quote
#include <SoftwareSerial.h>
#define RXPIN 3 // From the GPS to the Arduino
#define TXPIN 4 
SoftwareSerial mySerial(RXPIN, TXPIN);

/*   
  The Circuit:
   Pin assignments for the LS20031 GPS:
   • GPS Pin 5 (left-most when viewed from above) : No connection (or ground)
   • GPS Pin 4 : to Arduino ground (GND) pin
   • GPS Pin 3 : to Arduino pin 3
   • GPS Pin 2 : No connection
   • GPS Pin 1 (right-most when viewed from above) : to Arduino 3.3V pin
*/

void setup() 
{
  Serial.begin(115200);// old 57600 New 115200
  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(57600); // old 4800 new 57600
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available()){
    Serial.write(mySerial.read());
    }
}

And this is what I was getting from my GPS >>

Code:
Goodnight moon!
$GPGGA,210344.400,4751.6581,N,12142.3932,W,1,8,1.23,35.8,M,-16.9,M,,*5D
$GPGLL,4751.6581,N,1214™—™œ32,W,210344.400,A,A*4D
$GPG1, ª$GPGGA,210344.600,4751.6581,N,12142.3932,W,1,8,1.23,35.8,M,-16.9,M,,*5F
$GPGLL,4751.6581,N,1214™—™932,W,210344.600,A,A*4F
$GPG13Yª$GPGGA,210344.800,4751.6581,N,12142.3932,W,1,8,1.23,35.8,M,-16.9,M,,*51
$GPGLL,4751.6581,N,12142.3932,W,210344.800,A,A*41
$GPG&AÆ©$GPGGA,210345.000,4751.6581,N,12142.3932,W,1,8,1.23,35.8,M,-16.9,M,,*58
$GPGLL,4751.6581,N,12142.3932,W,210345.000,A,A*48
$GPG&ªª$GPGGA,210345.200,4751.6581,N,12142.3932,W,1,8,1.23,35.8,M,-16.9,M,,*5A
$GPGLL,4751.6581,N,1214™—™932,W,210345.200,A,A*4A
$GPG13Yª$GPGGA,210345.400,4751.6581,N,12142.3932,W,1,8,1.23,35.8,M,-16.9,M,,*5C
$GPGLL,4751.6581,N,12142.3932,W,210345.400,A,A*4C
$GPG ¢
Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Even with that mess I can get the example code that came with TinyGPS to work most of the time. Again I did some modification to reflect what Mikal had posted on his web page >>

Code:
#include <SoftwareSerial.h>

#include <TinyGPS.h>
#define RXPIN 3 // From the GPS to the Arduino
#define TXPIN 4 

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   57600-baud serial GPS device hooked up on pins (tx) and 3(rx).
   
  The Circuit:
   Pin assignments for the LS20031 GPS:
   • GPS Pin 5 (left-most when viewed from above) : No connection (or ground)
   • GPS Pin 4 : to Arduino ground (GND) pin
   • GPS Pin 3 : to Arduino pin 3
   • GPS Pin 2 : No connection
   • GPS Pin 1 (right-most when viewed from above) : to Arduino 3.3V pin
*/

TinyGPS gps;
SoftwareSerial nss( RXPIN, TXPIN); // refects what Mikal Hart has on his TinyGPS web page- helps in knowing which is RX and which is TX.
static void gpsdump(TinyGPS &gps);
static bool feedgps();
static void print_float(float val, float invalid, int len, int prec);
static void print_int(unsigned long val, unsigned long invalid, int len);
static void print_date(TinyGPS &gps);
static void print_str(const char *str, int len);

void setup()
{
  Serial.begin(115200);
  nss.begin(57600); // ----------- old value: 4800, NEW Value for the Locosys LS20031 GPS module >> 57600
 
  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS));
  Serial.print("Serial Buffer size =");Serial.println(_SS_MAX_RX_BUFF);
  Serial.println();
  Serial.println("Sats HDOP Latitude Longitude Fix  Date       Time       Date Alt     Course Speed Card  Distance Course Card  Chars Sentences Checksum");
  Serial.println("          (deg)    (deg)     Age                        Age  (m)     --- from GPS ----  ---- to London  ----  RX    RX        Fail");
  Serial.println("--------------------------------------------------------------------------------------------------------------------------------------");
}

void loop()
{
  bool newdata = false;
  unsigned long start = millis();
 
  // Every second we print an update
  while (millis() - start < 1000)
  {
    if (feedgps())
      newdata = true;
  }
 
  gpsdump(gps);
}

static void gpsdump(TinyGPS &gps)
{
  float flat, flon;
  unsigned long age, date, time, chars = 0;
  unsigned short sentences = 0, failed = 0;
  static const float LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
 
  print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);
  print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);
  gps.f_get_position(&flat, &flon, &age);
  print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 9, 5);
  print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 10, 5);
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);

  print_date(gps);

  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 8, 2);
  print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);
 
  // Ternary operation --> condition ? value_if_true : value_if_false
  print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6);
  print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0UL : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : TinyGPS::course_to(flat, flon, 51.508131, -0.128002), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);

  gps.stats(&chars, &sentences, &failed);
  print_int(chars, 0xFFFFFFFF, 6);
  print_int(sentences, 0xFFFFFFFF, 10);
  print_int(failed, 0xFFFFFFFF, 9);
  Serial.println();
}

static void print_int(unsigned long val, unsigned long invalid, int len)
{
  char sz[32];
  if (val == invalid)
    strcpy(sz, "*******");
  else
    sprintf(sz, "%ld", val);
  sz[len] = 0;
  for (int i=strlen(sz); i<len; ++i)
    sz[i] = ' ';
  if (len > 0)
    sz[len-1] = ' ';
  Serial.print(sz);
  feedgps();
}

static void print_float(float val, float invalid, int len, int prec)
{
  char sz[32];
  if (val == invalid)
  {
    strcpy(sz, "*******");
    sz[len] = 0;
        if (len > 0)
          sz[len-1] = ' ';
    for (int i=7; i<len; ++i)
        sz[i] = ' ';
    Serial.print(sz);
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    // Ternary operation >>condition ? value_if_true : value_if_false
    int flen = prec + (val < 0.0 ? 2 : 1);
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
      Serial.print(" ");
  }
  feedgps();
}

static void print_date(TinyGPS &gps)
{
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned long age;
  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  if (age == TinyGPS::GPS_INVALID_AGE)
    Serial.print("*******    *******    ");
  else
  {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d   ",
        month, day, year, hour, minute, second);
    Serial.print(sz);
  }
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
  feedgps();
}

static void print_str(const char *str, int len)
{
  int slen = strlen(str);
  for (int i=0; i<len; ++i) // Ternary operation --> condition ? value_if_true : value_if_false
    Serial.print(i<slen ? str[i] : ' ');
  feedgps();
}

static bool feedgps()
{
  while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }
  return false;
}

My only issue now is how to break the date and time out of TinyGPS so I can use it.

I have a color coded version of this that makes it really easy to read and see how things relate. I just didn't want to take up the whole fung shway space here. If anyone would like me to post it, let me know.

Here's what the output looked like >>

Code:
Testing TinyGPS library v. 12
by Mikal Hart

Sizeof(gpsobject) = 115
Serial Buffer size =128

Sats HDOP Latitude Longitude Fix  Date       Time       Date Alt     Course Speed Card  Distance Course Card  Chars Sentences Checksum
          (deg)    (deg)     Age                        Age  (m)     --- from GPS ----  ---- to London  ----  RX    RX        Fail
--------------------------------------------------------------------------------------------------------------------------------------
8    143  47.86102 -121.7065030   00/00/2000 21:46:45   34   42.80   ****** ***** ***   7651     34.66  NE    1065  7         1       
8    143  47.86102 -121.7065036   00/00/2000 21:46:47   39   42.80   ****** ***** ***   7651     34.66  NE    2004  14        1       
8    143  47.86102 -121.7065051   00/00/2000 21:46:48   55   42.80   ****** ***** ***   7651     34.66  NE    2942  21        1       
8    143  47.86102 -121.7065057   00/00/2000 21:46:50   62   42.80   ****** ***** ***   7651     34.66  NE    3880  28        1       
8    143  47.86102 -121.7065070   00/00/2000 21:46:51   73   42.80   ****** ***** ***   7651     34.66  NE    4818  35        1       
9    116  47.86102 -121.7065083   00/00/2000 21:46:52   86   42.80   ****** ***** ***   7651     34.66  NE    5757  42        1       
9    116  47.86102 -121.7065096   00/00/2000 21:46:54   100  42.80   ****** ***** ***   7651     34.66  NE    6768  50        1       
9    116  47.86102 -121.706504    00/00/2000 21:46:55   7    42.70   ****** ***** ***   7651     34.66  NE    7761  57        1       
9    116  47.86102 -121.7065023   00/00/2000 21:46:57   26   42.70   ****** ***** ***   7651     34.66  NE    8699  64        1       
9    116  47.86102 -121.7065044   00/00/2000 21:46:58   48   42.70   ****** ***** ***   7651     34.66  NE    9637  71        1       
9    116  47.86102 -121.7065062   00/00/2000 21:47:00   66   42.70   ****** ***** ***   7651     34.66  NE    10578 78        1       
9    116  47.86102 -121.7065082   00/00/2000 21:47:01   85   42.70   ****** ***** ***   7651     34.66  NE    11516 85        1       
« Last Edit: March 04, 2012, 04:48:00 pm by BlackLab1 » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  if (mySerial.available()){
    Serial.write(mySerial.read());
    }
Why are you using a function that sends binary data to send ASCII data?

Have you looked at the return type for SoftwareSerial::read(), and compared that to the expected input for the Print::write() method? They don't match!
Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You’re scaring me. If I understand right that the requirement under 1.0 IDE. It has to do with this >>

http://arduino.cc/blog/2011/10/04/arduino-1-0/
Quote
The behavior of Serial.print() on a byte has been changed to align it with the other numeric data types. In particular, it will now print the digits of its argument as separate ASCII digits (e.g. ’1′, ’2′, ’3′) rather than a single byte. The BYTE keyword has been removed. To send a single byte of data, use Serial.write() (which is present in Arduino 0022 as well).

You might also want to read { http://blog.makezine.com/2011/12/01/arduino-1-0-is-out-heres-what-you-need-to-know/ } >>

Quote
Working with byte datatypes
 print(byte)now prints the integer value of the byte as ASCII characters, previous releases sent the actual character. This affects Serial, Ethernet, Wire or any other library that has a class derived from the Print class. Change:
Code:
Serial.print(byteVal)

To:
Code:
Serial.write(val); //send as char

The BYTE keyword
 The BYTE keyword is no longer supported. Change:

Code:
Serial.print(val, BYTE)
To:
Code:
Serial.write(val); //sends as char

Sure there is this >>

Quote
Return values from write() methods
Classes derived from Print must implement a write method to write data to the device that the class supports. The signature of the write method has changed from void to size_t to return the number of characters written. If you have a class derived from Print you need to modify the write method as follows and return the number of characters written (typically 1). Change:
 
Code:
void write
To:
 
Code:
size_t write

But I am not trying to pass anything back through the write() function. Maybe I am miss understanding what you are saying.

If you want to find where I got part of this code take a look under the 1.0 IDE examples under SoftwareSerialExample. The tag “Goodnight moon!”, It's used a lot on lady Ada web site- and part of my idea of using this code came from her. I will admit that I changed the baud rate, and added some comments. what I am trying to say is I found some code on her site and rearranged it. I took out the char c = Serial.read(), and put it into the mySerial.Write(c) statement. Other than that I didn’t play with it much. Yeah, maybe I should type cast the Serial.read() statement, char, but I shouldn't have to. (Though I will try it, just to see if I can get cleaner output.) I will admit I am rusty when it comes to C++, but I am trying to follow what I found in the examples.

Blacklab
« Last Edit: March 05, 2012, 02:55:58 pm by BlackLab1 » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
To send a single byte of data, use Serial.write() (which is present in Arduino 0022 as well).
You are not sending a byte, though. You are sending a char, which is what the print() function is designed for.
Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Code I found originally said >>

Code:
void loop(){
if (mySerial.available()){
    char c = mySerial.read();  
Serial.write(c);
    }
}

Yeah I would agree that type casting it so it would read >>

Code:
if (mySerial.available()){
    Serial.write( char(mySerial.read());
    }

would have been better. But I am still getting junk even with that correction.
But the type casting is not the issue with what's wrong with how softwareSerial is sending data to TinyGPS.

Also here is the code that comes with Arduino 1.0 IDE's SoftwareSerialExample that I have been talking about >>

Code:
// Example from SoftwareSerialExample
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);

void setup()  
{
  Serial.begin(57600);
  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

If this is wrong then we need to bring this to the attention of the heads of state of Arduino.

<EDIT> what Mikal Hart said to me the problem has to do with the GPS module we are talking about here. It's putting data out too fast for softwareSerial to handle (baud:57600).
I have no clue if that is true or not. I think he's right. But that does not explain why I got Ver 9 of TinyGPS and the NewSoftSerial ver? to work under Arduino 0022 IDE. The only thing I had to do was to increase the buffer size in NewSoftSeral from 64 to 128.
So what I am after is "what changed?" And how can I get back to things working again.
« Last Edit: March 05, 2012, 03:21:41 pm by BlackLab1 » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So, can you just humor me. Try:
Code:
void loop()
{
  if (mySerial.available())
  {
    char c = mySerial.read();   
    Serial.print(c);
  }
}
Notice that c is NOT a byte. It is the same size as a byte, but it is a char, which is a completely different type.
Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tired that Paul and I still get junk inside of my output. Though I will have to admit the first two lines do look a little cleaner. {I am not talking about the first line mess- that's normal. I am talking about the two afterwards.}

Code:
Goodnight moon!
LMLK)¢b¢ÂÆÁÕâb’¢RºªjR":¨´*Š‰’bŠšbŠŠb¢šb&¢ŠbšÊb’‚b’Âb’ʪƚ’b’’b’¢bŠŠ‚b’šÆ’ªbŠ’b‚ºšbRººjRF:MY±Ñ±Í±ŠšbŠºÆ‚Êbš’¢b’ÊbŠ’b‚ÂƂš²bb’$GPGGA,205556.200,4751.6561,N,12142.3936,W,1,8,1.25,43.3,M,-16.9,M,,*5C
$GPGLL,4751.6561,N,12142.3936,W,205556.200,A,A*40
$GPG1*b‚$GPGGA,205556.400,4751.6561,N,12142.3936,W,1,8,1.25,43.3,M,-16.9,M,,*5A
$GPGLL,4751.6561,N,12142.3936,W,205556.400,A,A*46
$GPG,bª$GPGGA,205556.600,4751.6561,N,12142.3936,W,1,8,1.25,43.3,M,-16.9,M,,*58
$GPGLL,4751.6561,N,12142.3936,W,205556.600,A,A*44
$GPSiš²$GPGGA,205556.800,4751.6561,N,12142.3936,W,1,8,1.25,43.3,M,-16.9,M,,*56
$GPGLL,4751.6561,N,12142.3936,W,205556.800,A,A*4A
$GPGGSbA$GPGGA,205557.000,4751.6561,N,12142.3936,W,1,8,1.25,43.3,M,-16.9,M,,*5F
$GPGLL,4751.6561,N,12142.3936,W,205557.000,A,A*43
$GPG,*‚,$GPGGA,205557.200,4751.6561,N,12142.3936,W,1,8,1.25,43.3,M,-16.9,M,,*5D
$GPGLL,4751.6561,N,12142.3936,W,205557.200,A,A*41
$GPG&Rbb$GPGGA,205557.400,4751.6561,N,12142.3936,W,1,8,1.25,43.3,M,-16.9,M,,*5B
$GPGLL,4751.6561,N,12142.3936,W,205557.400,A,A*47
$GPG,Sb²$GPGGA,205557.600,4751.6561,N,12142.3936,W,1,8,1.25,43.3,M,-16.9,M,,*59
$GPGLL,4751.6561,N,12142.3936,W,205557.600,A,A*45
$GPG
,HA©$GPGGA,205557.800,4751.6561,N,12142.3936,W,1,8,1.25,43.3,M,-16.9,M,,*57
$GPGLL,4751.6561,N,12142.3936,W,205557.800,A,A*4B

But as I said Mikal Hart said our baud rate is too high for SoftwareSerial to handle (57600). All I was after was to see what SoftwareSerial puts out.
Please note that I do appreciate what you’re pointing out. Just I am a little confused by what you’re telling me. And your right Type Casting would make sure the compiler knew what read() put's out is a char and not a byte.

<edit> grr at myself… I need to clarify myself here as to why I am willing to go through all this head ache to see what SoftwareSerial is putting out. What’s happening inside of that example from TinyGPS is part of it is working, other parts are not. I want to see what TinyGPS is seeing. I remember when I bought my GPS from Sparkfun people were talking about changing the baud rate on the GPS. You can do that but to go from the Arduino to the GPS you have to use an BOB-08745 Logic Level Converter or something like it. I don’t remember all what you have to do to send it the correct programming codes to change to baud rate, but that’s what I remember what others were doing.

That still does not change the fact that I was able to get TinyGPS ver 9 to work with what I had with out chaning the baud rate with Ardunio 0022 IDE, and changing the buffer size in the NewSoftSerial from 64 to 128. In my project I am just after the time and date from the GPS. The Time Library from Arduino.cc is pre 1.0 IDE, and it also has some major problems with it. It never prints anything out, even if you correct things like channging NewSoftSerial over to SoftwareSerial. {I hope I got that right- with reading so much I tend to get things mixed up.}  I think there are a few other things that need to be fix, but it still does not work right.
« Last Edit: March 05, 2012, 04:17:46 pm by BlackLab1 » Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also
Mike hart said >>

Quote
@Dave and anyone else with the general question “Why do I get XXX data just fine but YYY is invalid or not there?”, it’s hard to answer the question without seeing the data stream that TinyGPS is given. Remember that TinyGPS just parses the data you give it. If HDOP doesn’t show up it probably means that it either isn’t provided in the NMEA sentences that you unit is sending you, or possibly that those sentences have become corrupt somehow.
 
Either way, the easiest way to debug is to display the raw NMEA sentences. In the test_with_gps_device sample, this means changing feedgps from
Code:
  while (nss.available())
  {
    if (gps.encode(nss.read()))
      return true;
  }
 
to
Code:
  while (nss.available())
  {
    char c = nss.read();
    Serial.write(c);
    if (gps.encode(c))
      return true;
  }
 
Post your output and we’ll take a look.
 
Mikal

The reason I am re-posting from his web site is because this is another way of seeing what SoftwareSerial is putting out. The only thing with this example is it's harder to see how the NMEA sentence is put together. At least when I did it, it was just a jumbled mess.

I am going to suggest substituting this code for his last code. Only because then all you have to do is add #define DEBUG at the top of your code to turn it on, or //define DEBUG to turn it off >>

Code:
static bool feedgps()
{
  while (nss.available())
    {
     #ifdef DEBUG
      char c = nss.read();
      Serial.write(c);
      if (gps.encode(c))
        return true;
     #else
     if (gps.encode(nss.read()))
      return true;
     #endif
    }
  return false;
}
« Last Edit: March 05, 2012, 04:52:57 pm by BlackLab1 » Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

BTW...

For those who are having a problem with not getting the date out of TinyGPS. If you can get TinyGPS to spit out the NMEA sentences like Mikal Hart has suggested- look for
$GPRMC in your sentences, It it’s not there you will not see a date.

There was a nice person who told me to go back to Sparkfun and take a look at their product page on this subject {
 http://www.sparkfun.com/products/8975 and see about what people were talking about the Locosys' LS2003x. Well I went looking for the datasheet for this item and could not find anything that was official about the $PMTK251 command to change the baud rate for the LS2003x. So I did some digging and found Locosys updated datasheet v 1.3 which this time around they included a whole bunch of Easter Eggs about the LS2003x. If you go to their page http://www.locosystech.com/product.php?zln=en&id=20 , and if you click on the down load tab and sign in their web page you can get to the v 1.3 datasheet for the LS2003x GPS. It has a heck of a lot of good information inside of it about the LS2003x GPS (and the way it looks some of the info could be used for other GPS units).  

What causing our problem with no DATE is that TinyGPS is not seeing $GPRMC sentences. Now here’s the weird part coming from SoftwareSerial: I ran TinyGPS and spit out more than 300+ lines of NMEA sentences and not once did I see a RM or MC next to each other in all those lines. My thinking is: If you get things scrambled you should get something that IDs or looks like the $GPRMC. You have to have a RM or MC or R or M or a C to get $GPRMC. It makes me wonder why or what SoftwareSerial is doing to prevent $GPRMC from showing up. But it’s not just not showing up with the beginning (or preamble) of $GPRMC sentence, the whole sentence is missing. These sentences come in a order (over and over, over), and from what I can tell SoftwareSerial loves $GPGLL and tries to merge $GPGGA with something else. That kind of explains why I am seeing so many other people not getting the DATE too. I think it's also why so many people are having problems with TinyGPS (though I will be on the record that it's not TinyGPS fault). Also makes you wonder what else SoftwareSerial is not telling us. My gut is telling me there is something favoring why we are not seeing $GPRMC, and I am not sure how to follow the trail.

You can see the fact that $GPRMC is not showing up from the NMEA sentences I post above.

Just some food for thought...
Blacklab1


From Locosys >>
5 Software interface
5.1 NMEA output message
Table 5.1-1 NMEA output message
_____________________________________________________
NMEA record     |      Description
_____________________________________________________
GGA                   |     Global positioning system fixed data < ---
_____________________________________________________
GLL                     |     Geographic position - latitude/longitude
_____________________________________________________
GSA                    |      GNSS DOP and active satellites
_____________________________________________________
GSV                    |      GNSS satellites in view
_____________________________________________________
RMC                    |      Recommended minimum specific GNSS data  < ---
_____________________________________________________
VTG                     |      Course over ground and ground speed
_____________________________________________________

More information on the GGA:    
GGA--- Global Positioning System Fixed Data
Table 5.1-2 contains the values for the following example:

$GPGGA,053740.000,2503.6319,N,12136.0099,E,1,08,1.1,63.8,M,15.2,M,,0000*64

Table5.1- 2 GGA Data Format
__________________________________________________________________________
 Name                    |      Example        |  Units   |           Description pink
__________________________________________________________________________
Message ID               |   $GPGGA          |                |     GGA protocol header
__________________________________________________________________________
UTC Time                 |   053740.000      |                |     hhmmss.sss
__________________________________________________________________________
Latitude                     |  2503.6319         |               |     ddmm.mmmm
__________________________________________________________________________
N/S indicator             |          N               |               |    N=north or S=south
__________________________________________________________________________
Longitude                 |  12136.0099         |               |   dddmm.mmmm
__________________________________________________________________________
E/W Indicator              |        E                |               |    E=east or W=west
__________________________________________________________________________
Position Fix Indicator   |        1                |                |    See Table 5.1-3
__________________________________________________________________________
Satellites Used           |       08                 |               |   Range 0 to 12
__________________________________________________________________________
HDOP                        |      1.1                |                |    Horizontal Dilution of Precision
__________________________________________________________________________
MSL Altitude              |      63.8               |  mters     |
__________________________________________________________________________
Units                          |          M               |  mters     |
__________________________________________________________________________
Geoid Separation        |      15.2               |  mters    |
__________________________________________________________________________
Units                           |          M               |  mters     |
__________________________________________________________________________
Age of Diff. Corr.        |                            | second   | Null fields when DGPS is not used
__________________________________________________________________________
Diff. Ref. Station ID    |    0000                |                |      
__________________________________________________________________________
Checksum                  |    *64                  |                 |
__________________________________________________________________________
<CR> <LF>                  |                          |                 |  End of message termination
__________________________________________________________________________

[
« Last Edit: March 10, 2012, 04:10:49 pm by BlackLab1 » Logged

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Table 5.1-3 Position Fix Indicators
_________________________________
Value  |   Description
_________________________________
0              |  Fix not available or invalid
_________________________________
1              |  GPS SPS Mode, fix valid
_________________________________
2              |  Differential GPS, SPS Mode, fix valid
_________________________________
3-5           |  Not supported
_________________________________
6              |  Dead Reckoning Mode, fix valid


More information on the RMC:
RMC---Recommended Minimum Specific GNSS Data
Table 5.1-9 contains the values for the following example:
$GPRMC,053740.000,A,2503.6319,N,12136.0099,E,2.69,79.65,100106,,,A*53

Table 5.1-9 RMC Data Format
__________________________________________________________________________
Name                         |    Example    |  Units   | Description
__________________________________________________________________________
Message ID               |  $GPRMC       |               |  RMC protocol header
__________________________________________________________________________
UTC Time                  |  053740.000 |               |  hhmmss.sss
__________________________________________________________________________
Status                        |          A         |               |  A=data valid or V=data not valid
__________________________________________________________________________
Latitude                     |  2503.6319   |                |  ddmm.mmmm
__________________________________________________________________________
N/S Indicator            |         N           |               |  N=north or S=south
__________________________________________________________________________
Longitude                  | 12136.0099  |                |  dddmm.mmmm
__________________________________________________________________________
E/W Indicator            |         E           |                |  E=east or W=west
__________________________________________________________________________
Speed over ground     |  2.69                | knots      | True
__________________________________________________________________________
Course over ground   |  79.65              | degrees   |   
__________________________________________________________________________
Date                        | 100106          |                |  ddmmyy
__________________________________________________________________________
Magnetic variation    |                       | degrees |
__________________________________________________________________________
Variation sense         |                      |                |  E=east or W=west (Not shown)
__________________________________________________________________________
Mode                        |         A            |               |   A=autonomous, D=DGPS, E=DR, N=Data not valid,
                               |                       |               |   R=Coarse Position, S=Simulator
__________________________________________________________________________
Checksum                 |       *53           |               |
__________________________________________________________________________
<CR> <LF>              |                        |               |   End of message termination
__________________________________________________________________________

Logged

Pages: [1]   Go Up
Jump to: