GPS integration

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Katch
Posts: 280
Joined: Thu Aug 04, 2011 1:44 pm

Re: GPS integration

Post by Katch »

EOSBandi;

Code: Select all

#define NAV_SPEED_MIN              100    // cm/sec   
#define NAV_SPEED_MAX              300    // cm/sec   
#define NAV_SLOW_NAV               true   
#define NAV_BANK_MAX 3000        //30deg max banking when navigating (just for security and testing)


These settings in GPS.ino only effect serial GPS or also I2C? I seem to remember I2C settings are made in the sketch on the GPS arduino but I don't remember NAV_SLOW_NAV being present in r33. Is there an updated sketch for I2C GPS or is r33 still current?

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

r33 is still current... you can find these settings in the config.h for i2c-gps-nav.
Except slow-nav which is fixed for true in the i2c-gps-code.
I'm still working on the code, but the main dev is going on the serial part (easier to debug and tune) once it's stabilised i'll move the code to i2c. But this is definitely post MW2.1

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

uBlox binary protocol....

Post by EOSBandi »

So I had a very little time for test it, because a quite heavy storm hit my flying place. BUT i had some results.
First, here is a small video....
http://www.youtube.com/watch?v=Uo_v6tBXqNU
Do not be missleaded by the altitude changes... the position stayed within a 2meterx2meter box during the video.

The wind was 17-22km/h and increased during the test.
Here is the onboard datalog (20Hz update rate) for the whole poshold period (about 5 min)
Poshold log
Poshold log

Red line is the distance from hold position in cm. the blue and green lines are the lat and lon rate I terms, you can clearly see the increase of the wind during the poshold..
(video is made during the last minute of this log)

And for the uBlox binary... It is awesome. Absolutly no need for GPS filtering anymore, which means that the latency that introduced by the moving average filter could be avoided.
Here is a log from NMEA mode :
nmea.JPG

Red line is the unfitered position, green is the filtered one. You can clearly see the steps on the unfiltered gps coordinates. These steps cause twiches during poshold, so this is why I introduced filtering.

And this is the output from the same uBlox gps, but using binary protocol.:
ublox.JPG

Clean and smooth.

So the conclusion : Forget MTK, get a uBlox with a decent patch antenna (25mmx25mm or bigger).

I know that MultiWii 2.1 is feature freezed, but I think it worth to commit the uBlox serial parser. I'll test it some more, and I'll do it during the weekend...
Last edited by EOSBandi on Thu Jul 05, 2012 11:19 pm, edited 2 times in total.

Katch
Posts: 280
Joined: Thu Aug 04, 2011 1:44 pm

Re: GPS integration

Post by Katch »

Rockin! Glad I got my ublox ready.

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

Andras,
thank you for the detailed explanation.
That makes absolute sense to me now.

I will test on a big field tomorrow.
It is so cool to have a working GPS now. Thank you.

Nils

Y.Mita
Posts: 46
Joined: Thu Sep 15, 2011 11:25 pm

Re: uBlox binary protocol....

Post by Y.Mita »

EOSBandi wrote:So I had a very little time for test it, because a quite heavy storm hit my flying place. BUT i had some results.
First, here is a small video....
http://www.youtube.com/watch?v=Uo_v6tBXqNU
Do not be missleaded by the altitude changes... the position stayed within a 2meterx2meter box during the video.

The wind was 17-22km/h and increased during the test.
:
:
So the conclusion : Forget MTK, get a uBlox with a decent patch antenna (25mmx25mm or bigger).

I know that MultiWii 2.1 is feature freezed, but I think it worth to commit the uBlox serial parser. I'll test it some more, and I'll do it during the weekend...

Very impressive video, lightning strikes from copter with uBlox module at 1:03 ! Under strong winds its stable ! Let's get uBlox !

Edited:

But ... I remember that MTK has binary protocol, too. How about that ?

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

Well, AFAIK only DIY drones custom firmware has the binary protocol. And that firmware is quite outdated...My basic problem with the PA6B and other MTK modules is the tiny antenna.....

alexia
Posts: 85
Joined: Sun Jun 17, 2012 10:23 pm
Contact:

Re: GPS integration

Post by alexia »

i think ,we have to choose only one great gps and improve code around it if we want something working very good!
ublox seem to be the best for multiwii!

User avatar
brettwal
Posts: 93
Joined: Mon Jun 18, 2012 4:51 pm
Location: Louisiana

Re: GPS integration

Post by brettwal »

EOSBandi wrote:
brettwal wrote:I am a bit confused on something, perhaps someone can assist.

I have a Crius SE with a Serial GPS module and it is working fine. I purchased a Crius V1.0 (with the I2C pins) and the I2C GPS Navigation module from RCTimer. (http://rctimer.com/index.php?gOo=goods_ ... oductname=). Do I have to load a sketch on to the AT328 on the module? or is this not necessary? I think YES but, find it odd that there are no pins for FTDI on RCTimer board.


Take a closer look. The place for pins is there, even labeled as FTDI, just solder in some pins....



I added pins. Am using Arduino 1.01. When I replace twi.h and twi.c with the patched files, I get compile errors.

C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\utility/twi.h: In member function 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t, uint8_t)':
C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\utility/twi.h:43: error: too many arguments to function 'uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t)'
C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\Wire.cpp:85: error: at this point in file
C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\utility/twi.h: In member function 'uint8_t TwoWire::endTransmission(uint8_t)':
C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\utility/twi.h:44: error: too many arguments to function 'uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t)'
C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\Wire.cpp:140: error: at this point in file



NEVERMIND, Found the note in an old post about using Arduino 1.0
Last edited by brettwal on Fri Jul 06, 2012 4:15 am, edited 1 time in total.

User avatar
brettwal
Posts: 93
Joined: Mon Jun 18, 2012 4:51 pm
Location: Louisiana

Re: GPS integration

Post by brettwal »

Ok, I have my Serial MTK Module plugged into the RCTimer i2c board w/ the the AT328 flashed with EOSBandi's GPS NAV code. I have the RCTimer i2c port plugged into the i2c pins on the Crius SE 1.0. I am getting data (lat, long, etc) in the multiwii conf gui. I have used MiniGPS to set my module to 115200 and 10Hz but, it will only keep these seetings for several hours and then it reverts back to defaults. Where can I send the strings to initialize the GPS module? ($PMTK251,115200*1F & $PMTK220,100*2F) Can this be put on the 328 on the i2c interface or on the Crius? If so, where?


I have this code, just not exactly sure where to insert it:

void setup() {

pinMode(8, OUTPUT); // led
//MTK3339 init
delay(1000); // power on delay
digitalWrite(8, HIGH); // set the LED on
Serial.begin(9600); // open port with firmware default baud
Serial.println("$PMTK251,115200*1F"); // change baud
Serial.end();
//reconnect and blink
digitalWrite(8, LOW); // set the LED off
delay(200); // wait for MTK3339 to settle at new baud
digitalWrite(8, HIGH); // set the LED on
Serial.begin(57600);
Serial.println("$PMTK313,0*2F"); // disable sbas (>5Hz)
Serial.println("$PMTK220,100*2F"); // set update frequ 10Hz
digitalWrite(8, LOW); // set the LED off

uint8_t i;

//Serial.begin(115200);

//Init i2c_dataset;

Thanks!


OK, NEVERMIND...I figured this out as well and have it working now.
Last edited by brettwal on Fri Jul 06, 2012 5:14 am, edited 2 times in total.

Scotth72
Posts: 23
Joined: Sat Jan 21, 2012 4:11 am

Re: GPS integration

Post by Scotth72 »


User avatar
Gaijin
Posts: 82
Joined: Sat Jan 14, 2012 8:00 am

Re: GPS integration

Post by Gaijin »

Okay,

To test out UBlox Vs MTK I've ordered a NEO-6M module from RCTimer and AT328 I2C board to test in place of my MTK based Navigatron, do I need to re-flash the UBlox?
Is there a guide to which firmware / settings we need, obviously I understand that I2c is on hold ATM while 2.1 is finished, but will the I2C sketch need much modification to work with the binary protocol?

http://www.rctimer.com/index.php?gOo=goods_details.dwt&goodsid=763&productname=
http://www.rctimer.com/index.php?gOo=goods_details.dwt&goodsid=762&productname=

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: uBlox binary protocol....

Post by LuFa »

EOSBandi wrote:So I had a very little time for test it, because a quite heavy storm hit my flying place. BUT i had some results.
First, here is a small video....
http://www.youtube.com/watch?v=Uo_v6tBXqNU
....


Very Cool :) !

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

Ublox neo modules are not reflashable, but they not need it at all....
You need the u-center software to config the u-blox module.
Here is a settings file for NMEA. You can download it to your module with the tools->GPS configuration menu...
Once the binary protocol parser is committed to Multiwii i'll update the i2c sw too.

One more issue : I found that the onboard battery of these ebay ublox modules are hardly last more than a couple of days... and since the neo-6M does not have flash onboard, then it forgets the settings. So it's worth do buy an i2c EEPROM chip (about .5usd a piece) (Microchip 24AA32A, or ST MC24C32-R) and connect it to the i2c port of the gps (some boards already has i2c port connection, or you can solder it directly to the module). (I'll update the GPS docs about ublox, including the external i2c storage).

I there is interest, i'll make breakout boards with i2c eeprom chips.
Attachments
u-blox-config.nmea.zip
U-blox neo-6 config for NMEA (115200 baud, 10Hz, European SBAS)
(859 Bytes) Downloaded 689 times

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: GPS integration

Post by shikra »

Excellent EOS

Also you shoudl take a snapshot of 1:03 - has to be one of the best Tricopter pictures ever!

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

shikra wrote:Excellent EOS

Also you shoudl take a snapshot of 1:03 - has to be one of the best Tricopter pictures ever!

Already did that :D
Snapshot 1 (7-6-2012 12-27 AM).jpg


BUT GUYS !!! I'v been chasing storms for photograpy in the last 15 years, I checked the doppler radar info and lightning tracking on the field continously....
Please do not try this unless you know your location and the distance of the storm. Beeing on the field in a storm easily could be lethal !!!!

User avatar
Gaijin
Posts: 82
Joined: Sat Jan 14, 2012 8:00 am

Re: GPS integration

Post by Gaijin »

EOSBandi wrote:Ublox neo modules are not reflashable, but they not need it at all....
You need the u-center software to config the u-blox module.
Here is a settings file for NMEA. You can download it to your module with the tools->GPS configuration menu...
Once the binary protocol parser is committed to Multiwii i'll update the i2c sw too.

One more issue : I found that the onboard battery of these ebay ublox modules are hardly last more than a couple of days... and since the neo-6M does not have flash onboard, then it forgets the settings. So it's worth do buy an i2c EEPROM chip (about .5usd a piece) (Microchip 24AA32A, or ST MC24C32-R) and connect it to the i2c port of the gps (some boards already has i2c port connection, or you can solder it directly to the module). (I'll update the GPS docs about ublox, including the external i2c storage).

I there is interest, i'll make breakout boards with i2c eeprom chips.


Thanks Eos,

Just thinking though, If you are using an I2C AT328 adapter board, can't you store the Ublox settings on that or force the settings at start up somehow?

tsoumelman
Posts: 4
Joined: Sat Jun 23, 2012 9:05 pm

Re: GPS integration

Post by tsoumelman »

brettwal wrote:
EOSBandi wrote:
brettwal wrote:I am a bit confused on something, perhaps someone can assist.

I have a Crius SE with a Serial GPS module and it is working fine. I purchased a Crius V1.0 (with the I2C pins) and the I2C GPS Navigation module from RCTimer. (http://rctimer.com/index.php?gOo=goods_ ... oductname=). Do I have to load a sketch on to the AT328 on the module? or is this not necessary? I think YES but, find it odd that there are no pins for FTDI on RCTimer board.


Take a closer look. The place for pins is there, even labeled as FTDI, just solder in some pins....



I added pins. Am using Arduino 1.01. When I replace twi.h and twi.c with the patched files, I get compile errors.

C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\utility/twi.h: In member function 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t, uint8_t)':
C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\utility/twi.h:43: error: too many arguments to function 'uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t)'
C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\Wire.cpp:85: error: at this point in file
C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\utility/twi.h: In member function 'uint8_t TwoWire::endTransmission(uint8_t)':
C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\utility/twi.h:44: error: too many arguments to function 'uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t)'
C:\Users\bwalker\Desktop\MWC Quad\arduino-1.0.1\libraries\Wire\Wire.cpp:140: error: at this point in file



NEVERMIND, Found the note in an old post about using Arduino 1.0

I had same problems! Can you show me how did you compile?
Thanks in advance!

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

Andras,

as stated by you and as experienced by me:
If you hold the copter while it tries to return home it will become more and more aggressive because it wants to speed up.

Because of the bad thunderstorms tonight I haven't got the time to test (thanks for your PM - I suspected the mag too.)
Imagenina the following situation:
The copter is returning home and there is a tree or a wall or something and I will do a stick input to save the day-

Will the copter fight this input the same way it fights me holding it?

If so, we should consider pausing RTH while stick input is done (same way Alex suspends Baro and MAG)

Nils

Sympster
Posts: 15
Joined: Thu May 24, 2012 1:45 am

Re: GPS integration

Post by Sympster »

EOSBandi wrote:One more issue : I found that the onboard battery of these ebay ublox modules are hardly last more than a couple of days... and since the neo-6M does not have flash onboard, then it forgets the settings.


I've read that you have to charge the onboard battery for about 24 hours. I did so by applying 5 volts to the module via the FTDI connected to my computer. Not sure how long it will keep the settings but it's been two days an counting.

User avatar
mOuchadino
Posts: 15
Joined: Sat Jul 07, 2012 3:51 am

Re: GPS integration

Post by mOuchadino »

asked permission to read around ..... :roll:

flyrobot
Posts: 73
Joined: Thu Apr 05, 2012 3:59 pm

Re: GPS integration

Post by flyrobot »

Hi EOSbandi,

I see the more accurate GPS position should be used bigger external ceramic GPS and using additional DIY antenna like this :
http://autoquad.org/wiki/wiki/autoquad- ... oundplane/
Also
Do we need to do this kind of calibration to get more accurate magnetometer ?
http://autoquad.org/wiki/wiki/autoquad- ... libration/
Have you tried this ?

I hope with the latest firmware and above process will have very accurate GPS position like this :
http://diydrones.com/profiles/blogs/aut ... 6#comments

Thanks,
John

User avatar
brettwal
Posts: 93
Joined: Mon Jun 18, 2012 4:51 pm
Location: Louisiana

Re: GPS integration

Post by brettwal »

Use Arduino 1.0 w/ patches, not 1.01



NEVERMIND, Found the note in an old post about using Arduino 1.0[/quote]
I had same problems! Can you show me how did you compile?
Thanks in advance![/quote]

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

flyrobot wrote:Hi EOSbandi,

I see the more accurate GPS position should be used bigger external ceramic GPS and using additional DIY antenna like this :
http://autoquad.org/wiki/wiki/autoquad- ... oundplane/

Yes, I already wrote this earlier, it is recommended to have at least a 25mmx25mm patch antenna. (You can easily get it from a cheap external gps antenna)
flyrobot wrote:Do we need to do this kind of calibration to get more accurate magnetometer ?
http://autoquad.org/wiki/wiki/autoquad- ... libration/
Have you tried this ?

I think this is overkill. the standard dance with noise pointing north and down to 45deg is adequate.
flyrobot wrote:I hope with the latest firmware and above process will have very accurate GPS position like this :
http://diydrones.com/profiles/blogs/aut ... 6#comments

Nope,
Autoquad LEA-6T module to record RAW GPS data and anaylise it after the flight on the ground station. Doing RTK on the fly will requires a Linux based extremly powerfull flight controller

What is expected is someting 2x2m or a little more better....

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

jevermeister wrote:Andras,

as stated by you and as experienced by me:
If you hold the copter while it tries to return home it will become more and more aggressive because it wants to speed up.

Because of the bad thunderstorms tonight I haven't got the time to test (thanks for your PM - I suspected the mag too.)
Imagenina the following situation:
The copter is returning home and there is a tree or a wall or something and I will do a stick input to save the day-

Will the copter fight this input the same way it fights me holding it?

If so, we should consider pausing RTH while stick input is done (same way Alex suspends Baro and MAG)

Nils

Yes, it is on the list but I think it will be after 2.1 since it's not a simple change and needs significant amount of testing....

User avatar
Bledi
Posts: 187
Joined: Sat Sep 10, 2011 6:36 pm

Re: GPS integration

Post by Bledi »

I just had an idea for the RESET of home position.
Why not using the same switch as the switch for RTH activation but only when motors are not armed :

Code: Select all

if (rcOptions[BOXGPSHOME]) && !armed)
{
GPS_reset_home_position();
}

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

Bledi wrote:I just had an idea for the RESET of home position.
Why not using the same switch as the switch for RTH activation but only when motors are not armed :

Code: Select all

if (rcOptions[BOXGPSHOME]) && !armed)
{
GPS_reset_home_position();
}

I think the gyro init is good enough.and it is a trigger not a switch.

User avatar
Bledi
Posts: 187
Joined: Sat Sep 10, 2011 6:36 pm

Re: GPS integration

Post by Bledi »

the problem is not to be good enough, but it's not natural to make a gyro init to reset home position, isn't it ?

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: GPS integration

Post by PatrikE »

I allways calibrate gyros on launchPoint after connecting the battery.
Because i dont like to fly with gyros who is not correct init..
I have tested it and its not healty...

flyrobot
Posts: 73
Joined: Thu Apr 05, 2012 3:59 pm

Re: GPS integration

Post by flyrobot »

EOSBandi wrote:Nope,
Autoquad LEA-6T module to record RAW GPS data and anaylise it after the flight on the ground station. Doing RTK on the fly will requires a Linux based extremly powerfull flight controller

What is expected is someting 2x2m or a little more better....


Thanks for the explanation. Im going to try using my spare MKGPS 2.1 using GPS shield (i have to DIY it), its using LEA 6S.
Will it work ? I will try to compare it with my FMP04.

flyrobot
Posts: 73
Joined: Thu Apr 05, 2012 3:59 pm

Re: GPS integration

Post by flyrobot »

EOSBandi wrote:
flyrobot wrote:Hi EOSbandi,

I see the more accurate GPS position should be used bigger external ceramic GPS and using additional DIY antenna like this :
http://autoquad.org/wiki/wiki/autoquad- ... oundplane/

Yes, I already wrote this earlier, it is recommended to have at least a 25mmx25mm patch antenna. (You can easily get it from a cheap external gps antenna)

I know you have mentioned it, What i meant is GPS shield. Made from plain PCB and it was soldered around the external ceramic gps. Its recommend by MK to use GPS shield to increase GPS signal reception.
Anyone have try it? How was the result?

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: GPS integration

Post by LuFa »

EosBandi ,

News about the UBX Parser ?
cant wait to test it :mrgreen:

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

LuFa wrote:EosBandi ,

News about the UBX Parser ?
cant wait to test it :mrgreen:


Stay tuned, i'll flight test it again tomorrow morning... (testing during the day is impossible due the 40+ degree heat...
Menawhile also coded parser for the MTK 1.6 Binary protocol (ala ArduCopter)....

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

flyrobot wrote:
EOSBandi wrote:
flyrobot wrote:Hi EOSbandi,

I see the more accurate GPS position should be used bigger external ceramic GPS and using additional DIY antenna like this :
http://autoquad.org/wiki/wiki/autoquad- ... oundplane/

Yes, I already wrote this earlier, it is recommended to have at least a 25mmx25mm patch antenna. (You can easily get it from a cheap external gps antenna)

I know you have mentioned it, What i meant is GPS shield. Made from plain PCB and it was soldered around the external ceramic gps. Its recommend by MK to use GPS shield to increase GPS signal reception.
Anyone have try it? How was the result?


Well it's not a shiled but rather an enlarged ground plane...
Theoretically a bigger ground plane means bigger gain for the antenna. However, increasing the size of the ground plane will shift the center frequency of the GPS antenna. And a smaller patch antenna has a smaller bandwith which means that a shifted center frequency puts the 1.5754Ghz GPS frequency outside of the usable reception range of the antenna.

Bigger patches (25x25 or 35x35) has bigger bandwith so you can use bigger ground planes... for a small patch antenna a bigger ground plane is worst than a no groundplane.

BrokenRotor
Posts: 9
Joined: Sat Mar 19, 2011 2:05 pm

Re: GPS integration

Post by BrokenRotor »

EOSbandi,

I made an I2C GPS BOB and have a problem attaching to a MiniWii with BMA180, it works on another MiniWii with MPU6050. The GPS feature is working but the ACCEL is locked and does not work as long as the I2C GPS is attached with the BMA180 unit.

I tried modifying the GPS_NAV code, #define I2C_NAV_FLAG_LOW_SPEED_D_FILTER 0x40 register to 0x42, but it did not make a difference. I believe the BMA180 address is set to 0x40 as default.

Any ideas where else to try to make a change?

flyrobot
Posts: 73
Joined: Thu Apr 05, 2012 3:59 pm

Re: GPS integration

Post by flyrobot »

EOSBandi wrote:Well it's not a shiled but rather an enlarged ground plane...
Theoretically a bigger ground plane means bigger gain for the antenna. However, increasing the size of the ground plane will shift the center frequency of the GPS antenna. And a smaller patch antenna has a smaller bandwith which means that a shifted center frequency puts the 1.5754Ghz GPS frequency outside of the usable reception range of the antenna.

Bigger patches (25x25 or 35x35) has bigger bandwith so you can use bigger ground planes... for a small patch antenna a bigger ground plane is worst than a no groundplane.


Hi EOSBandi,

Thank you, its very usefull information. Make me understand. Now i know what GPS HW to use.

John

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: GPS integration

Post by crashlander »

Hello
I'm trying to get GLB's Rabbit GPS module to work (http://www.goodluckbuy.com/rabbit-gps-r ... oller.html).
But it always resets its settings to 9600 and 1Hz, in less than a minute after disconnecting it from power source. I have charged the battery for 24h (as somebody suggested couple posts back) and no change.
So will it be possible to send init string from flight controller to set those parameters or is there any other solution?

Andrej

Edit: Maybe I'm doing something wrong, because the battery shows 2.38V after charging and 2.4V while charging... and GPS forgets its settings in an instant?!

ReM
Posts: 14
Joined: Sun Jul 08, 2012 12:02 pm
Location: Lithuania

Re: GPS integration

Post by ReM »

I set in I2C_GPS_NAV.ino for MediaTek:

Code: Select all

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Setup
//
void setup() {

  uint8_t i;

  // GPS setup
  Serial.begin(9600);
  delay(2000);
  Serial.println("$PMTK251,115200*1F");  //speed 115200
  delay(1000);
  Serial.begin(115200);
  Serial.println("$PMTK314,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"); // CGA, RMC, GSA
  Serial.println("$PMTK220,100*2F"); // 10 Hz


I do not know whether this is really true, but this works OK.

Sorry for my bad english...

tsoumelman
Posts: 4
Joined: Sat Jun 23, 2012 9:05 pm

Re: GPS integration

Post by tsoumelman »

Hello
i have problems while i am trying to compile r33 code.I am not familiar with arduino coding.I've made the extra steps needed to get the code compiled in the arduino IDE. I have copied the libraries that are in the Arduino-PID-libs folder (PI and PID controllers)and pasted them into the libraries folder in arduino folder.
I'm planning to use i2c_gps(MTK3339 from Adafruit). So i copied twi.c and twi.h from the Arduino-twi-lib-patch and pasted them to the libraries\wire\utilities folder(i didn't erase the existing twi.c and twi.h files). Then i tried to compile the code, but i had many errors.What have i done wrong?
Guys i NEED YOUR HELP!!!
Thanks in advance!

BrokenRotor
Posts: 9
Joined: Sat Mar 19, 2011 2:05 pm

Re: GPS integration

Post by BrokenRotor »

tsoumelman wrote:Hello
i have problems while i am trying to compile r33 code.I am not familiar with arduino coding.I've made the extra steps needed to get the code compiled in the arduino IDE. I have copied the libraries that are in the Arduino-PID-libs folder (PI and PID controllers)and pasted them into the libraries folder in arduino folder.
I'm planning to use i2c_gps(MTK3339 from Adafruit). So i copied twi.c and twi.h from the Arduino-twi-lib-patch and pasted them to the libraries\wire\utilities folder(i didn't erase the existing twi.c and twi.h files). Then i tried to compile the code, but i had many errors.What have i done wrong?
Guys i NEED YOUR HELP!!!
Thanks in advance!

I had to remove the original twi code from the wire library, renaming did not work, only removing them would allow it to compile.

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

USE Arduino 1.0 not 1.0.1

User avatar
brettwal
Posts: 93
Joined: Mon Jun 18, 2012 4:51 pm
Location: Louisiana

Re: GPS integration

Post by brettwal »

ReM wrote:I set in I2C_GPS_NAV.ino for MediaTek:

Code: Select all

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Setup
//
void setup() {

  uint8_t i;

  // GPS setup
  Serial.begin(9600);
  delay(2000);
  Serial.println("$PMTK251,115200*1F");  //speed 115200
  delay(1000);
  Serial.begin(115200);
  Serial.println("$PMTK314,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"); // CGA, RMC, GSA
  Serial.println("$PMTK220,100*2F"); // 10 Hz


I do not know whether this is really true, but this works OK.

Sorry for my bad english...



Battery is done for, replace it.

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

UBLOX parser

Post by EOSBandi »

Hi folks,
Here is the Ublox binary parser, I flown a couple of packs with it, and seems to work. BUT since Mw2.1 is feature freezed and the sram footprint is not tested, i'm not commiting it to the current _shared trunk, but keep it for post 2.1. You can easily add it to the current code for testing, just add it to the begining of the gps.ino after the #if defined(GPS_SERIAL)..... define
and change the

Code: Select all

 if (GPS_newFrame(SerialRead(GPS_SERIAL))) {

to

Code: Select all

if (UBLOX_GPS_newFrame((uint8_t)SerialRead(GPS_SERIAL))) {


I also attached the settings file got u-blox to binary mode.

Code: Select all

#if defined(UBLOX)

   struct ubx_header {
      uint8_t preamble1;
      uint8_t preamble2;
      uint8_t msg_class;
      uint8_t msg_id;
      uint16_t length;
   };

    struct ubx_nav_posllh {
        uint32_t   time;            // GPS msToW
        int32_t      longitude;
        int32_t      latitude;
        int32_t      altitude_ellipsoid;
        int32_t      altitude_msl;
        uint32_t   horizontal_accuracy;
        uint32_t   vertical_accuracy;
    };
    struct ubx_nav_status {
        uint32_t   time;            // GPS msToW
        uint8_t      fix_type;
        uint8_t      fix_status;
        uint8_t      differential_status;
        uint8_t      res;
        uint32_t   time_to_first_fix;
        uint32_t   uptime;            // milliseconds
    };
    struct ubx_nav_solution {
        uint32_t   time;
        int32_t      time_nsec;
        int16_t      week;
        uint8_t      fix_type;
        uint8_t      fix_status;
        int32_t      ecef_x;
        int32_t      ecef_y;
        int32_t      ecef_z;
        uint32_t   position_accuracy_3d;
        int32_t      ecef_x_velocity;
        int32_t      ecef_y_velocity;
        int32_t      ecef_z_velocity;
        uint32_t   speed_accuracy;
        uint16_t   position_DOP;
        uint8_t      res;
        uint8_t      satellites;
        uint32_t   res2;
    };
    struct ubx_nav_velned {
        uint32_t   time;            // GPS msToW
        int32_t      ned_north;
        int32_t      ned_east;
        int32_t      ned_down;
        uint32_t   speed_3d;
        uint32_t   speed_2d;
        int32_t      heading_2d;
        uint32_t   speed_accuracy;
        uint32_t   heading_accuracy;
    };

    enum ubs_protocol_bytes {
        PREAMBLE1 = 0xb5,
        PREAMBLE2 = 0x62,
        CLASS_NAV = 0x01,
        CLASS_ACK = 0x05,
        CLASS_CFG = 0x06,
      MSG_ACK_NACK = 0x00,
      MSG_ACK_ACK = 0x01,
        MSG_POSLLH = 0x2,
        MSG_STATUS = 0x3,
        MSG_SOL = 0x6,
        MSG_VELNED = 0x12,
        MSG_CFG_PRT = 0x00,
        MSG_CFG_RATE = 0x08,
        MSG_CFG_SET_RATE = 0x01,
      MSG_CFG_NAV_SETTINGS = 0x24
    };
    enum ubs_nav_fix_type {
        FIX_NONE = 0,
        FIX_DEAD_RECKONING = 1,
        FIX_2D = 2,
        FIX_3D = 3,
        FIX_GPS_DEAD_RECKONING = 4,
        FIX_TIME = 5
    };
    enum ubx_nav_status_bits {
        NAV_STATUS_FIX_VALID = 1
    };

    // Packet checksum accumulators
    static uint8_t      _ck_a;
    static uint8_t      _ck_b;

    // State machine state
    static uint8_t      _step;
    static uint8_t      _msg_id;
    static uint16_t   _payload_length;
    static uint16_t   _payload_counter;

    static bool        next_fix;
   
    static uint8_t     _class;

   // do we have new position information?
   static bool      _new_position;

   // do we have new speed information?
   static bool      _new_speed;

   static uint8_t       _disable_counter;

    // Receive buffer
    static union {
        ubx_nav_posllh      posllh;
        ubx_nav_status      status;
        ubx_nav_solution   solution;
        ubx_nav_velned      velned;
        uint8_t   bytes[];
    } _buffer;

void _update_checksum(uint8_t *data, uint8_t len, uint8_t &ck_a, uint8_t &ck_b)
{
   while (len--) {
      ck_a += *data;
      ck_b += ck_a;
      data++;
   }
}

bool UBLOX_GPS_newFrame(uint8_t data)
{
       bool parsed = false;

        switch(_step) {

        case 1:
            if (PREAMBLE2 == data) {
                _step++;
                break;
            }
            _step = 0;
        case 0:
            if(PREAMBLE1 == data) _step++;
            break;

        case 2:
            _step++;
       _class = data;
       _ck_b = _ck_a = data;         // reset the checksum accumulators
            break;
        case 3:
            _step++;
            _ck_b += (_ck_a += data);         // checksum byte
            _msg_id = data;
            break;
        case 4:
            _step++;
            _ck_b += (_ck_a += data);         // checksum byte
            _payload_length = data;            // payload length low byte
            break;
        case 5:
            _step++;
            _ck_b += (_ck_a += data);         // checksum byte

            _payload_length += (uint16_t)(data<<8);
         if (_payload_length > 512) {
            _payload_length = 0;
            _step = 0;
         }
            _payload_counter = 0;            // prepare to receive payload
            break;
        case 6:
            _ck_b += (_ck_a += data);         // checksum byte
         if (_payload_counter < sizeof(_buffer)) {
            _buffer.bytes[_payload_counter] = data;
         }
            if (++_payload_counter == _payload_length)
                _step++;
            break;
        case 7:
            _step++;
            if (_ck_a != data) _step = 0;                  // bad checksum
            break;
        case 8:
            _step = 0;
            if (_ck_b != data)  break;                      // bad checksum
        if (UBLOX_parse_gps())  { parsed = true; GPS_Present = 1;  }
        } //end switch
   return parsed;
}

bool UBLOX_parse_gps(void)
{

    switch (_msg_id) {
    case MSG_POSLLH:
        //GPS_time   = _buffer.posllh.time;
        GPS_coord[LON]   = _buffer.posllh.longitude;
        GPS_coord[LAT]   = _buffer.posllh.latitude;
        GPS_altitude     = _buffer.posllh.altitude_msl / 10/100;      //alt in m
   f.GPS_FIX         = next_fix;
   _new_position = true;
   break;
    case MSG_STATUS:
        next_fix   = (_buffer.status.fix_status & NAV_STATUS_FIX_VALID) && (_buffer.status.fix_type == FIX_3D);
   if (!next_fix) f.GPS_FIX = false;
        break;
    case MSG_SOL:
        next_fix   = (_buffer.solution.fix_status & NAV_STATUS_FIX_VALID) && (_buffer.solution.fix_type == FIX_3D);
   if (!next_fix) f.GPS_FIX = false;
        GPS_numSat   = _buffer.solution.satellites;
        //GPS_hdop      = _buffer.solution.position_DOP;
        //debug[3] = GPS_hdop;
        break;
    case MSG_VELNED:
        //speed_3d   = _buffer.velned.speed_3d;            // cm/s
        GPS_speed = _buffer.velned.speed_2d;            // cm/s
        GPS_ground_course = (uint16_t)(_buffer.velned.heading_2d / 10000);   // Heading 2D deg * 100000 rescaled to deg * 10
   _new_speed = true;
        break;
    default:
        return false;
    }

   // we only return true when we get new position and speed data
   // this ensures we don't use stale data
   if (_new_position && _new_speed) {
      _new_speed = _new_position = false;
      return true;
   }
   return false;
}

#endif  //UBLOX
Attachments
u-blox-config.ublox.zip
(868 Bytes) Downloaded 252 times

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: GPS integration

Post by LuFa »

Hi EosBandi ,

Great ! can you tell us how to add it into the I2C Code ?

thanks so mutch

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

LuFa wrote:Hi EosBandi ,

Great ! can you tell us how to add it into the I2C Code ?

thanks so mutch


I'll integrate it into the i2c code during the upcoming week.

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

MTK Binary parser

Post by EOSBandi »

And here is the Binary parser for MTK based modules with DIYDrones custom firmware (AXN1.30_2389_3329_384.1151100.1_v16.bin)
Replace the

Code: Select all

 if (GPS_newFrame(SerialRead(GPS_SERIAL))) {

with

Code: Select all

 if (MTK_GPS_newFrame((uint8_t)SerialRead(GPS_SERIAL))) {


Also have to switch the gps module to binary mode since the diydrones firmware start at 38400baud and 1Hz update, so you have to change the speed and the baudrate too.

Code: Select all

  SerialOpen(GPS_SERIAL,38400);
    SerialPrint(GPS_SERIAL,"$PMTK220,200*2C\r\n");
    delay(400);
    SerialPrint(GPS_SERIAL,"$PMTK251,115200*1F\r\n")
    SerialPrint(GPS_SERIAL,"$PGCMD,16,0,0,0,0,0*6A\r\n");
    delay(500);
  SerialEnd(GPS_SERIAL);


Code: Select all


#if defined(MTK)
    struct diyd_mtk_msg {
        int32_t      latitude;
        int32_t      longitude;
        int32_t      altitude;
        int32_t      ground_speed;
        int32_t      ground_course;
        uint8_t      satellites;
        uint8_t      fix_type;
        uint32_t   utc_date;
        uint32_t   utc_time;
        uint16_t   hdop;
    };
// #pragma pack(pop)
    enum diyd_mtk_fix_type {
        FIX_NONE = 1,
        FIX_2D = 2,
        FIX_3D = 3
    };

    enum diyd_mtk_protocol_bytes {
        PREAMBLE1 = 0xd0,
        PREAMBLE2 = 0xdd,
    };

    // Packet checksum accumulators
    uint8_t    _ck_a;
    uint8_t    _ck_b;

    // State machine state
    uint8_t    _step;
    uint8_t      _payload_counter;

    // Time from UNIX Epoch offset
    long      _time_offset;
    bool      _offset_calculated;

    // Receive buffer
    union {
        diyd_mtk_msg   msg;
        uint8_t         bytes[];
    } _buffer;

inline long _swapl(const void *bytes)
{
    const uint8_t   *b = (const uint8_t *)bytes;
    union {
        long   v;
        uint8_t b[4];
    } u;

    u.b[0] = b[3];
    u.b[1] = b[2];
    u.b[2] = b[1];
    u.b[3] = b[0];

    return(u.v);
}

bool MTK_GPS_newFrame(uint8_t data)
{
       bool parsed = false;

restart:
        switch(_step) {

            // Message preamble, class, ID detection
            //
            // If we fail to match any of the expected bytes, we
            // reset the state machine and re-consider the failed
            // byte as the first byte of the preamble.  This
            // improves our chances of recovering from a mismatch
            // and makes it less likely that we will be fooled by
            // the preamble appearing as data in some other message.
            //
        case 0:
            if(PREAMBLE1 == data)
                _step++;
            break;
        case 1:
            if (PREAMBLE2 == data) {
                _step++;
                break;
            }
            _step = 0;
            goto restart;
        case 2:
            if (sizeof(_buffer) == data) {
                _step++;
                _ck_b = _ck_a = data;            // reset the checksum accumulators
                _payload_counter = 0;
            } else {
                _step = 0;                     // reset and wait for a message of the right class
                goto restart;
            }
            break;

            // Receive message data
            //
        case 3:
            _buffer.bytes[_payload_counter++] = data;
            _ck_b += (_ck_a += data);
            if (_payload_counter == sizeof(_buffer))
                _step++;
            break;

            // Checksum and message processing
            //
        case 4:
            _step++;
            if (_ck_a != data) {
                _step = 0;
            }
            break;
        case 5:
            _step = 0;
            if (_ck_b != data) {
                break;
            }

            f.GPS_FIX         = _buffer.msg.fix_type == FIX_3D;
            GPS_coord[LAT]      = _buffer.msg.latitude  * 10;   
            GPS_coord[LON]      = _buffer.msg.longitude * 10;   
            GPS_altitude      = _buffer.msg.altitude;
            GPS_speed                   = _buffer.msg.ground_speed;
            GPS_ground_course           = _buffer.msg.ground_course;
            GPS_numSat              = _buffer.msg.satellites;
            //GPS_hdop         = _buffer.msg.hdop;
            parsed = true;
            GPS_Present = 1;
        }
    return parsed;
}
#endif //MTK

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: GPS integration

Post by LuFa »

did you have change the PID Parameter for the Ublox Parser ?

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: GPS integration

Post by EOSBandi »

LuFa wrote:did you have change the PID Parameter for the Ublox Parser ?


No, But I tested some more pid's Currently i fly with these settings :
PosHold 0.14 0.00
PosHoldRate 2.8 0.10 0.055

Your mileage may be different.... :D

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: GPS integration

Post by jevermeister »

Andras,
can you sum up the parameters for GPS`? The thread is quit long.
We should update the FAQ ASAP, I will contact Alex for this.

Nils

ReM
Posts: 14
Joined: Sun Jul 08, 2012 12:02 pm
Location: Lithuania

Re: GPS integration

Post by ReM »

brettwal wrote:
ReM wrote:I set in I2C_GPS_NAV.ino for MediaTek:

Code: Select all

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Setup
//
void setup() {

  uint8_t i;

  // GPS setup
  Serial.begin(9600);
  delay(2000);
  Serial.println("$PMTK251,115200*1F");  //speed 115200
  delay(1000);
  Serial.begin(115200);
  Serial.println("$PMTK314,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"); // CGA, RMC, GSA
  Serial.println("$PMTK220,100*2F"); // 10 Hz


I do not know whether this is really true, but this works OK.

Sorry for my bad english...



Battery is done for, replace it.


No, my GPS module without battery...

Post Reply