MultiWii GPS support

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

MultiWii GPS support

Post by MichalM_sk »

GPS to I2C board for MultiWii by MichalM_sk.rar
GPS to I2C adapter board sources + pcb layout
(23.76 KiB) Downloaded 1284 times
Hi,

MultiWii 1.8 with gps I2C support here http://www.sendspace.com/file/x2pfoa

I am software developer and fan of Multiwii project :) . Before two weeks ago I started a project to support gps for multiwii. I ordered serial gps module EM-406 - very slowly so replaced!! by the Skylab SKM53 (Mediatek MTK3329 chipset) and developed hardware (based on atmega 168) & software to read gps NMEA strings from gps module, parsing data from nmea and sending these data (now are sending Altitude,Latitude, NumSats) 10 bytes data packet via twi (i2c) interface of atmega 168 to master multiwii control board. I2c communication is directly based on twi interface and TWI registers. Supported and tested is 100Khz and 400Khz i2c bus speed. System stability of my i2c sensor emulation ist good now but much time was necessary until I solved all problems with system freezing. My multiwii board contains (wmp,nk,bmp085,hmc5843 and now gps :) ) No changes to multiwii control board twi interface code only added gps support.

Status: relased first version - work only with Mediatek MTK3329 chipset with a different
chipset will not work - differently config GPS sentenses.
I used SKM53 gps module , check "read info.txt" in package!! .


Connecting elements:

GPS to I2C board TX -------------> RX of GPS module
GPS to I2C board RX -------------> TX of GPS module
GPS to I2c board VCC -------------> VCC of GPS module
GPS to I2c board GND -------------> GND of GPS module

Video - Data only for visualisation, I work on position hold algoritm, no decimal precision of alt,lat,lon for now :)
http://www.youtube.com/watch?v=N2DuavNyLHE

Top side of gps board
Image

Bottom side of gps board
Image

I2c connection with control board
Image
Last edited by MichalM_sk on Tue Sep 06, 2011 11:59 am, edited 7 times in total.

miniquad
Posts: 65
Joined: Wed Mar 23, 2011 8:17 pm

Re: MultiWii GPS support

Post by miniquad »

Looks very interesting. Keep up the good work. :)

Kayle
Posts: 141
Joined: Sun Feb 13, 2011 6:45 pm

Re: MultiWii GPS support

Post by Kayle »

Hey michalM_SK,

Thats awesome. Really great. Where do yo come from?

Did you think to realize a position hold with your gps code?

Kind regards
Kayle

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: MultiWii GPS support

Post by Alexinparis »

Hi Michal,

It's a great news toward a GPS integration.
do you you have an idea about the time needed to sent the 23 bytes over I2C at 400kHz ?

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

Kayle wrote:Hey michalM_SK,

Thats awesome. Really great. Where do yo come from?

Did you think to realize a position hold with your gps code?

Kind regards
Kayle


Hi, I am from Slovakia.
Position hold is goal of this project.

Alexinparis wrote:Hi Michal,

It's a great news toward a GPS integration.
do you you have an idea about the time needed to sent the 23 bytes over I2C at 400kHz ?


Thank you, I modifies code (master side) and find out what time it is necessary to transfer all gps data via I2C 400kHz.

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

I modified code to view duration of i2c operation (reading gps data - 23 bytes)

Code: Select all

uint32_t sTime = 0; //start time
uint32_t eTime = 0; //end time
uint32_t dTime = 0; //duration time

sTime = micros();
//change I2C bus speed to  400kHz
TWBR = ((16000000L / 400000L) - 16) / 2;
i2c_rep_start((9<<1) + 1);       //GPS I2c address 0x09 (7bit)  and 0x12 (8bit)

for(uint8_t i = 0; i < 22; i++)
      gpsData[i]= i2c_readAck();
gpsData[22]= i2c_readNak();
eTime = micros();
dTime = eTime - sTime;
Serial.print("duration of i2c operation in uSec:  "); Serial.println(dTime);

results:

Code: Select all

100kHz - 692 uSec
400kHz - 616 uSec

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

I added a new video with full implementation to MultiWiiConf.

http://www.youtube.com/watch?v=PZN7VO-xhuE

Kayle
Posts: 141
Joined: Sun Feb 13, 2011 6:45 pm

Re: MultiWii GPS support

Post by Kayle »

Hey michalm_sk,

Great, keep going. I check the details from the gps modul you are using. The positional accuracy is normaly 10m. Do you think there is a good position hold function thinkable?

Greetings Kayle

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

Kayle wrote:Hey michalm_sk,

Great, keep going. I check the details from the gps modul you are using. The positional accuracy is normaly 10m. Do you think there is a good position hold function thinkable?

Greetings Kayle


+- 10 meters is normal positional accuracy for non-SBAS (WAAS, EGNOS,...). but sirfstar III chipset in EM-406 support WAAS. so I will test it with WAAS enable. Only tests confirm what is the real accuracy. Also it is possible to use any other GPS module (connected to gps board) with standard NMEA 0183 data format ;)

User avatar
c2po
Posts: 22
Joined: Fri Jun 24, 2011 7:31 pm
Location: Atlanta, GA

Re: MultiWii GPS support

Post by c2po »

MichalM_sk wrote:

Code: Select all

100kHz - 692 uSec
400kHz - 616 uSec

I'd hate to tell you that those numbers are a little bit off. There is no way that reading 23 bytes will take such a short time. :?
Let's do some math: at 100kHz one bit takes exactly 1/100000 = 10us, so one byte with start, ack, and stop bits will take about 100us. Reading 23 byte should take about 23 * 100 = 2300us, plus you need another 2 bytes of address before that, so total would be 2500ms.
At 400kHz it will be much faster, one byte is about 30us, so 23 * 30 = 690 plus 2 bytes of address, 750us total.
To prove the math I attached the screenshots from oscilloscope. ;)
First two show signals at 100kHz, and the third one is at 400kHz.

Image Image Image
Attachments
I2C_400kHz_1.gif
(9 KiB) Not downloaded yet
I2C_100kHz_2.gif
(8.97 KiB) Not downloaded yet
I2C_100kHz_1.gif
(7.58 KiB) Not downloaded yet

Felch
Posts: 9
Joined: Mon Mar 21, 2011 9:23 pm

Re: MultiWii GPS support

Post by Felch »

Supppose you will not use i2c but custom bit-banged protocol sending blindly data and clock? Then speed depends only of yor processors clock (assuming that int's are disabled during transfer). In that case you'd need a separate processor at the gps side collecting and deciphering data from slow gps module. As soon as main processor enables transfer, it could be done very quickly.
I used such trick in my gamma-spectrometer (PhD work). Can't tell exact transfer time right now but it was below 1ms for sure.

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

Re: MultiWii GPS support

Post by EOSBandi »

HI Guys,
I appriciate the work to bring gps to MultiWii, but do we really need to go along the i2c path? The amount of data that we need to move is quite big, compared to the sensor data and with a 10Hz GPS it will slow down the cycle time significantly. Plus the serial to i2c conversion also add unneccessary complication to the system. I rather suggest to connect gps to a serial port. I know that the Arduino mini does not have enough ports, but some of the recent developments also requires a ATMega 2560 or similar board.
Regards,
Andras

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

I use custom i2c protocol, 23 bytes was sent only for visualization purposes in multiwiiconf, currently is addressed only 10Byte (4 bytes Latitude , longitude and 2 conf bytes), control board read data from i2c GPS every 100 ms. Reading speed at 400 kHz is now comparable to the HMC5843.

Refresh rate of EM406 GPS module is too low (1Hz) so it is currently used MediaTek MT3329 GPS module with refresh rate increase up to 10Hz.

In the coming days I will test it, but in the moment I have a problem with PID values ​​on dev firmware. Default values is not working for me.

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

currently is implemented the routine to hold position and go home position (not complete - missing yaw correction)

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

Project status:

Position hold work (still needs a lot of testing) but i have gps unacuracy during the day sometimes up to 20 meters (in Slovakia, like elsewhere in Europe), about 10 - 11.00 pm only 1 to 2 m.

I have to try it when the geometry of satellites in the sky to determine the best accuracy.

babelo
Posts: 28
Joined: Wed Jul 06, 2011 12:56 pm

Re: MultiWii GPS support

Post by babelo »

Hi,

Do you have the code or diff from svn ? I wan to do a try with my gps from remzibi osd :))

Thanks

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

babelo wrote:Hi,

Do you have the code or diff from svn ? I wan to do a try with my gps from remzibi osd :))

Thanks


Hi,

At the moment the project is not public, want to have any testing until it was finalized.

For GPS position hold will be required:

- GPS sensor board (serial MTK GPS connected to developed custom I2C board)
- Magnetometer (determine the size of the angle between the head and the true North)

babelo
Posts: 28
Joined: Wed Jul 06, 2011 12:56 pm

Re: MultiWii GPS support

Post by babelo »

Ok so, i can continue to look at part of code from ardupirat, which took pid loop for lat / lon, and maybe heading can be read from gps too when copter is in move.

Code is there just need to extract part for NMEA serial, reading / pid loop

KaiK
Posts: 58
Joined: Thu Jul 28, 2011 8:32 pm
Contact:

Re: MultiWii GPS support

Post by KaiK »

I am just playing around with a Holux GPSlim 236 on a Arduino Mega Serial port.

I think the NMEA protocol doesnt provide a higher update rate than 1 Hz, which should be high enough for position hold an autonomous flight (and in contrast to the speed of quadrocopters and the precision of GPS)?

Regards
Kai

Lapino
Posts: 84
Joined: Tue Aug 16, 2011 10:01 am

Re: MultiWii GPS support

Post by Lapino »

here's some kind of motivation to get GPS support going ;)
http://www.multiwii.com/forum/viewtopic.php?f=7&t=469&p=3244#p3244

Greetings,

Lapino

Maciek
Posts: 1
Joined: Tue Jul 26, 2011 11:22 pm

Re: MultiWii GPS support

Post by Maciek »

Hello Michal

I would love to hear if you've made any progress with your GPS software and are perhaps ready to share it with us...

Thanks

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

Hi,

I returned from vacation.

Following days I will implement my code to multiwii 1.8 and then publish the source code.

Info for all interested

This project is built on the Arduino pro mini platform which has only one serial port. Therefore, communication with the GPS is solved through the I2C bus. After more testing I found no errors during i2c comunication with my board so there is no freeze I2C bus, which could cause an accident.

Benefits I2c solutions

Main CPU does not slow down with reading serial port data (every 100ms), decoding the GPS data, position data averaging
Only 10Bytes is sending via I2C
Very short transfer time (about 300 us)
400kHz I2C bus

vps_rj
Posts: 4
Joined: Mon Aug 29, 2011 3:45 pm

Re: MultiWii GPS support

Post by vps_rj »

Amazing. I'm new to this world of MultiWii, but i want to help soon! I'm a Java programmer and i want to contribute with to help our platform be bigger and mature.

I need to take a look at this forum to start with this exciting world...
Best regards!

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »


goofy23
Posts: 1
Joined: Wed Aug 31, 2011 10:45 pm

Re: MultiWii GPS support

Post by goofy23 »

Wow i am really astonished how fast the things moved.
I am still full of work and have hardly any time to test all the thing which are new here.
Did a quick test with a Flyduino V2 and a FMP04, got no fix.
Changed the serial3 simply to serial2 but may i am wrong and its more complicated.
I think my serial mapping makes some problems, as the GPS proved to work on the megapriate before.
Its on Serial2 for the V2 Flyduino.
The cables should arrive tomorrow, but i still need some time to evaluate the new GPS module abugsnightmare found, have it here but didnt connected it, in my opinion its a hot item and the support will be good, it will be also relaitve cheap.
So more will come for sure.

User avatar
SoundMTB
Posts: 37
Joined: Tue Jul 26, 2011 8:17 am
Location: Germany Osnabrueck
Contact:

Re: MultiWii GPS support

Post by SoundMTB »

Dear Michal,

I very interested in your GPS solution.
Can you give me your schematic and source for the GPS adapter board to implemt this in my MULTIWII Copter with Arduino Pro Mini?

thanks
Oliver

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

SoundMTB wrote:Dear Michal,

I very interested in your GPS solution.
Can you give me your schematic and source for the GPS adapter board to implemt this in my MULTIWII Copter with Arduino Pro Mini?

thanks
Oliver



Hi,

sources & pcb layout in my first post

User avatar
SoundMTB
Posts: 37
Joined: Tue Jul 26, 2011 8:17 am
Location: Germany Osnabrueck
Contact:

Re: MultiWii GPS support

Post by SoundMTB »

Thanks
sorry I was so happy to find a GPS solution than I haven't seen the file

gread job
Oliver

MatthiasW
Posts: 2
Joined: Fri Sep 09, 2011 7:56 pm

Re: MultiWii GPS support

Post by MatthiasW »

Hi MichalM_sk,

thank you for posting your GPS-I2C-Converter.
I have a 4800baud-GPS-Modul (1Hz). Am I able to use your converter as it is, or are there changes to be done in the Mega168-Firmware ?
Can you send me the sourcecode? Then i can do the changes myself.

Thank you alot
have a nice day
Matthias

Ben_der
Posts: 9
Joined: Thu Aug 25, 2011 5:22 pm

Re: MultiWii GPS support

Post by Ben_der »

Has anybody an idea what happened to MichalM_SK ?

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

Re: MultiWii GPS support

Post by PatrikE »

Userstats say
Last visited:02 Nov 2011 10:34

So probably done something else for a while. 8-)

leszczuarek
Posts: 1
Joined: Thu Jan 12, 2012 6:57 pm

Re: MultiWii GPS support

Post by leszczuarek »

Hi
Sorry for my english
I want to build this project
to my multiwii
I have 2 questions about the construction.

First Q2 how much Mhz?

Second Does the GPS sensor will be good?
http://www.maritex.com.pl/pl/shop/produ ... /1/backurl
Thank you very much for your help.

skazic
Posts: 1
Joined: Thu Aug 11, 2011 7:37 am

Re: MultiWii GPS support

Post by skazic »

Hello,
I have a plan to create a GPS I2C adapter board, but I encountered a problem in the making.
Unable to figure out the value of Q2.
It would be very grateful to you if we who says that value
Thanks
Last edited by skazic on Thu Jan 19, 2012 10:32 am, edited 1 time in total.

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

Re: MultiWii GPS support

Post by PatrikE »

I think it will work.
It have both Serial and USB ports.

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: MultiWii GPS support

Post by marbalon »

leszczuarek wrote:Hi
Sorry for my english
I want to build this project
to my multiwii
I have 2 questions about the construction.

First Q2 how much Mhz?

Second Does the GPS sensor will be good?
http://www.maritex.com.pl/pl/shop/produ ... /1/backurl
Thank you very much for your help.


Hi,
I think you are from Poland so please read this post ;)
http://rc-fpv.pl/viewtopic.php?t=5576

But fer every other people who want to use this module - I have custom firmware for this module with 10Hz support and binary protocol ;)

ProstetnikJeltz
Posts: 1
Joined: Tue May 01, 2012 6:47 pm

Re: MultiWii GPS support

Post by ProstetnikJeltz »

Hello Michal,

great work !

Could you please also post a schematic of the pcb.
In your first post are the pcb and the placement of the parts but no schematics.
I just bought a TQFP-Breakoutboard and don't want to use your PCB due to space problems in my copter .
May you be so kind, to attach it here ?

Greetings from Munich Uli

MichalM_sk
Posts: 89
Joined: Wed Jun 15, 2011 5:04 pm
Location: Slovakia

Re: MultiWii GPS support

Post by MichalM_sk »

Hi,

new schematic + latest hex (from 3.10.2011) in attachment.
I use my I2c board about one year without any problems. Now with modified MultiWii 2.0 ;)

Regards Michal M
Attachments
gpsI2cBoard.zip
(15.43 KiB) Downloaded 402 times

chandoo
Posts: 1
Joined: Mon Jun 18, 2012 12:57 pm

Re: MultiWii GPS support

Post by chandoo »

KaiK wrote:I am just playing around with a Holux GPSlim 236 on a Arduino Mega Serial port.

I think the NMEA protocol doesnt provide a higher update rate than 1 Hz, which should be high enough for position hold an autonomous flight (and in contrast to the speed of quadrocopters and the precision of GPS)?

Regards
Kai


Hello Kai
I just placed order for my multiwii quad parts, waiting for shipment to be delivered.
I have Holux GPSlim 236 as well, and i am totally new to electronics and Quad Copters, this is my first attempt in doing something in this Hobby.

since holux gpslim236 can output gps data over bluetooth interface, initially i thouhgt of getting bluetooth module for Cirus Multiwii SE and interfacing with Holux GPSlim236 in getting the gps data, later i found that mini USB interface on Holux GPSlim can output serial data.
I found this info regarding the holux gpslim 236 pinout
http://pinouts.ru/GPS/holux_gps_pinout.shtml
i thought it might help.
If you are still playing with GPSlim236, I will be joining you soon .

Thanks
Chandoo

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

Re: MultiWii GPS support

Post by EOSBandi »

Forget the holux, it's a SirfIII based module, max 1Hz update rate. Not enough for poshold.

spidi
Posts: 5
Joined: Mon Jun 04, 2012 3:44 pm

Re: MultiWii GPS support

Post by spidi »

What do i need to coonect GPS to my MultiWii SE board?

Can you please give me link to best price?

Thank You!

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

Re: MultiWii GPS support

Post by LuFa »

thats know the right plase to ask question about gps :
viewtopic.php?f=8&t=649

User avatar
ezio
Posts: 827
Joined: Sun Apr 01, 2012 11:03 pm
Location: Paris
Contact:

Odp: MultiWii GPS support

Post by ezio »

I started to think about buying a gps. Which one is better u-blox or MTK?

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

Re: MultiWii GPS support

Post by flyrobot »

I have both MTK and ublox, i still prefer MTK chipset FMP04 from flyduino (its serial). FMP04 just plug and run without any modification and very good signal reception.

Post Reply