Pages: [1]   Go Down
Author Topic: Why are we receiving strange characters with gps?  (Read 1256 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys, we have been working with our gps module for arduino, and arduino decimilia.  We have tried some codes that is supposed it works, and we receive strange characters like cirylian characters and squares, ? etc...

can you help us please??

Thank you so much!!!
Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks to me like there is something wrong.

If you'd like a less vague answer, give a less vague description of the problem: provide us with output samples, a description of the circuit (or even better, a schematic), code, etc.

-j

Logged

Forum Administrator
Offline Offline
Newbie
*****
Karma: 3
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

most likely you're looking at the data at the wrong serial speed...

Off the top of my head GPS modules run at4800 baud make sure you're using that speed

BTW I second the opinion that the more detail you provide about your problem the better the reply.

massimo
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm having the same problem as Airman and several people from the thread on the EM-406.

Here are the details:

I'm getting this output on the Ardunio Environment console:


In an attempt to trouble shoot, I've cut down the software serial code and the example gps code by Bigengineer to this:

Code:
#include <string.h>
#include <ctype.h>

#define bit4800Delay 188
#define halfBit4800Delay 94

byte rx = 6;

void setup() {
pinMode(rx,INPUT);
Serial.begin (4800);
Serial.println("Working so far!");
}

void loop()
{
byte val = 0;
byte final_val = 0;
  while (digitalRead(rx));
  if (digitalRead(rx) == LOW)
  {
    delayMicroseconds(halfBit4800Delay);
    for (int offset = 0; offset < 8; offset++)
      {
      delayMicroseconds(bit4800Delay);
      val |= digitalRead(rx) << offset;
      }
  Serial.print(val, BYTE);
  }
}

I'm using an EM-406 connected on digital 6, 5v and Ground:


(larger version here)

I've tried powering the Arduino via USB and external 9v DC. As well I've tried powering the EM-406 from the Arduino 5v or an external power supply regulated down to 5v DC. In the case of the external EM-406 power, nothing transmitted unless the external ground was connected to the Ardunio Ground. In all cases, the output is unreadable like the posted picture.

The Arduino seems to run other code fine and the EM-406 returns accurate location data when connected to SparkFun's GPS Evaluation Board.

I'm running Windows XP and I've tried compiling and uploading with Arduino Environment Alpha 0010 and 0009. I get the same output data using the Arduino Environment, HyperTerminal and PuTTY. As the debug message in setup() demonstrates, my connection to the Arduino works. I've got my terminal programs set at 4800 bps, 8 bits, no parity, 1 stop bit, no flow control. My hardware COM properties match this.

The EM-406 operates at 4800 bps. The data sheet is a little confusing, it says the EM-406 works at "TTL level, Output voltage level: 0V ~ 2.85v RS-232 level." The Arduino operates TTL at 5v I think, but I'm not sure if these differences matter.

SparkFun has a data sheet on their EM-406 product page if it helps.

Any thoughts what the problem is?
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Shouldn't  these two line be swapped:

      delayMicroseconds(bit4800Delay);
      val |= digitalRead(rx) << offset;

right now when rx pin goes low you wait for "half a bit" then enter the for loop, and wait for "a whole bit" before reading the first bit.

Should you not read the first bit before waiting ?

Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's not a surprise you get nothing without a ground; a signal is a voltage, and a voltage is in reference to something - ground is that "something".  Some devices, for whatever reasons, require multiple connections to ground.  You'd think they could do that internally, but sometimes the designers have good reasons not to do so, like the ATmega's GND and AGND pins.

The GPS datasheet says 2.85V output on TX, but the ATmega's input high voltage is 0.6*Vcc, which is 3V for a 5V arduino.  Your signal never really goes high as far as the arduino is concerned, so there's your problem.

You'll need some extra hardware to convert from 2.8V logic to 5V logic.  There are specific ICs (level translators) to do the job.  There are also tricks with transistors, pull-up resistor circuits, diodes, and so forth.  The "tricks" rely on knowing something about the technology in the interface.  I'm a bit weak on this subject, so I'm not going to offer any advice on quick and easy tricks.

One solution is to use a TTL/RS232 transceiver at 2.85V (the Sparkfun eval board you reference uses 3.3V) to get the signals to true RS232 levels, then use another TTL/232 transceiver (like MAX232)  on the arduino side to go from true RS232 to 5V TTL.  This is requires several components, but it is straightforward and those components are something you may have on hand.

The data sheet is really weak on actual data.  Hopefully your GPS will accept 5V inputs and you haven't fried something by driving it with 5V on the RX pin.

-j

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys, thank you for your answers.  I have been working on that, and the problem was the speed rate in the library.  Now I receive the message "Configurando gps..." forever and ever.  I think the problem could be, the configuration sentence.  Anyone of you can say me if the sentence I have in my code is universal one, or I need to configure anything else?

the code is that one, and the sentence is highlighted:

/*******************************************
* Program for reading possition from GPS
* module via the softwareSerial
*
* M. Yarza
* Oct 2.007 Zaragoza
*******************************************/

// include the SoftwareSerial library
#include <SoftwareSerial.h>

// Constants
#define rxPin 0
#define txPin 1

// set up the serial port

SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);

// variables
byte byteGPS = 0;
int i = 0;
int indices[13];
int cont = 0;
int conta = 0;

char inBuffer[300] = "";

int k = 0;

void setup(){

  //setup for mySerial port
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  mySerial.begin(4800);
  
  //setup for Serial port
  Serial.begin(4800);

  // setup the GPS module
  Serial.println("Configurando GPS...");
  delay(1000);
  mySerial.println([glow]"$PSTMNMEACONFIG,0,4800,1,1"[/glow]);        // configure NMEA sentences to show only GGA                                                                                                                                                                                                                                
                                                                                           //sentence
  delay(100);
  
  // command for setting time and position
  mySerial.println("$PSTMINITGPS,4140.000,N,00053.000,W,0197,22,10,2007,11,40,00");    

  // "4140.000,N" means: Latitude 41º40'00.0" North
  // "00053.000,W" means: Longitude 0º53'00.0" West
  // "0197" means 197 m elevation
  // "22,10,2007,11,40,00" means date and time (October 22, 2.007 - 11h 40min 00sec UTC time)
}

void loop(){
 
  byteGPS = 0;
  i = 0;
  while(byteGPS != 42){                   // read the GGA sentence
    byteGPS = mySerial.read();        
    inBuffer=byteGPS;              
    i++;                      
  }
  
  k = 1;
  while(inBuffer[k] != 42){
    Serial.print(inBuffer[k]);            // write the GGA sentence
     k++;
  }
  Serial.println();
  delay(3000);
}
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That code has software serial set to transmit on pin 1.

It looks from the picture like its actually connected to pin6 or 7.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for your help, but the image is not from my gps, it is another guy who posted that.  Our rx and tx is setted according to the board.

If you can help us, we will thank you sincerely
Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Now I receive the message "Configurando gps..." forever and ever.
Since you only print that message in setup(), this sounds like a program or board that's resetting continuously.

Quote
Code:
#define rxPin 0
#define txPin 1

This looks like a problem: the ATmega's USART (hardware serial port) is on pins 0 and 1, and it appears you have it connected to a computer (via Arduino's built-in USB).  If you are also putting your software serial port on those pins, things will be very confused.  You may not have the GPS wired to pins 0 and 1, but the code you posted definitely has software serial tied to the hardware serial pins.

Maybe you can verify which pins are physically connected to the GPS, and which pins are in the SoftwareSerial() call?

-j

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, Ive checked and I have the gps wired to 0 and 1, but I cannot check the softwareserial call.  I have been looking for that, and in CPP file only says receivePin and transmitPin with nothing else.  If you can explain me how to check the softwareserial call maybe I can do that.   Thank you very much, and I apologize for my lack of knowledgement of arduino.

thank you again!!!!
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The GPS should not be wired to pins 0 and 1 if you are using software serial. You can use any free pins from 2 and higher. It doesn't matter which you choose, but the pin you wire to the GPS receiver input must the same number as you define as your software serial Transmit pin in your sketch, and the pin wired to the GPS transmitter must be define as your software serial Receive pin
« Last Edit: March 03, 2008, 01:26:21 pm by mem » Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, what mem said.  look at the code you posted previously:

Quote
Code:
// Constants
#define rxPin 0
#define txPin 1
 
// set up the serial port
 
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);  

Here you are using pins 0 and 1 for your software serial.  You must use some other pins, since the ATmega's USART and the USB chip are already using these two.  I would sugest using the pins you actually have the GPS wired to...

-j

Logged

Pages: [1]   Go Up
Jump to: