[vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”What is GPS” tab_id=”1388387938-1-21″][vc_column_text]1. What is GPS?
The Global Positioning System (GPS) is a space-based satellite navigation system that provides location and time information in all weather conditions, anywhere on or near the Earth where there is an unobstructed line of sight to four or more GPS satellites.The system provides critical capabilities to military, civil and commercial users around the world. It is maintained by the United States government and is freely accessible to anyone with a GPS receiver.
2. Structure
The current GPS consists of three major segments. These are the space segment (SS), a control segment (CS), and a user segment (US).
The space segment is composed of 24 to 32 satellites in medium Earth orbit and also includes the payload adapters to the boosters required to launch them into orbit. The control segment is composed of a master control station, an alternate master control station, and a host of dedicated and shared ground antennas and monitor stations. The user segment is composed of hundreds of thousands of U.S. and allied military users of the secure GPS Precise Positioning Service, and tens of millions of civil, commercial, and scientific users of the Standard Positioning Service[/vc_column_text][/vc_tab][vc_tab title=”Introduction of GPS Shield” tab_id=”1388387938-2-26″][vc_column_text]LinkSprite Arduino GPS shield is a GPS module breadout board designed for Global Positioning System receiver with SD interface. It is easy to use for recording the position data into SD card. 5V/3.3V compatible operation voltage level make it compatible with Arduino boards, leaf maple, IFlat32 and other arduino compatible boards.
Features
- With Micro SD interface
- Active antenna design with high receive sensitivity, compatible normal antenna
- Extremely fast time to first fix at low signal level
- UART interface
- Operation temperature: -40℃ ~ +85℃
[/vc_column_text][/vc_tab][vc_tab title=”Arduino IDE test code” tab_id=”1388450512757-2-8″][vc_column_text]Note,
If use USE_EXT_SDCARD macro definition, the data will save to GPS Shield’s SD card. You need use another SD library instead of the default one. You can it from here. Unzip the downloaded file and copy it to “ /usr/share/arduino/libraries”, cover the default SD library. Before you do this, you can back up the default SD library. And you also need download the file Pritht.h(here) and copy to “/usr/share/arduino/hardware/arduino/pcduino/cores/arduino”.
If do not use USE_EXT_SDCARD macro definition, the data will save to pcDuino’s RAM. In this condition, you cannot clink the “Run” button. Find the gps.cpp file in /home/ubuntu/Arduino and run it in Terminal. And a datalog.txt file will be created in /home/ubuntu/Arduino. Open this file, you will find GPS data.
Arduino IDE
Test Code
#include <core.h> //#define USE_EXT_SDCARD #ifdef USE_EXT_SDCARD #include <SD.h> Sd2Card card; SdVolume volume; SdFile root; #define chipSelect 10 void setup() { uint32_t volumesize; SD.begin(chipSelect); if (!card.init(4, chipSelect)) { printf ( "initialization failed. Things to check:\n" ); printf ( "* is a card is inserted?\n" ); printf ( "* Is your wiring correct?\n" ); printf ( "* did you change the chipSelect pin to match your shield or module?\n" ); //return; } else printf ( "Wiring is correct and a card is present.\n" ); printf ( "\nCard type: " ); switch (card.type()) { case SD_CARD_TYPE_SD1: printf ( "SD1\n" ); break ; case SD_CARD_TYPE_SD2: printf ( "SD2\n" ); break ; case SD_CARD_TYPE_SDHC: printf ( "SDHC\n" ); break ; default : printf ( "Unknown\n" ); break ; } // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32 if (!volume.init(card)) { printf ( "Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card\n" ); return ; } printf ( "Volume type is FAT%d\n" ,volume.fatType()); volumesize = volume.blocksPerCluster(); // clusters are collections of blocks volumesize *= volume.clusterCount(); // we'll have a lot of clusters volumesize *= 512; // SD card blocks are always 512 bytes printf ( "Volume size (bytes): T%d\n" ,volumesize); volumesize /= 1024; printf ( "Volume size (Kbytes): T%d\n" ,volumesize); volumesize /= 1024; printf ( "Volume size (Mbytes): T%d\n" ,volumesize); if (root.openRoot(volume) == false ) { printf ( "Root Open Failed!" ); return ; } printf ( "Files found on the card (name, date and size in bytes):" ); // list all files in the card with date and size root.ls((LS_R | LS_DATE | LS_SIZE),8); root.close(); printf ( "\n" ); Serial.begin(9600); } void loop() { // make a string for assembling the data to log: unsigned int index = 0; char temp = 0; String dataString = "" ; File dataFile = SD.open( "datalog.txt" , 0x42); if (dataFile) { while (Serial.available()) { temp = Serial.read(); printf ( "%c" ,temp); dataString += String(temp); index++; if (index > 200) break ; } dataFile.print(dataString); dataFile.close(); } else printf ( "Failed to Open LogFile!!\n" ); } #else //use local memory #include<fcntl.h> #include<string> using std::string; void setup( void ) { Serial.begin(9600); } long GetFileSize( FILE * fp) { long pos; long posHis; if (!fp) return 0; posHis = ftell (fp); fseek (fp,0L,SEEK_END); pos = ftell (fp); fseek (fp,posHis,SEEK_SET); return pos; } void loop() { // make a string for assembling the data to log: int index = 0; char *buffer; long tmpLong; FILE *dataFile = fopen ( "./datalog.txt" , "rt+" ); if (!dataFile)dataFile = fopen ( "./datalog.txt" , "w" ); if (dataFile) { tmpLong = GetFileSize(dataFile); if (tmpLong >= (512*128)) fseek (dataFile,0L,SEEK_SET); else fseek (dataFile,0L,SEEK_END); printf ( "File Size is 0x%08x\n" ,tmpLong); buffer = ( char *) malloc (512); if (!buffer) { printf ( "Memory Allocatino Failed!!\n" ); return ; } while (Serial.available()) { buffer[index++] = Serial.read(); printf ( "%c" ,buffer[index - 1]); if (index > 400) break ; } buffer[index]= '\n' ; fwrite (buffer,index,1,dataFile); fclose (dataFile); free (buffer); } else printf ( "Failed to Open LogFile!!\n" ); } #endif |
[/vc_column_text][/vc_tab][vc_tab title=”Running screenshot” tab_id=”1388453023562-3-3″][vc_column_text]Save the GPS data to pcDuino’s Onboard Storage
Save the GPS data to the SD card of GPS Shield
[/vc_column_text][/vc_tab][vc_tab title=”Hardware installation drawing” tab_id=”1388453531890-4-8″][vc_column_text]I am text block. Click edit button to change this text.[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.