Hallo iedereen
Ik ben Gert ik ben van limburg (be)
en ik ben al van kleinsaf al bezig met basiselectronica
en sinds dat ik arduino heb leren kennen is er een andere wereld voor mij opengegaan
ik ben nog niet zo heel lang bezig met arduino
en daarmee dat ik hier even om raad kom vragen
Ik ben bezig met een gps project en in dit geval zit ik toch wel een beetje vast
nu ben ik wel geen programmeur en meestal kijk ik rond op internet en pas ik de code aan aan mijn wens
zo ook in dit geval ben ik vertrokken vanaf een sketch van adafruit
ik ben al zo ver geraakt dat ik de coordinaaten op mn lcd scherm krijg
(via de §gprmc string)
maar nu moet ik die nog converteren en daar loop ik vast
elders op het arduinoforum heb ik al iets gelijkaardigs gevonden van een gps conversie zoals dit:
float long = 45.124783;
int deglong = long;
long -= deglong; // remove the degrees from the calculation
long *= 60; // convert to minutes
int minlong = long;
long -= minlong; // remove the minuts from the calculation
long *= 60; // convert to seconds
maar het lukt mij niet om dit toe te voegen of veranderen zodat het werkt in mn bestaande sketch
Kan iemand mij hiermee verder helpen of een duw in de juiste richting geven ?
mn setup is het volgende :
ik werk met een arduino uno r3 en ide 1.0
een rgb lcd display en een gps mtk 3329 van adafruit
[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=#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/100, 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/100, 4);
lcd.[color=#CC6600]print[/color]([color=#006699]", "[/color]);
}
}
}
[/quote]
ik heb wel wat code moeten verwijderen anders was het te groot
don't shoot er zullen nog wel andere fouten of overbodige dingen inzitten
maar veel ervaring heb ik nog niet met arduino
het enige wat nu nog moet aangepast worden zijn de cijfers na de comma delen door 60
dacht dat dit toch wel een beetje makkelijker was voor ik er aan begon :~
Groeten Gert