GPS sensor

Development & General Chat for the superb openxvario project.

Moderator: rainer

Post Reply
kabturek
Posts: 4
Joined: Sun Jun 28, 2015 7:40 am
Country: Poland
Contact:

GPS sensor

Post by kabturek »

Hi!

Thanks for a great project. I was finally able to have voltage telemetry on my most 'advanced' receiver (x8r). I have a Remzibi OSD with Ublox 6m working great. I was wondering would it be possible to hook up the gpx tx line to OpenXsensor and get the gps coordinates back on Taranis ? No GPS initialization would be needed rat first (maybe later when people would want to hook up seperate gps modules).

Would it be possible? could there be any hardware problems (program space, ram , IO etc) ? No flying after work so i'm looking for something to do ;)

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

Re: GPS sensor

Post by Carbo »

Similar thougjts here.

I am prepairing a F5J sailplane for maiden. In the past i have used the speed sensor to optimize the flight-modes and to compensate the vario. But i do not want any holes in this one. I ordered a ublox gps-module and to use it with the sketch from here: http://www.rcgroups.com/forums/showthread.php?t=2482328

Would it be possible, to integrate the gps in openxsensor? Furthermore it would be great to test, if there is any chance to compensate the vario with gps-speed. The routines allow 3-5 Hz for gps-data, that is imo enough for compensation purposes. Especially in accelerated flight, searching for thermals, it would be helpful. I know, that there are restrictions regarding the accuracy of gps speed measurement.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

I could try to support ulox gps to oXs.
I think it is possible.
Perhaps it has already be done; see this post on the forum:
viewtopic.php?f=86&t=5125&hilit=sport+gps

Still it could be that it would not be possible to activate this option when all the other options are already activated because the Arduino pro mini would (perhaps) not have enough memory.
This should not be a main issue because it is unusual to activate all options simultanously.

The main issue will be that I have no gps in order to test the code I could write.

It would also be possible to try to compensate the vario using the speed provided by the gps.
I don't know if someone already try it but I am afraid that the result will not be as good as with the current solutions (TEK probe or airspeed sensor) because:
- the gps can only measure the ground speed and , for compensation, it is airspeed that is required. This seems important when cycling on a windy day.
- I expect that in order to get an accurate ground speed, the GPS applies some filter logic. So, the reported ground speed reacts probably slower (with a delay) compare to the real ground speed. I think Carbo already noticed such a delay about the altitude in some tests made a year ago. If the reaction time of the vario is not the same as the one from GPS, it will generate false vario signal. Remember, Carbo, the isssues we had with the first code of oXS when I tried to use the rate of airspeed change to compensate the vario.
Anyway best is to check it.

I could start coding it but, as it is not a minor change, I am afraid that there will several bugs if I can't test it myself with a GPS device.
Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS sensor

Post by Carbo »

Hello Michel,

just ordered another one Ublox EEPROM NEO-6M GPS Module RC AeroQuad Controller Arduino MWC IMU APM2 OVP, it is on its way to belgium.

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

Re: GPS sensor

Post by mstrens »

Thanks Carbo,

I will start coding.

I propose first to get following data on SPORT
- latitude
- longitude,
- altitude,
- ground speed 2D,
- ground speed 3D
Later on, I could add other protocols (HUB and Multiplex) and vario compensation.

I will try to read GPS data as often as possible because it would perhaps be better for vario compensation; 10hz is the max.
I will transmit GPS data as long, lat, ... to Tx at a lower frequency (e.g. 1 hz) because bandwidth of SPORT is quite limitted.

This will probably require to change the default configuration of the GPS.
I do not plan to do it inside oXs.
Ublox have a free software that allows to configure the GPS. I think it is possible to use this tool with a common usb serial adapter and it has to be done only once.
So I expect I can use the hardware UART from arduino for reading the GPS keeping as much CPU time for other tasks.

Did you ordered the GPS in China or in Europe? It it just to know what could be the delivery date.

FYI, I think that Ublox has newer GPS models with higher performance (e.g. neo 7 and neo 8). Neo 7 is not much expensive (about 12 euro in China).
Anyway, I expect that it does not change anything for the software because all models can send the same types of messages.

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

Re: GPS sensor

Post by Carbo »

mstrens wrote:I will try to read GPS data as often as possible because it would perhaps be better for vario compensation; 10hz is the max.
I will transmit GPS data as long, lat, ... to Tx at a lower frequency (e.g. 1 hz) because bandwidth of SPORT is quite limitted.
Good plan!
mstrens wrote:FYI, I think that Ublox has newer GPS models with higher performance (e.g. neo 7 and neo 8). Neo 7 is not much expensive (about 12 euro in China)
After looking into the datasheets, i did not see any technical improvements, so i ordered the proven one.
mstrens wrote:Anyway, I expect that it does not change anything for the software because all models can send the same types of messages.
Ordered in GB, but the delivery will be between Sep. 30 and Okt. 10, so i suspect, it comes from the east.

After flying a year with compensated vario, i found the best way is to use the compensation in fast flightmodes for searching, but when you have found the thermal, switch to uncompensated vario (e.g. combined with the flightmode-switch). It helps, to avoid flying in "delphin-style" in larger altitudes. OpenTX does not allow to switch the variosource in flight, so please provide again the "ppm" compensation-adjustment/-switching.

Another point for an inexpensive speedsensor is, that some of my planes require a speed-warning to prevent them from selfdestroying:

https://youtu.be/N9-nFIN7kr4
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

If I compare the official product summay, I find small differences in performance:
Here I noticed only sensitivity, frequency , accuracy:
Neo8M : -164 db , 18 hz , 2 m
Neo7M : -162 db , 10 hz , 2.5 or 2 m
Neo6M : -161 db , 5 hz , 2.5 or 2 m

So I will try to read GPS data at 5hz only (this will also limit the CPU utilisation of Arduino)
Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS sensor

Post by Carbo »

On ebay they showed the same data for 6M and 7M, i have changed my order in a Neo7M, it will arrive between Fr. 25.09. and Th. 01.10. So we can try 5 Hz and 10 Hz update.
kabturek
Posts: 4
Joined: Sun Jun 28, 2015 7:40 am
Country: Poland
Contact:

Re: GPS sensor

Post by kabturek »

great stuff, i see it's shaping nicely on github! i'll have to do some testing soon :)
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

http://www.aliexpress.com/item/Ublox-7- ... eb201560_9


I ordered one these, wondered if it will work with this project with an arduino pro mini and my ms5611 or course.
Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS sensor

Post by Carbo »

nigelsheffield wrote:http://www.aliexpress.com/item/Ublox-7- ... eb201560_9


I ordered one these, wondered if it will work with this project with an arduino pro mini and my ms5611 or course.
I did not find any specifications for it, but the connections are the same:

Connection diagram:
Black to GND
Red to +5V
Blue to TX
Orange to RX

I would try it with Michels (mstrens) oXs GPS branch. As usual Michel wrote everything you have to know for installing it in "oXs_config_description.h".The Ublox Neo 7M is much bigger, so yours would be a good alternative, if it works.
oXs5611-4525.jpg
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

nigelsheffield wrote:http://www.aliexpress.com/item/Ublox-7- ... eb201560_9


I ordered one these, wondered if it will work with this project with an arduino pro mini and my ms5611 or course.
If it is a build with a Ublox 7 chip, it should work IF 4 signals are available:
- Vcc.
- Ground
- UART TX
- UART RX.
Please check if this the same as Mini-NAZE32

Take care that most arduino pro mini work with a Vcc = 5 volt (=16 mhz). Ublox GPS accepts max 3.3 (or 3.6 ?) volt. So It is important that this module has a voltage regulator to drop down the voltage from 5 Volt to 3.3 volt.

It is safe (mandatory?) to add some resistors to protect Tx and RX pin from Arduino 5 volt signal. I put some important comments about this in the file oXs_config_desciption.h

The new code is available on github in the branch openXsensor_GPS.
This code seems OK for the SPORT receivers. There could be some extension in the future based on the feed back of tester.
The code is available but not yet tested for the Hub protocol.
The code is not yet written for the Multiplex protocol.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Thanks, the module says 5v supply is OK but I will put a resistor of 10k as advised between GPS RX pin and arduino pin.
I got it because it is small enough to fit in a dlg , for purpose of making a lua script on taranis requiring distance based tasks type game.
I also ordered a gy-86 hoping it might also get integrated into openxsensor at some point, with some coding it could give angles sent to taranis for instruments like artificial horizon, and even a full instrument
Display so flying a glider that suddenly dissapear in clouds would be safer, a return to home arrow with the GPS help would mean could fly by instruments alone ...
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

http://forum.taulabs.org/viewtopic.php?f=17&t=797

Relevant posts to my above post. Scroll down the taulabs forum to see the lua script already done with artificial horizon and GPS info Inc arrow to home I think.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

About Gy-86, I am currently looking for adding support for this sensor to oXs.
I am waiting getting a device. It is ordered but not yet arrived.

It is very easy to get from this module raw data (acceleration, gyro,...) but this is not very useful.
The idea is to use a fusion algorithm (like in quadcopter) in order to calculate the attitude of the sensor compare to Earth.
I would then like to calculate the vertical acceleration (compare to Earth) and so to get a second source of data for a vertical speed.
A complementary filter would then allow to merge the vertical speed calculated from accelerometer/gyro with the verticcal speed from Baro sensor MS5611.
I hope getting a vario with a lower reaction time (reaction time with MS5611 is about 0.5-1 sec).
Later on, perhaps it would be possible to use also the acceleration + GPS speed in order to calculate an estimation of dTE (compensated vario) without using a probe.
Please note that I am not sure that this will be possible (limited CPU power, complex math, noisy sensor, ...)
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Sounds interesting, the GPS speed for compensated vario would be OK in a straight line but circling in wind not so good so switching between the 2 with ppm signal would be needed but this is already in place I think?
And faster reaction time would be great!
Maybe even use the GPS and acc data to determine if we are circling to switch between vario and compensated .....

Would it be worth Upping from the arduino pro mini to a stm32 board for extra performance if the 328 can't manage it all?
The stm32 development module is available at under £2 posted...though it might be a bit on the large side..
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

GPS speed is for sure much less good than airspeed because:
- it is not very accurate.
- so, it is impossible to use it to calculate rate of speed change (which is required for compensation)
- it varies depending on the direction of the plane regarding the direction of the wind.
Tests should demonstrate if it could be used or not. I have doubs too.

Circling will perhaps be an issue for normal vario. If it is not taken into account, I presume that the calculated attitude of the plane will become wrong.
Low pass filter on acceleration is used to identify the gravity vector (and so compensate the gyro drift). In continuous circling, low pass filter on acceleration will be impacted by centrifuge force.
So, I am afraid that I will have to disable the "fast" vario part (coming from accelerometer) when circling is detected.

I already have a cheap stm32 board but, as you said, it is about twice as big as a pro mini. A Teensy is better (for the size) but quite more expensive.
I think it is important to keep oXs as cheap as possible.
Furthermore, a lot of oXs code should be rewritten because oXs has many direct access to the AVR328P registers.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Yes keeping it cheap and small very important to me too.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

ok , i got my gps today(wow fast!!)
i cant get anything using openxsensor gps version downloaded from github.
however the gps works with taranis using flarisons code on 2nd post here http://www.rcgroups.com/forums/showthread.php?t=2482328 , just tested the gps only , no vario or anything else connected.
i connected to rx pin of arduino with tx pin of gps and pin 4 arduino to s.port of rx.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

In order to let oXs works with the GPS you must also connect the rx pin of GPS to arduino pin 6 (currently hardcoded).
In fact GPS can be configured.
When GPS starst with default GPS config, GPS sent messages in a MNEA format (widely used because readable with a normal text editor).
Still this format requires more CPU in order to extract the data in an IT format.
Ublox GPS (like your) can generate the data in another format which is easier/faster to decode.
Still it requires to send some commands to the GPS.
Some GPS modules have an external EEPROM that allow to save a special configuration using an external program (Ublox have such a free software available on his web site).
Still, the GPS I (and Carbo too) got had a defective EEPROM.
So I add some code in oXs to send some commands to the GPS when oXs startup.
This requires that oXs can send a signal on the Rx pin of GPS.

If your GPS module have a good EEPROM, it would be possible to avoid this connection but it requires that you use the free software from UBLOX in order to send and save in the EEPROM the required configuration.

I suggest that you try adding the connection to Rx of GPS.

Here the explanation I added to oXs.
Please read it carrefully.
* It is possible to connect a GPS module to Arduino. In this case, oXs will transmit to the Tx some data generated by the GPS module.
* Note: data are sent to the receiver only when the GPS has a fix.
* So, it can take several minutes before oXs start sending GPS data.
* If GPS lost his fix, oXs will stop sending GPS data until GPS got a new fix.
* When Frsky (SPORT or HUB) receiver is used, oXs will always send longitude, latitude, altitude, ground speed and course.
* This does not require any additional lines in the section "Data to transmit" (see 9 here above)
* When Multiplex receiver is used, the user has well to specify under the line "#define SETUP_MULTIPLEX_DATA_TO_SEND" which data are sent and the line number where the data have to appear on the display.
* Hardware points of attention.
* Supported GPS modules: oXs supports modules based on UBLOX GPS (easily available on ebay or aliexpress) like Neo6M, Neo7M and Neo8M.
* Most modules have a build in voltage regulator in order to drop the voltage down to 3.3 volt which is about the max allowed by the GPS
* They have 4 pins available that have to be connected to Arduino
* - GPS gound is connected to Arduino ground
* - GPS Vcc is normally connected to Arduino Raw pin (which is normally connected to Vcc from the receiver).
* Still take care that the voltage regulator on the GPS module is, most of the time, foreseen for a maximum voltage of 6 Volt while arduino Raw pin accept more.
* So, if you Raw pin get more that 6 volt, it is safe to add another voltage regulator to drop the GPS Vcc down.
* - GPS Tx pin is connected to Arduino Rx pin
* - GPS Rx pin is connected to a resistor (e.g. 10k) and the other pin of the resistor is connected to Arduino pin 6 (digital pin 6).
* This resistor is added (at least for a Arduino 5 volt) in order to protect the GPS pin.
* This is requested because Arduino will generate a signal with a high level equal to arduino Vcc (so normally 5 volt) while the GPS module should normally not accept more than 3.3 Volt.
* To be safier, you could even add a second resistor between GPS Rx pin and Ground (value= 22k) but, in my case, it worked without this second resistor.
* Note: it would be possible to use another pin than Arduino pin 6 but then it requires to change some parameters in file oXs_gps.cpp (see "Setup the GPS sensor").
* !! IMPORTANT NOTE :
* Arduino Rx pin is used for 2 purposed: getting the data from the GPS and uploading the program into the Arduino (normally only to be done once) using a USB to serial adapter.
* You must avoid having both GPS and USB connected at the same time because while uploading a program in Arduino, there will be conflicts between the signals sent by the 2 devices and programming will fail.
* There is another risk: if your USB to serial adapter generates 5 volts signal, it could damage the GPS module.
* So, when you connect the usb to serial adapter to the Arduino, you should disconnect at least the GPS TX pin from the Arduino Rx pin.
* Personnaly I use a connector between Arduino and GPS module and so I can disconnect totally the GPS module.
* Software points of attention
* UBLOX GPS module are normally delivered with a default configuration (generating automatically e.g some NMEA messages at 9600 bauds at a refresh rate of 1 hz).
* oXs assumes that, at start up, GPS is working at 9600 bauds. oXs sent then some commands in order to
* - disable all NMEA messages
* - activates some UBX messages
* - increase frequency of calculation (to 5 Hz instead of 1hz)
* - set up the baud rate to 38400 instead of 9600.
* Those parameters are not saved in the GPS (because some GPS modules does not allow it). So, oXs will send those commands at each power on.
* If you oXs does not send GPS data, please check that your GPS module has still the default configuration (most important is that it is configured to receive UBX command messages at 9600 bauds).
* An easy way to check the GPS configuration is to connect the GPS module to a 3.3 volt FTDI ( or USB to serial adapter) and to use a free software named "u-center".
* This software is available on the official web site of UBLOX. More info is easily available on the web.
* OXs allows to modify some parameters in the config.h file:
* - #define GPS_INSTALLED : uncomment this line if a GPS is connected and has to transmit his data
* - #define GPS_SPEED_IN_KMH : uncomment this line if GPS speed has to be sent in km/h instead of knot/h
* - #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)
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

thanks, i have already done that and still nothing, i wonder if the baud rate is a problem?
the tiny gps library says it assumes a gps rate of 4800 i think .
the code that flarison has uses the tiny gps library and works whether i connect the rx pin of gps or not..
will the opensensor gps only work if the gps is using 9600?

note i have only tested this on a x6r.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

Indeed, the default baudrate of Ublox GPS is 9600.
So oXs send automatically his configuration commands at startup using 9600bds.

The last command that oXs sent ask GPS to further switch at 38400. This was done because we expected to be able to get data from GPS at 10hz (with a Neo7).

So if your GPS uses 4800 bds at startup, it explains that oXs does not seem to work.

In order to solve this issue you can try asking oXs at start up at 4800 bds instead of 9600.
In file oXs_gps.cpp, you have a line with
#define MICROSECONDS_PER_BIT_9600 ((1000000ul / 9600) - MICROSECONDS_OVERHEAD_ADJUST)

Can you test using this line
#define MICROSECONDS_PER_BIT_9600 ((1000000ul / 4800) - MICROSECONDS_OVERHEAD_ADJUST)
If it works, I could make a more logical change later.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Still struggling , I realised after connecting a vario that the s.port was not working, so I looked at config and forced s.port, this got the vario working, unremarked enable GPS as this was disabled...
So with this I started again from scratch, with microseconds back to 9600
The line under it says 1000000ul / 38400ul
Shoudl the ul be there after 38400?
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

I am editing the CPP file in arduino, is this right? Do I need to save after each change ?
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Ok I'm stupid and sorry, I just tested again with default setting but all the comments as above and it worked , I think I just expected the comments to be set to work for GPS seeing as I downloaded the latest GPS file!
Anyway data seems to be updating pretty fast, though my GPS coordinates wander about a lot, and distance etc go up on its own , must be the GPS unit and the fact that I'm not outside in a big open field where it will hopefully work better.
No clock info displayed though.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

Adding ul after the number says to the compiler explicitely that the value has to be set in unsigned long. It can't be wrong.

Automatic detection of SPORT/ HUB occurs only at startup of oXs. If oXs is not powered by the Rx and if you power on oXs before powering on the Rx, oXs will read the SPORT signal at sartup and will not get any signal.
In this case, it considers that it is a Hub protocol (D Receiver).
So take care to power on oXS before or simultanously with Rx (it is for sure the case if oXs is powered via the SPORT bus)
Still, some users says that detection did not work in all cases. It seems it depends on the Arduino device. I already increase some oXs delay and it fixed the issue for some user but perhaps still not always.
Sorry but I can't reproduce it with my own devices.
That the reason why I add a parameter in the set up to force one protocol.

You can edit the cpp in arduino IDE.
Each time you compile the sketch, IDE save automatically all your changes. You can also save when you want using the menu.

If you still have issue with GPS, it would be possible to use some debug option. I would have to look at.
Ask if requested.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

nigelsheffield wrote:Ok I'm stupid and sorry, I just tested again with default setting but all the comments as above and it worked , I think I just expected the comments to be set to work for GPS seeing as I downloaded the latest GPS file!
Anyway data seems to be updating pretty fast, though my GPS coordinates wander about a lot, and distance etc go up on its own , must be the GPS unit and the fact that I'm not outside in a big open field where it will hopefully work better.
No clock info displayed though.
Fine that it works.

Please never thrust the config.h provided in github. current verssion was mainly done for Carbo in order to test some other developments.

I think that GPS data will become more stable after some time and when you are outside.

In current version, I have not foresee to transmit date and time (it saves CPU time and reduces number of data to transmit, ...).
I expected that Tx has his own clock.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

No need for clock data agreed.
When you say don't trust config.h should I still download it but check it thoroughly or just use my own? I downloaded this one because GPS was new and config was different to the one I had..
Great work
And thanks again.
I will build it properly soon and put it in my glider to see results.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS sensor

Post by mstrens »

Normally you must download the config.h file because it could be that it contains new (perhaps mandatory) parameters.
Still you have to check it thoroughly because I can't publish one file that meets all user requirements.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: GPS sensor

Post by nigelsheffield »

Ok thanks again.
Nigel.

Post Reply

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