GPS sensor

Development & General Chat for the superb openxvario project.

Moderator: rainer

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

Re: GPS sensor

Post by mstrens »

I can add that the reaction time (and smoothing) is related to the frequency the updates (yaw, ...) are calculated.
I think that yaw, pitch and roll are calculated 50 times a second.
Imagine that yaw has a suddent change from 0 to 100 (which is normally not possible but it is just to explain)
If X = 0.1, it means that the smoothed yaw will change quite fast
At t= 0, smoothed yaw = 0
At t= 0.02 sec (1/50) , smoothed yaw will become 0 + 0.1 (100-0) = 10
at t = 0.04 , it becomes 10 + 0.1 (100-10) = 19
at t = 0.06, it becomes 19 + 0.1 (100 - 19) = 27
at t= 0.08, it becomes 27 + 0.1 (100 - 27) = 34
at t= 0.1, it becomes 34 + 0.1 (100 - 34) = 41
etc.
You can think in this way: a suddent change will be greatly present on the smoothed values after 1/X updates.

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

Re: GPS sensor

Post by nigelsheffield »

Yes, so a large spike would not be smoothed particularly well..
If yaw is updated 50hz then smoothing that or calculating smoothed yaw from that at the rate it comes but only sending it 10hz might improve results somewhat.
The other method would be to average the last 10 ? Or so results by adding them together and dividing by 10, then each reading during the cycle has same weight. Though I think this would also be prone to spikes if not enough results were averaged.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

bellow is another attempt at smoothing the yaw rate, seems to work, what do you think?
I have not done the calculation for exact measurement based on the time sampling factor.
cant test it out in air as my minimoa test glider crashed other day and is out of action for a while(maybe permanently).
need to get another glider fixed up with the sensors soon.

#if defined (VARIO) && defined (USE_6050)
static int32_t previousYaw ;
static int32_t countYaw ;
static int32_t totalYaw ;
static int32_t smoothYaw ;
static uint32_t previousYawRateMillis ;
uint32_t currentMillis ;
totalYaw+=yaw.value;
countYaw++;
currentMillis = millis() ;
if (currentMillis >= previousYawRateMillis + 50 ) {

smoothYaw=(totalYaw/countYaw);
test1.value=(smoothYaw-previousYaw);
previousYaw=smoothYaw;
//if (yaw.value-previousYaw<340&&yaw.value-previousYaw> -340){

totalYaw=yaw.value;
countYaw=1;
test1.available = true ;
previousYawRateMillis = currentMillis ;
//test1.value += 0.5 * ( ( (yaw.value - previousYaw) *1.0 ) - test1.value ) ;//this will give smoothing, first number between .1 and 1 lower number gives more smoothing

//else{
//test1.value = (yaw.value - previousYaw) *1.0 ; // calculate yaw rate in degree / sec
//}

#define DEBUGYAWRATE
#ifdef DEBUGYAWRATE
//Serial.print(lastImuInterruptMillis) ; Serial.print(" ") ; Serial.print( previousYawRateMillis ) ;Serial.print(" ") ; Serial.print( yaw.value ) ; Serial.print(" ") ; Serial.print( test1.value ) ; Serial.print(" ") ; Serial.println(oXs_MS5611.varioData.absoluteAlt.value) ;
Serial.print( currentMillis ) ;Serial.print(" ") ; Serial.print( yaw.value ) ; Serial.print(" ") ; Serial.print( test1.value ) ; Serial.print(" ") ; Serial.println(oXs_MS5611.varioData.absoluteAlt.value) ;
#endif
}
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

With a delay of 50 msec (defined in line "if (currentMillis >= previousYawRateMillis + 50 )", I think you will calculate an average yaw based on 4 raw values.
If you need more smoothing you will have to increase the delay. This will require extra code if you still want that a new smoothed yaw is calculated about every 50 msec.

From my point of view, it is easier and better (avoiding noise) to use the formula of exponential smoothing e.g. smoothYaw += 0.1 * (yaw.value - smoothYaw ) and to change 0.1 by another value depending on the smoothing you would get. For good results, this calculation has to be performed each time a new yaw.value is available.
One drawback of this kind of smoothing formula is that it can introduce some big delay when the smoothing parameter is very low (and/or the frequecy of update is low). In order to get a shorter reaction time, it is possible to apply different smoothing parameters depending on the difference between the previous smooth value and the new value. When the difference is lowen that X, then use a small value of smoothing parameter (e.g. 0.05) ; when the difference is bigger than Y, use a higher smoothing parameter (e.g. 0.4); between X and Y, you can use a linear interpolation. This is the logic that I use e.g. when calculating the vertical speed.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

So smoothing less when there is a big change?
But what if the big change is due to noise?
I guess there is always a balance between what is perfect and what is practicle and your solution sounds best.
But yes I think smoothing yaw every time it is available would be best and then transmitting the smoothed yaw and yaw rate at whatever speed is needed .
I expect all yaw pitch and roll would benefit from this sort of smoothing , having flown with it a few times it does jump about a fair bit.
There is still the problem of smoothing when changing from -180 to plus 180 to consider ..

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

Re: GPS sensor

Post by mstrens »

Normally noise is not very big.
If you do not move the IMU (or move it at a regular speed) while logging the data to the PC terminal you can see how big is the noise (e.g 5 degree).
Then you can set up the parameters in such a way that when the difference (in absolute value - I forgot to specify it in previous post) between previous smooth value and current value is less that the max noise you have seen (e.g. less than 5 degree), then you can apply quite high smoothing (so a low value smoothing parameter like 0.05). On the opposite, when the difference is about 10 X the noise (e.g. 50 degree), then you can use less smoothing (so a high value smoothing parameter like 0.5)

About changing from -180 to 180. I presume this is an issue only when calculating the yaw rate.
I expect you could try some code like:
Currently you have probably a code like :
yaw rate = (new_smooth_yaw - previous_smooth_yaw) / time_interval

I expect you could try some code like:
if ( new_smooth_yaw > 90 and previous_smooth_yaw < -90 )
yaw rate = (new_smooth_yaw + previous_smooth_yaw - 360) / time_interval
else if ( new_smooth_yaw < -90 and previous_smooth_yaw > 90 )
yaw rate = (new_smooth_yaw - previous_smooth_yaw + 360) / time_interval
else (new_smooth_yaw - previous_smooth_yaw) / time_interval
I presume it should work if yaw rate is not to high.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Right thanks, will try that next chance I get.
By noise I mean more probably from turbulence rather then sensor itself which is quite smooth.
User avatar
Wene001
Posts: 47
Joined: Wed Feb 01, 2012 11:05 pm
Country: -

Re: GPS sensor

Post by Wene001 »

Cant get GPS working

Debug says
openXsensor starting..
milli=0
freeram=946
vario is setting up..
vario is up..
END of GPS setup
FRSky Output Module: TX Pin 4
Sport Protocol =1
End of general set up


My GPS:
http://www.aliexpress.com/item/Ublox-7- ... 15475.html

All 3 GPS lines uncommented in config.h

Vcc-Vcc
GND-GND
Rx to Arduino Pin6 (10k Resistor)
Tx to Arduino RX

If i search for Sensors in OpenTX 2.1.7 i found nothing like GPS

i`m missing soemthing?

Before reading the instructions properly i connected my module like
Vcc-Vcc
GND-GND
Rx to Arduino TX without resistor
Tx to Arduino RX

maybe my module is dead...
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: GPS sensor

Post by kalle123 »

Wene001 wrote:...maybe my module is dead...
Same pro mini, which gives trouble with the MS5611?

Get your CP2102 or FTDI usb uart. Connect the module to your pc and check the module. U-center is fine for that.

You seem to have a habit of connecting everything and then find out, that the whole assembly is not working.

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

Re: GPS sensor

Post by nigelsheffield »

GPS needs time to get a lock before sensors will be discovered, put it outside and leave it powered and connected to tx for at least 5 minutes maybe more.
Check config file that GPS is enabled.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

In order to know if your GPS module is still OK, connect your GPS directly to your PC (without using oXs) as kalle123 says :
"Get your CP2102 or FTDI usb uart. Connect the module to your pc and check the module. U-center is fine for that."
U-center is a free software that you can donwload from internet (from the site of U-blox I think).

Many gps module have a led that will blink when GPS get a lock.If your module have such a led, wait that it blink before asking openTx for discovering new sensor.

Some GPS modules have an eprom that can store a GPS set up. When GPS starts, it loads this configuration.
oXs assumes that default configurations is used (e.g. using NMEA + Ublox messages via UART at 9600 bauds).
If your module is preloaded with another configuration, the commands sends by oXs will not be recognised.
Using U-center should allow you to look at the set up of your GPS.
If required, reload the default GPS configuration using u-center.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

He is using the exact same GPS as me so it should just work is its enabled gps in config file.
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: GPS sensor

Post by kalle123 »

nigelsheffield wrote:Check config file that GPS is enabled.
He wrote "All 3 GPS lines uncommented in config.h"
Nigel, I see only those THREE lines here! You have more than THREE in config.h?
// --------- 11 - GPS ------------------------------------------------------------------------------------------------
#define GPS_INSTALLED // uncomment this line if a GPS is connected
#define GPS_SPEED_IN_KMH // uncomment this line if GPS speed has to be sent in km/h instead of knot/h (only for Frsky protocol)
#define GPS_SPEED_3D // uncomment this line if GPS speed has to be the 3d speed instead of the 2d speed (note: 3d is probably less accurate - to test)
Hope, we are not discussing basics like
...antenna has to clear access to the sky... and ...a cold start takes its time... here.

A good software tool to check functionality of gps is to load https://github.com/mariopesch/SenseBoxA ... Plus-0.94b into your arduino IDE and use the examples ....
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Sorry I missed his comments on the GPS lines uncommented, just trying to help of course and I have had a couple of people ask me why GPS is not working now and all it took was for them to go outside and wait for a lock.....
User avatar
Wene001
Posts: 47
Joined: Wed Feb 01, 2012 11:05 pm
Country: -

Re: GPS sensor

Post by Wene001 »

Thanks for help

@Kalle
this is not the "problematic" one

I`ll test U-Center later
testet in and outside @ the window
waitet 10 Minutes

@nigel
Blue Wire to 10k on Pin 6 ?
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: GPS sensor

Post by kalle123 »

You don't have a arduino uno at hand?

Easiest is in my opinion to use the examples from TinyGPSPlus-0.94b.

U-Center with those settings can be tricky .....
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Wene001 wrote:Thanks for help

@Kalle
this is not the "problematic" one

I`ll test U-Center later
testet in and outside @ the window
waitet 10 Minutes

@nigel
Blue Wire to 10k on Pin 6 ?

Yes but I think I used a 6.8k as that was at hand.
Testing at window did not always work for me, I needed to go outside away from buildings and wait for lock.
I have 3 of those GPS units and all work like this.
User avatar
Wene001
Posts: 47
Joined: Wed Feb 01, 2012 11:05 pm
Country: -

Re: GPS sensor

Post by Wene001 »

My Uno should arrive in the next few days....
Do i have to worry about resistors when using the gps with my pl2303 serial adapter?
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: GPS sensor

Post by kalle123 »

I have 2 x CRIUS CN-06 and 1 x GY-GPS6MV2 modules here, which I connect directly with FTDI or CP2102..
Aliexpress page says

Schwarz zu GND
Rot + 5 V
Blau zu TX
Orange zu RX

No risk, no fun :mrgreen:
User avatar
Wene001
Posts: 47
Joined: Wed Feb 01, 2012 11:05 pm
Country: -

Re: GPS sensor

Post by Wene001 »

We got live jim
I took my 20m USB extensions and put the Ublox 7 on a table in the garden completely free sky.
I got a fix after 15min 5 Sat fixes between 22 and 29 dB visulaized in U-center.
Do you have the same weak signals?
Anything i can try?
Last edited by Wene001 on Thu Apr 28, 2016 4:21 pm, edited 1 time in total.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Not tested for number of sats but in garden still takes a while for lock and it can lose it again, once down in flying field the lock still can take a few minutes on first connecting power but never loses it and locks right away on subsequent battery packs.
User avatar
Wene001
Posts: 47
Joined: Wed Feb 01, 2012 11:05 pm
Country: -

Re: GPS sensor

Post by Wene001 »

I found this on google
Image
Mine looks this way (under clear sky)
Ublox7.jpg
Very weak i think

Tested u-center for android
on the same Table in my garde my Sony Xperia have a fix in 5 seconds
Handy.jpg
User avatar
Wene001
Posts: 47
Joined: Wed Feb 01, 2012 11:05 pm
Country: -

Re: GPS sensor

Post by Wene001 »

@ mstrens
Which GPS do you have. And are you satified with this?
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

In fact I got one that I used for developing and testing oXs but I do not use it for flying so I do not have really experience.

Normally I get a fix outside in 1 or 2 min I think.

About your gsm, if you already used the gps some hours (days?) before, then the gsm stores some data and it helps a lot getting a fix faster.
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: GPS sensor

Post by kalle123 »

Wene001 wrote: Mine looks this way (under clear sky)
After WHAT time, please?

We are talking here about a 9€ GPS from China.
http://de.aliexpress.com/item/Ublox-7-s ... 0-bm2aeAra

Buy cheap from China, but be aware, quality control can be a problem, so don't buy one pro mini or one gps, Buy another component from another dealer in China, so you can compare .... Parcels get lost, quality is sometimes a problem. But really not often. Got a nano with unstable connection over USB. No problem. Nano went into the bin and I got my 1.50€ back.

Or buy expensive from a local dealer, where you have direct contact and can complain and get replacement fast.

With my first gps module I was convinced after one week of trying, that something was wrong with the eeprom. Ordered a second one (had to wait 3 weeks) and found, #1 was ok.

Just my 2 cents - KH
frater
Posts: 77
Joined: Sat Aug 30, 2014 11:04 pm
Country: -

Re: GPS sensor

Post by frater »

I totally agree with Kalle...
My first Arduino project (not that long ago) was a head tracker.
The first worked, but was wonky.
I build a 2nd one with more care and it was less wonky, but still not reliable.
Then I made a 3rd one that did exactly what I expected.

I already bought from several vendors and I probably used 2 bad ones the first time.
I could have done better if I now knew which vendor sold me the bad ones.

I've built 2 of these sensors and they work fine now..
I'm going to build a 3rd one this weekend.

I'm now using a mini-JST connector (4-pin 1mm) to connect the GPS-unit.
The GPS-units I bought already come with these, so I only need to plug these in.
Last edited by frater on Fri Apr 29, 2016 6:57 am, edited 1 time in total.
frater
Posts: 77
Joined: Sat Aug 30, 2014 11:04 pm
Country: -

Re: GPS sensor

Post by frater »

It seems that Spektrum is using i2c for their sensors.
I don't have Spektrum, so I wouldn't know.
Could these sensors be connected to the i2c-bus on the Arduino that is also used to connect the sensor boards?

What pins are they using and what is the layout?
User avatar
Wene001
Posts: 47
Joined: Wed Feb 01, 2012 11:05 pm
Country: -

Re: GPS sensor

Post by Wene001 »

kalle123 wrote: After WHAT time, please?
15m after powering up the gps in clear sky

How much dB do you get @ the gps signals?

@Kalle
Which one does perform better?
CRIUS CN-06 or GY-GPS6MV2

i`ve ordered a Ublox Neo7M to compare.
Looking forward to it
http://de.aliexpress.com/item/Mini-Ublo ... 62504.html
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

I expect that all the Neo7 are just fine.
Bad sensitivity is probably the result of a bad antenna.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Don't forget that when testing in your garden there are still things in the way, the small ublox7 only has a smaller antennae so won't be so sensitive, but when you are flying in the sky ABOVE all objects mine works just fine.
My advice is to try it in flight before giving up on it.

Post Reply

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