Page 1 of 1

Serial Port GPS(MTK3329 & UBLOX)available on 328P board

Posted: Mon May 07, 2012 2:25 am
by ygl611
There is only one serial port on 328 board, communicate with GPS or GUI is auto selected when the board is powered. If GPS is connect , the board will receive GPS data. Next time if you want communicate with GUI ,you must poweroff the board , connect board with GUI ,then power the board again.

The code "GPS init "comes from marbalon,code "GPS PID contral "comes from EOSBandi .
What i do is just copy and paste them together. ;) .

EOSBandi use PI and PID controller classes , so Copy libraries folder to arduino libraries folder.

My little contribution to the code is show GPS_numSat on the status LED. Before armming, waitting until the GPS is hold , status LED will flash weakly to show the number of satellite,then brife pause,then flash agin.

when armming the board ,the home position is hold.

I calibrate MAG with the old way ,which works well on my 328 board.(itg 3205 bma020 hmc5883l bmp085).

In order to GPS init with serial port 0, in serial.pde, code must changed as follows:

Code: Select all

void SerialWrite(uint8_t port,uint8_t c){
 switch (port) {
    case 0: while (!(UCSR0A & (1 << UDRE0))) ; UDR0 = c; break;    //ygl611 GPS init
    //case 0: serialize8(c);UartSendData(); break;                 // Serial0 TX is driven via a buffer and a background intterupt
    #if defined(MEGA) || #defined(PROMICRO)
    case 1: while (!(UCSR1A & (1 << UDRE1))) ; UDR1 = c; break;  // Serial1 Serial2 and Serial3 TX are not driven via interrupts
    #endif
    #if defined(MEGA)
    case 2: while (!(UCSR2A & (1 << UDRE2))) ; UDR2 = c; break;
    case 3: while (!(UCSR3A & (1 << UDRE3))) ; UDR3 = c; break;
    #endif
  }
}


I dont know why. Maybe alexinparis can tell me why. :D ,I only have a little VB experience many years age.

Hope you guys enjoy the GPS code on 328 board.

EDIT:

These codes also works on MEAG board, change the code in config.h to this

Code: Select all

#define GPS_SERIAL 2    // should be 2 for flyduino v2. It's the serial port number on arduino MEGA

Re: Serial Port GPS(MTK3329 & UBLOX)available on 328P board

Posted: Fri May 18, 2012 8:49 am
by Ajienux
hi, thanks for sharing, this work for multiwii 1.9 ?

Re: Serial Port GPS(MTK3329 & UBLOX)available on 328P board

Posted: Sat May 19, 2012 10:05 am
by ygl611
Ajienux wrote:hi, thanks for sharing, this work for multiwii 1.9 ?


These codes is based on 2.0 P4

Re: Serial Port GPS(MTK3329 & UBLOX)available on 328P board

Posted: Thu Aug 09, 2012 1:25 am
by zanek
So I could use a serial GPS on a Arduino Pro Mini with atmega 328p?

Re: Serial Port GPS(MTK3329 & UBLOX)available on 328P board

Posted: Wed Nov 07, 2012 8:38 pm
by reis
Zanek,
Did you ever get an answer to your question, "So I could use a serial GPS on a Arduino Pro Mini with atmega 328p?" ?
Thank you,
Rick

Re: Serial Port GPS(MTK3329 & UBLOX)available on 328P board

Posted: Fri Nov 30, 2012 11:44 pm
by zanek
no