Pages: [1]   Go Down
Author Topic: GPS 7 Segment speedometer  (Read 3664 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello guys I am newbe here! I need your help with a code for running a PARALLAX GPS MODULE PMB-648 with arduino  duemilanove. I need to extract the NMEA data, just the speed mph and print it to a seven segment display. I am using a 4-digit LED-driver with I^2C-Bus interface SAA106.
I have only basic computer skills loops and switches. Pin TXD in the module goes to RX pin in arduino, but I am not so sure if that is the way is suppose to be connected, and I believe I am suppose to connect the SDA and CLK pins of the IC to pin number 4 and 5 analog input in the arduino. The PDF contains the slave address for the IC. The only code example i have is from arduino playground extracting GPS data I will appreciate a complete code if that is not too much to ask. I attached a picture of the 4-Digit LED-driver and the GPS module.
GPS module http://www.microcenter.com/single_product_results.phtml?product_id=0377206
4-digit LED-Driver http://www.nxp.com/documents/data_sheet/SAA1064_CNV.pdf

Code:
/*
 Example code for connecting a Parallax GPS module to the Arduino

 */
 #include <string.h>
 #include <ctype.h>
 int ledPin = 13;                  // LED test pin
 int rxPin = 0;                    // RX PIN
 int txPin = 1;                    // TX TX
 int byteGPS=-1;
 char linea[300] = "";
 char comandoGPR[7] = "$GPRMC";
 int cont=0;
 int bien=0;
 int conta=0;
 int indices[13];
 void setup() {
   pinMode(ledPin, OUTPUT);       // Initialize LED pin
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   Serial.begin(4800);
   for (int i=0;i<300;i++){       // Initialize a buffer for received data
     linea[i]=' ';
   }   
 }
 void loop() {
   digitalWrite(ledPin, HIGH);
   byteGPS=Serial.read();         // Read a byte of the serial port
   if (byteGPS == -1) {           // See if the port is empty yet
     delay(100);
   } else {
     linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
     conta++;                     
     Serial.print(byteGPS, BYTE);
     if (byteGPS==13){            // If the received byte is = to 13, end of transmission
       digitalWrite(ledPin, LOW);
       cont=0;
       bien=0;
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
           bien++;
         }
       }
       if(bien==6){               // If yes, continue and process the data
         for (int i=0;i<300;i++){
           if (linea[i]==','){    // check for the position of the  "," separator
             indices[cont]=i;
             cont++;
           }
           if (linea[i]=='*'){    // ... and the "*"
             indices[12]=i;
             cont++;
           }
         }
         Serial.println("");      // ... and write to the serial port
         Serial.println("");
         Serial.println("---------------");
         for (int i=0;i<12;i++){
           switch(i){
             case 0 :Serial.print("Time in UTC (HhMmSs): ");break;
             case 1 :Serial.print("Status (A=OK,V=KO): ");break;
             case 2 :Serial.print("Latitude: ");break;
             case 3 :Serial.print("Direction (N/S): ");break;
             case 4 :Serial.print("Longitude: ");break;
             case 5 :Serial.print("Direction (E/W): ");break;
             case 6 :Serial.print("Velocity in knots: ");break;
             case 7 :Serial.print("Heading in degrees: ");break;
             case 8 :Serial.print("Date UTC (DdMmAa): ");break;
             case 9 :Serial.print("Magnetic degrees: ");break;
             case 10 :Serial.print("(E/W): ");break;
             case 11 :Serial.print("Mode: ");break;
             case 12 :Serial.print("Checksum: ");break;
           }
           for (int j=indices[i];j<(indices[i+1]-1);j++){
             Serial.print(linea[j+1]);
           }
           Serial.println("");
         }
         Serial.println("---------------");
       }
       conta=0;                    // Reset the buffer
       for (int i=0;i<300;i++){    // 
         linea[i]=' ';             
       }                 
     }
   }
 }
smiley-roll
Thanks,


* gpsmodule.Jpg (49.01 KB, 641x343 - viewed 21 times.)

* ic2.JPG (32.77 KB, 640x480 - viewed 23 times.)
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You have velocity in Knots, you just need to convert to MPH (*1.15077).
I can't help you with the complete code though, what's the point of the project if not to learn about the platform and technology you're using? Couldn't you just buy a GPS-based speedo if you wanted a finished product?
Tutorial for the GPS module http://arduino.cc/playground/Tutorials/GPS
Tutorial for the Display http://tronixstuff.wordpress.com/2011/07/21/tutorial-arduino-and-the-nxp-saa1064-4-digit-led-display-driver/
Logged

ਪੰਜਾਬ
Offline Offline
Edison Member
*
Karma: 12
Posts: 1601
Another year! Alone! :(
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I will say if you are doing a project to learn, you take it up yourself , However i also made a LCD speedometer here >> http://winacro.com/index.php?option=com_content&view=article&id=47 you may get something in terms of other idea's , It;s not driven by GPS
Logged

"Real Men can Accomplish  Anything"
-  Website  
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੂਂ !

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

Hello guys, Thank you for taking the time to help me with my project. I had a problem with the Serial.print(byteGPS, BYTE); I replaced it with Serial.write(byteGPS) because serial print was not suported as of arduino version 1.0. I ran the code and the serial monitor only displays symbols instead of data. The serial monitor displays this Ã333<?fó??fó333<fóÃ<fÿ. If I take the RX pin out of the arduino the flow of symbols stop so I think I am writing the data just not printing it wright. Can you guys helpme to fix the code to get actual NMEA data.
Regards,
Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1330
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
int rxPin = 0;                    // RX PIN
 int txPin = 1;                    // TX TX


 Those pins are connected to the usb that goes to the computer. If you are using UNO, you need to use NewSoftWareSerial and connect that to the GPS module.

 Other than that the serial monitor has to have the same baud rate that your Arduino is set at.
Logged


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

forget all think gps speedometer,i use 4 year and no good,newer no see real speed and place good.
better way have wheel sensor,odometer and speed.
gps no realti9me and true newer,and how work in cave,other no good place,no newer,i see thats many year,now have new project,real time odo/speed whit LCD.working and true no only "maybe" all data.
Logged

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

Guys, I adjusted the baud rate to 480 bps and now I can see the data in the serial monitor. Latitude, longitude, speed in knots, etc.
The next step is how do i print only the speed information to  the 4-digit LED-driver with I^2C-Bus interface SAA106. how do I start the code to send the information to the IC. What function should I use and how do I called the IC to read the data. I understand I have to give it a command. I will appreciate your help. Sorry for the dumb questions but I am a newbee with Arduino. This is an example code i found. How can I modify it to pass the data only from the speed send it to the IC and print it in hole numbers?
Code:
#include "Wire.h"  // enable I2C bus

byte saa1064 = 0x70 >> 1; // define the I2C bus address for our SAA1064 (pin 1 to GND)

int digits[16]={63, 6, 91, 79, 102, 109, 125,7, 127, 111, 119, 124, 57, 94, 121, 113};
// these are the byte representations of pins required to display each digit 0~9 then A~F

void setup()
{
  Wire.begin(); // start up I2C bus
  delay(500);
  initDisplay();
}

void initDisplay()
// turns on dynamic mode and adjusts segment current to 12mA
{
  Wire.beginTransmission(saa1064);
  Wire.send(B00000000); // this is the instruction byte. Zero means the next byte is the control byte
  Wire.send(B01000111); // control byte (dynamic mode on, digits 1+3 on, digits 2+4 on, 12mA segment current
  Wire.endTransmission();
}
Logged

Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Start with the first step. Read the entire NMEA string into a buffer. Remember that at the end of each NMEA string is a carriage return and a line feed. Read those in also. The last three printable characters should be something like *7A. Well, it will always be the *, the last two bytes are hex codes and this is a checksum for the string. Its important to compare the checksum against the entire string to make sure you read it correctly.

I found a little code that does this here:

http://www.gpspassion.com/forumsen/topic.asp?TOPIC_ID=103972

Once you get that working, you want to parse the speed out and throw the rest away.

Convert speed from knots to MPH.

Then send the speed to the display.

Maybe you can configure your GPS receiver module to only send speed. That would make it easier to parse, but you would still need to verify the checksum.
 
Logged

Pages: [1]   Go Up
Jump to: