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

Post Reply
ygl611
Posts: 9
Joined: Mon Mar 05, 2012 1:29 am

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

Post 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
Attachments
GPS.rar
(72.11 KiB) Downloaded 567 times

Ajienux
Posts: 1
Joined: Fri May 18, 2012 8:48 am

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

Post by Ajienux »

hi, thanks for sharing, this work for multiwii 1.9 ?

ygl611
Posts: 9
Joined: Mon Mar 05, 2012 1:29 am

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

Post by ygl611 »

Ajienux wrote:hi, thanks for sharing, this work for multiwii 1.9 ?


These codes is based on 2.0 P4

zanek
Posts: 5
Joined: Thu Aug 09, 2012 1:21 am

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

Post by zanek »

So I could use a serial GPS on a Arduino Pro Mini with atmega 328p?

reis
Posts: 9
Joined: Fri Jun 22, 2012 6:41 pm

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

Post 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

zanek
Posts: 5
Joined: Thu Aug 09, 2012 1:21 am

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

Post by zanek »

no

Post Reply