Gps project

Projecten die niet passen in bovenstaande onderwerpen
Berichten: 1
Geregistreerd: 11 Aug 2012, 20:55

Gps project

Berichtdoor gert » 11 Aug 2012, 22:00

Hallo iedereen
na een tijdje zoeken ben ik toch eindelijk op een nederlandstalig arduino forum terechtgekomen
ik ben nog maar een paar maanden bezig met een arduino uno
en in blijde verwachting van een arduino leonardo ;)
ik ben aan een nieuw project bezig en deze keer zit ik toch wel vast
mss kan hier iemand mij verder helpen

mijn project is het volgende :
Ik heb een gps sensor van adafruit (de mtk 3329) en een rgb lcdscherm aangesloten op de arduino
voor de coordinaten weer te geven op het lcd scherm
kwestie van de computer niet te moeten meesleuren voor de serial monitor
na een dikke week zoeken heb ik de coordinaten op mn lcd scherm
MAAR deze zijn niet juist als ik ze ingeef met google maps
nu heb ik op internet gevonden dat je die coordinaten van de gps
nog verder moet bewerken om de juiste plaats te bekomen
voorbeeld :
$GPRMC,035211.000,A,1259.3254,N,07740.1250,E,0.24,86.89,0302


Your resulting latitude should be 12.9887566666667 ie 12 + (59.3254/60)

Similarly the longitude should be 77.66875 ie 077 + (40.125/60)

maar nu is mijn vraag hoe kan ik zoiets programmeren met de arduino ide 1.0
dit is de code wat ik nu heb
deze is afkomstig van adafruit en heb ik zelf aangepast
Code: Alles selecteren
[quote]


[color=#7E7E7E]// Test code for Adafruit GPS modules using MTK3329/MTK3339 driver[/color]
[color=#7E7E7E]//[/color]
[color=#7E7E7E]// This code shows how to listen to the GPS module in an interrupt[/color]
[color=#7E7E7E]// which allows the program to have more 'freedom' - just parse[/color]
[color=#7E7E7E]// when a new NMEA sentence is available! Then access data when[/color]
[color=#7E7E7E]// desired.[/color]
[color=#7E7E7E]//[/color]
[color=#7E7E7E]// Tested and works great with the Adafruit Ultimate GPS module[/color]
[color=#7E7E7E]// using MTK33x9 chipset[/color]
[color=#7E7E7E]//    ------> http://www.adafruit.com/products/746[/color]
[color=#7E7E7E]// Pick one up today at the Adafruit electronics shop [/color]
[color=#7E7E7E]// and help support open source hardware & software! -ada[/color]
#include <[color=#CC6600]LiquidCrystal[/color].h>
[color=#7E7E7E]// initialize the library with the numbers of the interface pins[/color]
[color=#CC6600]LiquidCrystal[/color] lcd(12, 11, 5, 4, 3, 2);
#include <Adafruit_GPS.h>
#if ARDUINO >= 100
 #include <SoftwareSerial.h>
#else
  [color=#7E7E7E]// Older Arduino IDE requires NewSoftSerial, download from:[/color]
  [color=#7E7E7E]// http://arduiniana.org/libraries/newsoftserial/[/color]
 #include <[color=#CC6600]NewSoftSerial[/color].h>
 [color=#7E7E7E]// DO NOT install NewSoftSerial if using Arduino 1.0 or later![/color]
#endif

[color=#7E7E7E]// Connect the GPS Power pin to 5V[/color]
[color=#7E7E7E]// Connect the GPS Ground pin to ground[/color]
[color=#7E7E7E]// If using software serial (sketch example default):[/color]
[color=#7E7E7E]//   Connect the GPS TX (transmit) pin to Digital 3[/color]
[color=#7E7E7E]//   Connect the GPS RX (receive) pin to Digital 2[/color]
[color=#7E7E7E]// If using hardware serial (e.g. Arduino Mega):[/color]
[color=#7E7E7E]//   Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3[/color]
[color=#7E7E7E]//   Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3[/color]

[color=#7E7E7E]// If using software serial, keep these lines enabled[/color]
[color=#7E7E7E]// (you can change the pin numbers to match your wiring):[/color]
[color=#7E7E7E]//#if ARDUINO >= 100[/color]
  [color=#7E7E7E]//SoftwareSerial mySerial(3, 2);[/color]
[color=#7E7E7E]//#else[/color]
  [color=#7E7E7E]//NewSoftSerial mySerial(3, 2);[/color]
[color=#7E7E7E]//#endif[/color]
[color=#7E7E7E]//Adafruit_GPS GPS(&mySerial);[/color]
[color=#7E7E7E]// If using hardware serial (e.g. Arduino Mega), comment[/color]
[color=#7E7E7E]// out the above six lines and enable this line instead:[/color]
Adafruit_GPS GPS(&[color=#CC6600][b]Serial[/b][/color]);


[color=#7E7E7E]// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console[/color]
[color=#7E7E7E]// Set to 'true' if you want to debug and listen to the raw GPS sentences[/color]
#define GPSECHO  [color=#CC6600]false[/color]

[color=#7E7E7E]// this keeps track of whether we're using the interrupt[/color]
[color=#7E7E7E]// off by default![/color]
[color=#CC6600]boolean[/color] usingInterrupt = [color=#CC6600]true[/color];
[color=#CC6600]void[/color] useInterrupt([color=#CC6600]boolean[/color]); [color=#7E7E7E]// Func prototype keeps Arduino 0023 happy[/color]

[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() 

  [color=#CC6600]pinMode[/color] (6, [color=#006699]OUTPUT[/color]);[color=#7E7E7E]// pin 6 , blauw[/color]
  [color=#7E7E7E]//pinMode (9,OUTPUT);//pin9 , groen[/color]
  [color=#7E7E7E]//pinMode (10, OUTPUT);//pin10 , rood[/color]
    
  [color=#7E7E7E]// connect at 115200 so we can read the GPS fast enough and echo without dropping chars[/color]
  [color=#7E7E7E]// also spit it out[/color]
  lcd.[color=#CC6600]begin[/color](16,2);
  lcd.[color=#CC6600]print[/color]([color=#006699]"waiting fix ..."[/color]);

  [color=#7E7E7E]// 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800[/color]
  GPS.[color=#CC6600]begin[/color](9600);
  
  [color=#7E7E7E]// uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude[/color]
  [color=#7E7E7E]//GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);[/color]
  [color=#7E7E7E]// uncomment this line to turn on only the "minimum recommended" data[/color]
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
  [color=#7E7E7E]// For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since[/color]
  [color=#7E7E7E]// the parser doesn't care about other sentences at this time[/color]
  
  [color=#7E7E7E]// Set the update rate[/color]
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   [color=#7E7E7E]// 1 Hz update rate[/color]
  [color=#7E7E7E]// For the parsing code to work nicely and have time to sort thru the data, and[/color]
  [color=#7E7E7E]// print it out we don't suggest using anything higher than 1 Hz[/color]

  [color=#7E7E7E]// the nice thing about this code is you can have a timer0 interrupt go off[/color]
  [color=#7E7E7E]// every 1 millisecond, and read data from the GPS for you. that makes the[/color]
  [color=#7E7E7E]// loop code a heck of a lot easier![/color]
  useInterrupt([color=#CC6600]true[/color]);

  [color=#CC6600]delay[/color](1000);
}


[color=#7E7E7E]// Interrupt is called once a millisecond, looks for any new GPS data, and stores it[/color]
SIGNAL(TIMER0_COMPA_vect) {
  [color=#CC6600]char[/color] c = GPS.[color=#CC6600]read[/color]();
  [color=#7E7E7E]// if you want to debug, this is a good time to do it![/color]
  [color=#CC6600]if[/color] (GPSECHO)
    [color=#CC6600]if[/color] (c) UDR0 = c; 
    [color=#7E7E7E]// writing direct to UDR0 is much much faster than Serial.print [/color]
    [color=#7E7E7E]// but only one character can be written at a time. [/color]
}

[color=#CC6600]void[/color] useInterrupt([color=#CC6600]boolean[/color] v) {
  [color=#CC6600]if[/color] (v) {
    [color=#7E7E7E]// Timer0 is already used for millis() - we'll just interrupt somewhere[/color]
    [color=#7E7E7E]// in the middle and call the "Compare A" function above[/color]
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = [color=#CC6600]true[/color];
  } [color=#CC6600]else[/color] {
    [color=#7E7E7E]// do not call the interrupt function COMPA anymore[/color]
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = [color=#CC6600]false[/color];
  }
}

uint32_t timer = [color=#CC6600]millis[/color]();
[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]()                     [color=#7E7E7E]// run over and over again[/color]
{
  [color=#7E7E7E]// in case you are not using the interrupt above, you'll[/color]
  [color=#7E7E7E]// need to 'hand query' the GPS, not suggested :([/color]
  [color=#CC6600]if[/color] (! usingInterrupt) {
    [color=#7E7E7E]// read data from the GPS in the 'main loop'[/color]
    [color=#CC6600]char[/color] c = GPS.[color=#CC6600]read[/color]();
    [color=#7E7E7E]// if you want to debug, this is a good time to do it![/color]
    [color=#CC6600]if[/color] (GPSECHO)
      [color=#CC6600]if[/color] (c) UDR0 = c;
      [color=#7E7E7E]// writing direct to UDR0 is much much faster than Serial.print [/color]
      [color=#7E7E7E]// but only one character can be written at a time. [/color]
  }
  
  [color=#7E7E7E]// if a sentence is received, we can check the checksum, parse it...[/color]
  [color=#CC6600]if[/color] (GPS.newNMEAreceived()) {
    [color=#7E7E7E]// a tricky thing here is if we print the NMEA sentence, or data[/color]
    [color=#7E7E7E]// we end up not listening and catching other sentences! [/color]
    [color=#7E7E7E]// so be very wary if using OUTPUT_ALLDATA and trytng to print out data[/color]
    [color=#7E7E7E]//Serial.println(GPS.lastNMEA());   // this also sets the newNMEAreceived() flag to false[/color]
  
    [color=#CC6600]if[/color] (!GPS.parse(GPS.lastNMEA()))   [color=#7E7E7E]// this also sets the newNMEAreceived() flag to false[/color]
      [color=#CC6600]return[/color];  [color=#7E7E7E]// we can fail to parse a sentence in which case we should just wait for another[/color]
  }

  [color=#7E7E7E]// if millis() or timer wraps around, we'll just reset it[/color]
  [color=#CC6600]if[/color] (timer > [color=#CC6600]millis[/color]())  timer = [color=#CC6600]millis[/color]();

  [color=#7E7E7E]// approximately every 2 seconds or so, print out the current stats[/color]
  [color=#CC6600]if[/color] ([color=#CC6600]millis[/color]() - timer > 2000) {
    timer = [color=#CC6600]millis[/color](); [color=#7E7E7E]// reset the timer[/color]
    
    
     
    [color=#CC6600]if[/color] (GPS.fix) {
      lcd.[color=#CC6600]setCursor[/color](0,0);
      lcd.[color=#CC6600]print[/color]([color=#006699]"lat  "[/color]);
      lcd.[color=#CC6600]print[/color](GPS.latitude, 4);
      lcd.[color=#CC6600]print[/color]([color=#006699]", "[/color]);
      lcd.[color=#CC6600]setCursor[/color](0,1);
      lcd.[color=#CC6600]print[/color]([color=#006699]"lon  "[/color]);
      lcd.[color=#CC6600]print[/color](GPS.longitude, 4);
      lcd.[color=#CC6600]print[/color]([color=#006699]", "[/color]);
      
    }
  }
}

[/quote]


Groeten Gert

Advertisement

Terug naar Overige projecten

Wie is er online?

Gebruikers in dit forum: Google [Bot] en 12 gasten