Cov txheej txheem:

Nrhiav Koj Txoj Kev Nrog GPS: 9 Kauj Ruam
Nrhiav Koj Txoj Kev Nrog GPS: 9 Kauj Ruam

Video: Nrhiav Koj Txoj Kev Nrog GPS: 9 Kauj Ruam

Video: Nrhiav Koj Txoj Kev Nrog GPS: 9 Kauj Ruam
Video: Lub Zog Nruab Nrog (Hmong Dubbed) 2024, Hlis ntuj nqeg
Anonim
Nrhiav Koj Txoj Kev Nrog GPS
Nrhiav Koj Txoj Kev Nrog GPS

Kev tawm dag zog sai hauv kev nkag siab thiab siv cov ntaub ntawv GPS

  • Lub Sijhawm Xav Tau: 2 Teev
  • Nqe: $ 75 - $ 150

Rau cov neeg tsim khoom, nws tau dhau los ua qhov pheej yig kom suav nrog cov ntaub ntawv geospatial zoo hauv cov phiaj xwm hluav taws xob. Thiab nyob rau ob peb xyoos dhau los, GPS (Cov Txheej Txheem Txheej Txheem Thoob Ntiaj Teb) cov txais cov qauv tau loj hlob ntau dua, muaj zog, thiab yooj yim rau kev koom ua ke nrog cov laug cam txhim kho xws li Arduino, PIC, Teensy, thiab Raspberry Pi. Yog tias koj tau xav txog kev tsim ib puag ncig GPS, koj tau xaiv lub sijhawm zoo los pib.

Kauj Ruam 1: Nws Ua Haujlwm Li Cas

Lub GPS module yog lub xov tooj cua me me uas ua cov teeb liab tshaj tawm ntawm kev paub ntau zaus los ntawm lub nkoj ntawm cov hnub qub. Cov hnub qub no yws ncig lub ntiaj teb nyob rau hauv ib puag ncig ncig, xa cov haujlwm tsis raug thiab cov ntaub ntawv moos mus rau hauv av hauv qab no. Yog tias tus neeg txais lub ntiaj teb tuaj yeem "pom" txaus ntawm cov hnub qub no, nws tuaj yeem siv lawv los xam nws tus kheej qhov chaw thiab qhov siab.

Thaum cov lus GPS tuaj txog, tus txais yuav xub tshuaj xyuas nws lub sijhawm tshaj tawm kom pom thaum nws raug xa mus. Vim tias qhov nrawm ntawm lub xov tooj cua yoj hauv qhov chaw yog qhov paub tas li (c), tus txais tuaj yeem sib piv kev tshaj tawm thiab tau txais lub sijhawm los txiav txim siab qhov deb ntawm lub teeb liab tau mus. Thaum nws tau teeb tsa nws qhov deb ntawm plaub lossis ntau dua lub hnub qub paub, suav nws tus kheej txoj haujlwm yog qhov teeb meem yooj yim ntawm 3D triangulation. Tab sis kom ua qhov no sai thiab raug, tus txais yuav tsum muaj peev xwm nimbly crunch tus lej los ntawm ntau txog 20 cov ntaub ntawv ntws ib zaug. - nyiam dua - yog pom txhua lub sijhawm los ntawm txhua kis hauv ntiaj teb. Tam sim no muaj 32 GPS satellites ua yeeb yam seev cev ua las voos hauv huab huab 20,000 mais siab.

Kauj Ruam 2: Ntxuam Qhov Tseeb

GPS tsis tuaj yeem ua haujlwm yam tsis muaj Einstein txoj kev xav ntawm kev sib raug zoo, vim tias yuav tsum tau them nyiaj rau 38 microseconds lub orbiting atomic clocks nce txhua hnub los ntawm lub sijhawm nthuav dav hauv ntiaj teb lub ntiajteb txawj nqus.

Kauj ruam 3: Pib

Pib Pib
Pib Pib

Xijpeem koj qhov haujlwm, GPS yog qhov yooj yim los ua ke. Feem ntau cov neeg txais cov qauv sib tham nrog cov txheej txheem sib txuas ncaj qha, yog li yog tias koj tuaj yeem pom qhov chaw nres nkoj txuas ntxiv ntawm koj lub rooj tswj hwm, nws yuav tsum siv tsuas yog me me ntawm cov xov hlau los ua lub cev sib txuas. Thiab txawm hais tias tsis yog, cov tswj hwm feem ntau txhawb nqa ib qho "software" serial mode uas koj tuaj yeem siv los txuas rau tus pin yam tsis xav tau.

Rau cov pib tshiab, Adafruit qhov kawg GPS Breakout module yog qhov kev xaiv zoo. Muaj ntau cov khoom lag luam sib tw ntawm kev ua lag luam, tab sis Qhov kawg yog cov khoom ua tau zoo ntawm tus nqi tsim nyog, nrog qhov loj los ntawm qhov uas yooj yim rau solder lossis txuas rau lub khob cij.

Ua ntej, txuas hauv av thiab lub zog. Hauv Arduino cov ntsiab lus, qhov no txhais tau tias txuas ib qho ntawm microcontroller GND pins rau tus qauv GND, thiab +5V tus pin rau tus qauv VIN. Txhawm rau tswj cov ntaub ntawv xa mus, koj kuj yuav tsum txuas tus qauv TX thiab RX pins rau Arduino. Kuv yuav xaiv qhov tsis raug xaiv Arduino pins 2 (TX) thiab 3 (RX) rau lub hom phiaj no, txawm hais tias koob 0 thiab 1 tshwj xeeb tau tsim los siv ua "chaw nres nkoj cov khoom siv txuas" lossis UART. Why? Vim tias kuv tsis xav nkim qhov UART nkaus xwb cov txheej txheem AVR qis-kawg muaj. Arduino's UART yog qhov nyuaj-txuas rau lub onboard USB txuas, thiab kuv nyiam khaws nws txuas nrog kuv lub khoos phis tawj kom debug.

Kauj Ruam 4: Ntiv taw hauv Datastream

Toe hauv Datastream
Toe hauv Datastream

Tam sim koj thov lub zog, GPS module pib xa cov ntawv me me ntawm nws kab kab. Nws tseem yuav tsis tau pom dua ib lub satellite, tsawg dua muaj "kho," tab sis cov kais dej cov ntaub ntawv los tam sim, thiab nws yog qhov txaus siab pom dab tsi tawm. Peb thawj daim duab yooj yim (hauv qab) tsis muaj dab tsi tab sis tso tawm cov ntaub ntawv no uas tsis tau ua tiav.

#suav nrog #define RXPin 2

#define TXPin 3#txhais GPSBaud 4800

#define ConsoleBaud 115200

// Qhov txuas txuas mus rau lub cuab yeej GPSSoftwareSerial ss (RXPin, TXPin);

void teeb tsa () {

Serial.begin (ConsoleBaud);

ss.begin (GPSBaud);

Serial.println ("Piv txwv GPS 1");

Serial.println ("Qhia cov ntaub ntawv NMEA nyoos kis los ntawm GPS module.");

Serial.println ("los ntawm Mikal Hart"); Serial.println ();

}

void lub voj ()

{yog (ss.available ()> 0) // Raws li txhua tus cim tuaj txog …

Serial.write (ss.read ()); //… sau nws mus rau lub console

}

NCO TSEG: Cov duab kos piav qhia tus txais tus pin (RXPin) ua 2, txawm hais tias peb tau hais ua ntej tias tus kis (TX) tus pin yuav txuas nrog tus pin 2. Qhov no yog qhov ua rau tsis meej pem. RXPin yog tus tau txais tus pin (RX) los ntawm Arduino qhov kev xav. Ib qho ntxiv, nws yuav tsum txuas nrog tus qauv hloov pauv (TX) tus pin, thiab hloov pauv.

Tshaj tawm cov duab kos no thiab qhib Serial Monitor ntawm 115, 200 baud. Yog tias txhua yam ua haujlwm, koj yuav tsum pom cov ntais, tsis muaj qhov kawg ntawm cov kab lus sib cais ntawm kab ntawv. Txhua tus yuav zoo ib yam li daim duab thib ob thaum pib ntawm kab lus.

Cov hlua sib txawv no hu ua NMEA kab lus, yog li hu vim tias hom ntawv tau tsim los ntawm National Maritime Electronics Association. NMEA txhais tus lej ntawm cov kab lus no rau cov ntaub ntawv qhia kev mus los ntawm qhov tseem ceeb (qhov chaw thiab sijhawm), mus rau esoteric (satellite teeb liab-rau-suab nrov piv, sib txawv sib nqus, thiab lwm yam). Cov neeg tsim khoom tsis sib xws txog hom kab lus twg uas lawv tau txais, tab sis GPRMC yog qhov tseem ceeb. Thaum koj tus qauv tau txais kev kho, koj yuav tsum pom tus lej ncaj ncees ntawm cov kab lus GPRMC no.

Kauj Ruam 5: Nrhiav Koj Tus Kheej

Nws tsis yog qhov tseem ceeb kom hloov pauv cov khoom siv raw rau hauv cov ntaub ntawv koj qhov program tuaj yeem siv tau. Hmoov zoo, muaj qee lub tsev qiv ntawv zoo uas twb muaj lawm los ua qhov no rau koj. Limor Fried qhov nrov Adafruit GPS Library yog qhov kev xaiv yooj yim yog tias koj siv lawv qhov kawg tawm. Nws tau sau los ua kom muaj cov yam ntxwv tshwj xeeb rau qhov kawg (zoo li kev kaw cov ntaub ntawv sab hauv) thiab ntxiv qee qhov tswb nrov thiab xuav ntawm nws tus kheej. Kuv nyiam cais cov tsev qiv ntawv, txawm li cas los xij - thiab ntawm no kuv yog qhov tseeb kiag li tsis muaj kev ncaj ncees - yog qhov kuv tau sau hu ua TinyGPS ++. Kuv tsim nws kom suav nrog, muaj zog, sib luag, thiab siv tau yooj yim. Cia peb coj nws mus rau qhov tig.

Kauj Ruam 6: Coding Nrog TinyGPS ++

Los ntawm tus programmer pom, siv TinyGPS ++ yog qhov yooj yim heev:

1) Tsim cov khoom gps.

2) Ua txhua tus cim uas tuaj txog ntawm tus qauv mus rau qhov khoom siv gps.encode ().

3) Thaum koj xav paub koj txoj haujlwm lossis qhov siab lossis sijhawm lossis sijhawm, tsuas yog nug cov khoom gps.

#ncig #ncig

#Txhais RXPin 2

#define TXPin 3

#txhais GPSBaud 4800

#define ConsoleBaud 115200

// Qhov txuas txuas mus rau lub cuab yeej GPSSoftwareSerial ss (RXPin, TXPin);

// TinyGPS ++ kwv

TinyGPSPlus gps;

void teeb tsa () {

Serial.begin (ConsoleBaud);

ss.begin (GPSBaud);

Serial.println ("Piv txwv GPS 2");

Serial.println ("Ib qho yooj yim tracker siv TinyGPS ++.");

Serial.println ("los ntawm Mikal Hart");

Serial.println ();

}

void voj () {

// Yog tias muaj cov cim tau los ntawm GPS, /

/ xa lawv mus rau TinyGPS ++ khoom

thaum (ss.available ()> 0)

gps.encode (ss.read ());

// Cia tso saib qhov chaw tshiab thiab qhov siab

// thaum twg los xij ntawm ib qho ntawm lawv tau hloov kho tshiab

yog (gps.location.isUpdated () || gps.altitude.isUpdated ())

{

Serial.print ("Qhov chaw:");

Serial.print (gps.location.lat (), 6);

Serial.print (",");

Serial.print (gps.location.lng (), 6);

Serial.print ("Qhov siab:");

Serial.println (gps.altitude.meters ());

}

}

Peb daim ntawv thov thib ob txuas ntxiv qhia tus txais qhov chaw nyob thiab qhov siab, siv TinyGPS ++ los pab nrog kev cais tawm. Hauv lub cuab yeej tiag tiag, koj tuaj yeem teev cov ntaub ntawv no rau SD daim npav lossis tso tawm ntawm lub LCD. Lob lub tsev qiv ntawv thiab kos duab FindingYourself.ino (saum toj no). Nruab ib lub tsev qiv ntawv, raws li ib txwm muaj, hauv Arduino cov tsev qiv ntawv nplaub tshev. Xa cov duab kos rau koj Arduino thiab qhib Serial Monitor ntawm 115, 200 baud. Koj yuav tsum pom koj qhov chaw nyob thiab qhov siab tshaj kho dua tshiab ntawm lub sijhawm. Txhawm rau pom qhov tseeb koj nyob qhov twg, muab tshuaj txhuam qee qhov ua tiav latitude/longitude coordinates rau hauv Google Maps. Tam sim no nqes koj lub laptop thiab mus taug kev lossis tsav tsheb. (Tab sis nco ntsoov khaws koj ob lub qhov muag ntawm txoj kev!)

Kauj Ruam 7: Qhov "FIMTH DIMENSION"

hough peb koom nrog GPS nrog qhov chaw nyob hauv qhov chaw, tsis txhob hnov qab cov hnub qub tau xa lub sijhawm- thiab cov ntawv teev npe, ib yam. Qhov nruab nrab GPS moos yog qhov raug rau kaum-lab thib ob, thiab qhov kev xav theoretical tseem siab dua. Txawm hais tias koj tsuas xav tau koj txoj haujlwm kom taug qab lub sijhawm, GPS module tseem yuav yog qhov pheej yig tshaj thiab daws tau yooj yim.

Txhawm rau Tig Nrhiav Koj Tus Kheej.ino rau hauv lub moos zoo tshaj, tsuas yog hloov pauv ob peb kab kawg li no:

yog (gps.time.isUpdated ()) {

char kub [80];

sprintf (buf, "Lub sijhawm yog%02d:%02d:%02d", gps.time.hour (), gps.time.minute (), gps.time.second ()); Serial.println (buf);

}

Kauj Ruam 8: Nrhiav Koj Txoj Kev

Nrhiav Koj Txoj Kev
Nrhiav Koj Txoj Kev

Peb daim ntawv thov thib peb thiab zaum kawg yog qhov tshwm sim ntawm kev sib tw tus kheej los sau cov ntawv nyeem tau TinyGPS ++, hauv tsawg dua 100 kab ntawm cov cai, uas yuav coj tus neeg siv mus rau qhov chaw uas siv cov lus qhia yooj yim xws li "khaws ncaj" lossis "veer sab laug."

#ncig #ncig

#Txhais RXPin 2

#define TXPin 3

#txhais GPSBaud 4800

#define ConsoleBaud 115200

// Qhov txuas txuas mus rau lub cuab yeej GPSSoftwareSerial ss (RXPin, TXPin);

// Lub TinyGPS ++ kwv TinyGPSPlus gps;

unsigned ntev lastUpdateTime = 0;

#define EIFFEL_LAT 48.85823#txhais EIFFEL_LNG 2.29438

/* Qhov piv txwv no qhia txog lub hauv paus txheej txheem rau qhov koj yuav siv chav kawm thiab nrug deb li cas los coj tus neeg (lossis drone) mus rau qhov chaw. Lub hom phiaj no yog Eiffel Tower. Hloov nws raws li qhov xav tau

Txoj hauv kev yooj yim tshaj plaws kom tau txais lat/ntev kev sib koom tes yog mus rau txoj cai-nias lub hom phiaj hauv Google Maps (maps.google.com), thiab xaiv "Dab tsi ntawm no?". Qhov no tso qhov tseeb qhov tseem ceeb hauv lub thawv tshawb nrhiav

*/

void teeb tsa () {

Serial.begin (ConsoleBaud);

ss.begin (GPSBaud);

Serial.println ("Piv txwv GPS 3");

Serial.println ("Qhov Tsis-yog-kev taw qhia Txheej Txheem");

Serial.println ("los ntawm Mikal Hart");

Serial.println ();

}

void voj () {

// Yog tias muaj cov cim tau los ntawm GPS, // xa lawv mus rau TinyGPS ++ cov khoom thaum (ss.available ()> 0) gps.encode (ss.read ());

// Txhua 5 vib nas this, ua qhov hloov tshiab

yog (millis () - lastUpdateTime> = 5000)

{

lastUpdateTime = millis ();

Serial.println ();

// Tsim peb cov xwm txheej tam sim no

double distanceToDestination = TinyGPSPlus:: distanceBetween

gps.location.lat (), gps.location.lng (), EIFFEL_LAT, EIFFEL_LNG);

ob chav courseToDestination = TinyGPSPlus:: courseTo

gps.location.lat (), gps.location.lng (), EIFFEL_LAT, EIFFEL_LNG);

const char *directionToDestination = TinyGPSPlus:: cardinal (courseToDestination);

int courseChangeNeeded = (int) (360 + courseToDestination - gps.course.deg ()) % 360;

// debug Serial.print ("DEBUG: Course2Dest:");

Serial.print (courseToDestination);

Serial.print ("CurCourse:");

Serial.print (gps.course.deg ());

Serial.print ("Dir2Dest:");

Serial.print (directionToDestination);

Serial.print ("RelCourse:");

Serial.print (courseChangeNeeded);

Serial.print ("CurSpd:");

Serial.println (gps.speed.kmph ());

// Tsis pub dhau 20 metres ntawm qhov chaw? Peb nyob ntawm no

yog (nrugToDestination <= 20.0)

{Serial.println ("CONGRATULATIONS: Koj tuaj txog!");

tawm (1);

}

Serial.print ("DISTANCE:"); Serial.print (distanceToDestination);

Serial.println ("meters mus.");

Serial.print ("INSTRUCTION:");

// Sawv ntsug? Tsuas qhia tias yuav mus qhov twg

yog (gps.speed.kmph () <2.0)

{

Serial.print ("Lub taub hau");

Serial.print (directionToDestination);

Serial.println (".");

rov qab;

}

yog (courseChangeNeeded> = 345 || courseChangeNeeded <15) Serial.println ("Khaws ncaj nraim ua ntej!");

lwm yam yog (courseChangeNeeded> = 315 && courseChangeNeeded <345)

Serial.println ("Veer me ntsis rau sab laug.");

lwm yam yog (courseChangeNeeded> = 15 && courseChangeNeeded <45)

Serial.println ("Veer me ntsis rau sab xis.");

lwm yog (courseChangeNeeded> = 255 && courseChangeNeeded <315)

Serial.println ("Tig mus rau sab laug.");

lwm yam yog (courseChangeNeeded> = 45 && courseChangeNeeded <105)

Serial.println ("Tig rau sab xis.");

lwm tus

Serial.println ("Tig ib ncig.");

}

}

Txhua txhua 5 vib nas this tus lej ntes tus neeg siv qhov chaw nyob thiab chav kawm (kev taug kev mus) thiab suav cov kabmob (kev taw qhia mus rau qhov chaw), siv TinyGPS ++ courseTo () txoj hauv kev. Sib piv ob lub vectors tsim cov lus pom zoo kom mus ncaj los yog tig, raws li qhia hauv qab no.

Luam cov duab kos FindingYourWay.ino (saum toj no) thiab muab tshuaj txhuam rau hauv Arduino IDE. Teem lub hom phiaj 1km lossis 2km deb, xa daim duab kos rau koj Arduino, khiav ntawm koj lub khoos phis tawj, thiab saib seb nws yuav coj koj mus rau qhov ntawd. Tab sis qhov tseem ceeb dua, kawm txoj cai thiab nkag siab tias nws ua haujlwm li cas.

Kauj Ruam 9: Mus Ntxiv

Lub peev xwm muaj tswv yim ntawm GPS yog qhov loj heev. Ib qho ntawm qhov txaus siab tshaj plaws uas kuv tau ua yog GPS-qhib lub thawv ntawv uas qhib tsuas yog ntawm ib qhov chaw npaj ua ntej. Yog tias koj tus neeg raug tsim txom xav kom muab cov khoom muaj nqis xauv sab hauv, nws yuav tsum xyuas seb qhov chaw zais cia ntawd nyob qhov twg thiab nqa lub thawv mus rau qhov twg. Ib lub tswv yim zoo tshaj plaws thawj lub tswv yim yog qee yam ntawm cov cuab yeej txiav ntoo uas sau cov feeb ib feeb thiab qhov siab ntawm, hais tias, tus neeg taug kev taug kev hla Trans-Pennine Trail. Los yog dab tsi txog ib qho ntawm cov neeg dag ntxias cov neeg sib tw taug qab DEA cov neeg sawv cev hauv Kev Ua Phem Tsis Zoo ntawm cov neeg phem lub tsheb? Ob leeg muaj peev xwm ua tiav, thiab tej zaum yuav lom zem los tsim, tab sis kuv txhawb koj kom xav ntau ntxiv, dhau ntawm cov khoom koj tuaj yeem yuav hauv Amazon. Nws yog lub ntiaj teb loj nyob ntawd. Ncig kom deb thiab dav npaum li koj tuaj yeem ua tau.

Pom zoo: