GPS sensor

Development & General Chat for the superb openxvario project.

Moderator: rainer

Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS sensor

Post by Carbo »

One goal of the GPS integration in oXs was the calculation and transmission of glider performance in flight. Meanwhile this works with airspeed, but with GPS-speed there is still a too large influence of wind, even when the wind is not noticeable for the pilot, like in this flight:
org.png
But there seems to be a chance to calculate and eliminate the wind influence, using the heading-data of the GPS. If you fly a circle with constant vertical speed, you have all necessary information: maximum speed - minimum speed = 2 x windspeed. Heading of maximum speed is equal the heading of the wind. With this the adjustment of GPS speed could be done.

On the other hand, there is still the risk, that the windspeed is not constant at all, and particularly the windspeed (and the heading) is not constant with altitude.

Mounting a GPS in a plane is much easier, than mounting a pitot-tube, also the pitot-tube and its attachment may have an influence on the performance of the plane.

Continue with GPS or develop a pitot-tube holder, that is easy to mount for measuring flights?

mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

It does not seem me easy to eliminate the wind influence using the heading data of the GPS.
First the sensor would have to recognise that you fly a circle (at a quite uniform rate).
Second, how could the sensor identify that you fly at constant speed (without an airspeed sensor) because the GPS speed will varies.
Imagine, that this is done, oXs would probably says that wind speed = (max GPS speed - min GPS speed)/2 and would check that the max and min where reached at 180 degree each other.
Then it could calculate the "airspeed" based on GPS speed , GPS heading and just prior calculated windspeed.
Still this assume that wind speed stays constant and this is probably not true.

I do not think that mounting a pitot tube could have an influence on the performance of the plane because it is quite small (about 3mm diameter and a few cm length).
Please note that:
- airspeed sensor MS4525 is quite small
- it is possible to put the MS4525 sensor anywhere (e.g. close to the pitot tube) and having a quite long wiring between MS4525 and Arduino
- position of pitot probe is probably less critical than a TEK probe.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

I can see how the wind speed and direction can be calculated, very clever BTW.
And so air speed is estimated from this by taking into account heading.
How would this work when a thermal is present and air is drawn towards thermal changing the direction of the wind?
But maybe this is still a good tool for tuning glide ratio in relatively calm conditions.
I tested my GPS outside today, I just walked up and the street and watched speed and distance to look for lag, logged at 0.1 to see what rate it did,
Lag was none existent , I stopped and it stopped etc.
Logs showed that 2 values were repeated and some times 3 or 4 but mostly 2 so I think it seemed to be 5hz.
Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS sensor

Post by Carbo »

nigelsheffield wrote:How would this work when a thermal is present and air is drawn towards thermal changing the direction of the wind?
But maybe this is still a good tool for tuning glide ratio in relatively calm conditions.
Yesterday i tested around 14:00 in the fog. You could not even guess, where the sun is. Despite of there were a lot of small thermals, not useable for climb, but enough to destroy any measurement. I too had the illusion, to measure in calm conditions - it does not work. Dusk or dawn are unfortunately the only 2 possibilities without illuminating your plane.

@mstrens: I will do the next flights with airspeed and GPS, and i try simulate the idea of adjusting GPS-speed in the csv.

And i will try to find a more elegant solution for the pitot-tube.
Testsonde.jpg
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Still, even if the GPS speed is not useful for total energy or tuning in anything other then perfect calm, it is still a good addition to openxsensor, much better and cheaper then frsky offering.
Then there is the gy86 which you mentioned could possibly be used..

Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS sensor

Post by Carbo »

Sorry for my english. My statement was not against GPS, i flew with airspeed and GPS. Both were not able to measure anything helpful to transmit the glider performance data, because of the troubled air.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

No apology needed, my enlish is ok becvause i am english, my other languages are none exixtent lol,
Trying to trim out a glider in turbulent conditions is difficult if not impossible one can only get it so close and no amount of measuring equipment can really fix that I think..
In dead calm and flying in a straight line I think that GPS speed could still be useful for glide ratio tuning.
Sadly here in uk dead calm is VERY rare too.

Air speed sensor and tek probe are something I am intrigued by but have not yet attempted , like you I find that fitting them on a plane seems difficult to do neatly. And I don't have skills or equipment to build the probes, they do seem be getting cheaper to buy though so maybe soon I will do it.

Where can I buy the ms4525 you mention?
Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS sensor

Post by Carbo »

Best to make a google search for the sensor, but only this one works with oXs:

4525DO-DS5AI001DP

I bought from digikey, but maybe there are cheaper possibilities.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Thanks both!
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

hi i see you are doing the mpu6050 now, great news!
will this give levels for artificial horizon script?

i have the gy-86 ordered and also a gy-521 which i am hoping will be able to work with my gy-63 that i have already many of, will this be possible and how might i do it?
thanks.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: GPS sensor

Post by jhsa »

mpu6050? on the oXs? what will it do??

Thanks

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Mstrens is hoping to use it to give better vario tones, faster response using a combination of the alt and acc readings.
Also there is a script for taranis ( and you could probably do something on an android device maybe?) Which gives a full GPS heads up display including an artificial horizon IF the levels are available. This could be useful if suddenly your plane dissapear in cloud etc, you could fly by instruments alone and return your craft to overhead .
The sensors are cheap now too, the gy86 includes the ms5611, acc and compass for £7 odd.the gy521 is about £1 with just the gyro. GPS cost £7.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: GPS sensor

Post by jhsa »

Ahh ok. I don't let my planes enter the clouds when I'm at the field. Normally it is forbidden to fly RC models at such altitude because it could interfere with real air traffic and cause an accident, unless the clouds are really low, of course :)

I asked because maybe angle of attack could be used for vario compensation instead of airspeed. I remember a discussion about that a couple years ago..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

I wrote some code in order to read the data provided by a mpu6050. In fact I copied large part of code from nav6 project because this project seems to use the latest DMP firmware from invsense about mpu6050. I have not foreseen to read the magnet sensor because it is only usefull to avoid gyro drift on the yaw axe.

The code is available on github in branch openXsensor_mpu (which integrates GPS support, glider ratio and hott protocol too).
Still take care that this code just compile but has not been tested. I am still waiting for a GY86 device to test it. Furthermore, it does not yet include any code to transmit new data to the Tx nor code to merge acceleration into vertical speed..
If it works, it should be possible to transmit the pitch and roll. So I presume you could display an artificial horizon on the Tx.
Still, I already see that it requires quite a lot of flash memory. When I activate just the Sport protocol, the baro sensor and the MPU, it requires about 29k flask (on the 30k available).
So when some more code will be added, it will not be possible to activate simultenously other options like GPS, airspeed, voltage, current,...
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Flying in low cloud or sudden fog or mist or haze or just looking away and not finding the glider in the sky etc is more what I had in mind but the cool factor alone makes it fun to try.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

http://www.rcgroups.com/forums/showthread.php?t=2482328

Flarrison has the GPS and IMU plus vario code fit in size but no pitch and roll, I wonder how difficult it would be to add that?
I guess if size is a problem sport would allow another pro mini to just do the IMU side, but hub then would not be able to do both?
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

I had a look at the link you provided on rcgroups.
As far I can see, the code that Flarrison use for GPS is different. It reads NMEA messages sent by GPS. I prefered to decode UBLOX format messages because it requires less CPU from arduino.
So oXs has more "free time" to handle other tasks (like voltage conversions). still it could be that it requires some more fash memory.
For GPS, I also have some code to configure the GPS (because some module does not have an EEPROM to save a config). For a NEO7, it is possible to get data at 10hz (activating a line in oXs_GPS.cpp file).
Still you will probaly be limitted by the number of bytes that can be transmitted by the Frsky protocol. Anyway, it would reduce the latency. Still, not sure it is really useful.

About mpu6050, there is a major difference.
Flarrison code just reads the raw data from the sensor (acceleration and gyro) and take care of some offset. The code to do so is quite small.
In fact, when you want to know the attitude of the plane refered to Earth, you need to combine the acceleration and the gyro data and take care avoiding gyro drift. This is called a fusion algorithm.
The library that Flarrison uses have some functions to do it.
In fact it has 2 ways doing it. One is to perform the calculation on Arduino level; the second one is to upload some program inside the MPU6050 and let the MPU6050 perform the fusion. This is called DMP.
I decided to use this second method because it free up the arduino CPU and let the fusion to be performed at 200Hz.
Still, it could be that this requires finally more flash memory because the MPU6050 code has to be store in Arduino too (because the Arduino has to send it to MPU6050 at each startup).
The library that Flarrison uses contains an old version of the MPU6050 DMP that is also shorter than the latest version I am using (provided by the MPU6050 manufacter).

All this explains the difference in size.
Perhaps I will try the oldier MPU6050 DMP. It could be that it free up about 1k flash memory.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Thanks for explaining that to me, I found that your GPS code ran faster updating the lat and long etc, flarrison said his would run faster without using nmea.
Also he uses a cut down version of the openxvario I think to save space?
I suspect the code to get attitude would push his version over the memory limit too but I am hoping it's possible , I think uploading the DMP to the mpu6050 is best like you say.
Great work you are doing here.
Obviously your methods will be faster and give better smoother results as long as you can sqeaze it all into the memory.
Fingers crossed!
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

clock-2015-11-07.csv
(62.07 KiB) Downloaded 196 times
i set the gps to 10 hz after mstrens mentioned how to do it.
raining outside so i just tested out of window but here is results, you can see sometimes the values are same for a while but other times they change every 10th of a second, but that probably just the different field being sent at different times.
looks like 10hz is working anyway. 8-)
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

If you have only the GPS data being transmitted, oXs get in theory a polling request from the receiver every 20 (or 22 - I never remind) msec.
At each polling, oXs sent one of the 5 data to be transmitted.
So it takes about 100msec (or 120 msec) to send all GPS data.

If you ask oXs to send other data too, then polling for GPS will probably be only 30 msec (or 33 msec) and it will require about 150 msec to transmit all data. If GPS gives new data every 100 msec (10 Hz), then some data will not be sent.

Note : even if a new value is available and sent every 50-80msec, I already saw that the log at 10hz still repeat sometime some value. I cant't explain it. I presume it is caused by the transmission between Rx and Tx or by the telemetry/log on openTx.
Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS sensor

Post by Carbo »

Possibly nigelsheffield moved too slow, to have new coordinates every 1/10 s, look at the gps speed. The gps resolution is not high enough, to cover this.
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: GPS sensor

Post by MikeB »

The SPort is polled every 12mS, but any one sensor is not polled faster than every other one of these, so every 24mS.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

think the vario data is being sent too even though the vario is not connected so this might slow it down a bit too, but yes i was just hanging out of window so data changes in gps position etc wont be much , i will test more tomorow if it stops raining .
i imagine the data updates not being synchronised with each other will throw up a lot of repeated data, but to be honest 5hz is fast enough and the main thing i noticed when testing at 5 hz even was there was no lag like the frsky gps is reported to have, when i stopped the gps speed stopped etc.
and logging at .1 internvals would be impractical as files will be huge once flying for a hour lol.
Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS sensor

Post by Carbo »

Here is a log with 5Hz and a 5Hz GPS, full charged oXs with airspeed and vario and there is an update every 0,2s
5Hz.png
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

I think I need to build the GPS properly ( it is just connected with cables and jumpers etc ) and fit it in a plane and test properly.
Apart from rubbish weather the glider I intended it for stopped working the other day , the x4r just refused to connect to tx so that has been sent back to t9hobbysport and waiting for a replacement. Only used it for a couple of months so disappointing and a bit scared to use another one , the d8r and d4r are 3 years old and work perfect ..

GPS signal is pretty poor in my street and it takes ages sometimes won't work at all to get the GPS started after turning on RX etc, makes testing difficult when it's raining all time lol....
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Ok I stuck in the car and went for a drive,
Results much better, most of the time 10 hz is working with just the occasional repeated value but this could well be down to bushes building etc etc.
Though it did tell me I was going at 50 mph when I was doing 30, opentx obviously not changing the value from kmh to mph.
Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS sensor

Post by Carbo »

Cool, that oXs works with 10Hz too, mstrens wrote in oXs_config_description.h:

#define GPS_SPEED_IN_KMH : uncomment this line if GPS speed has to be sent in km/h instead of knot/h

So if you want miles/h, you can only use the ratio field in openTX Telemetry 2.1.X, here is a statement, with that information you can calculate the ratio (it is not very intuitive):

viewtopic.php?f=86&t=7393#p100681
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Thanks yes I did read that line about sending in kph and think I have it sending in kph now, tx is set to imperial and so announced mph but does not convert the number then, I am using opentx 2.0.17 so need to send it in knots then.
I take it that opentx 2.0.17 does not convert knots to mph then and if I want mph then I need to somehow covert it maybe in a lua script.
Another reason to move up to 2.1 soon then.
But yes very cool that it works at 10hz, and such a nice small and cheap GPS too.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Changed to knots and speed seems correct now.
Just out of interest not pestering, will support for D8 series rxs be added to the GPS code sometime?
My gy-86 is now posted at last and tracking is working so hoping it arrives soon and I can help test out your IMU code.

Post Reply

Return to “OpenXVario - an open source vario supported by the open source firmwares!!”