GPS & Arduino Pro mini

Development & General Chat for the superb openxvario project.

Moderator: rainer

kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

GPS & Arduino Pro mini

Post by kenelder »

Hello and thanks for any help! I am trying to get a Ublox Neo-6m talking to an Arduino Pro Mini connected to a FrSky Smart Port. I have done a lot of reading on this forum as well as any other I could learn from. First, I have tested the Neo-6 with the U-center software. It is functioning great and boots at 9600 baud. It accepts UBX-CFG messages and I can reconfigure the baud rate as well as the input/output protocol. When power is removed then reconnected it again boots at 9600 as expected.

I am using the latest OpenXVario software (all files have 8-10-2018 date created) in the Arduino IDE ver 1.8.5. I have read through the config.basic.h and config.advanced.h and in the basic turned on the GPS (=YES). The sketch compiles and uploads fine, verbose output shows no issues. I have tested my Arduino Pro Mini and IDE by uploading the Blink sketch as well as modifying the Blink sketch to do a double blink. It works as expected.

Connections from the GPS Neo-6 to the Pro Mini- Vcc(gps) to Vcc(Pro on long side), GND (gps) to GND (Pro on long side), TX(gps) to RX1(Pro long side) and Tx(gps) to 10k resistor to pin 6 Pro. I verified config.advanced.h is set to use pin 6 for this.

Connection from Pro Mini to Sport- Vcc(Pro) to + (smart port), Gnd (Pro) to - (smart port) and finally Pin 4 (Pro) to signal (Sport). I verified in the sketch pin 4 is set for this.

On powering the receiver, I get red lights on the Pro Mini and the GPS (Indicating power on) and after a minute or so a flashing green LED on the GPS. When on U-center, the green only flashes after the GPS gets a fix, so I believe gps is getting a fix just fine.

"Discover Sensors" on my Taranis X9D (Opentx 2.2.1) does not discover the GPS. The usual FrSky RSSI and RxBT are working fine. At one time I had a FrSky GPS on this model and it was discovered and working. After not seeing an update I deleted the GPS sensors that were in the Taranis and set about re-discovering them. Still no GPS.

As near as I can tell, the GPS is working fine, the sketch is uploading to the Pro mini, but there's something missing somewhere since it never gets to the smart port.

I have attached my config.basic.h and config.advanced.h in case anyone can help by reviewing them. Also included gps.h and gps.cpp. Maybe I left something out?

Any suggestions very much appreciated!

Ken
Attachments
oXs_gps.cpp
(15.07 KiB) Downloaded 319 times
oXs_config_basic.h
(11.18 KiB) Downloaded 317 times
oXs_config_advanced.h
(19.13 KiB) Downloaded 320 times

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

Re: GPS & Arduino Pro mini

Post by Carbo »

Everything seems to be OK. Eventually you did not give enough time to establish a sufficient sat fix for oXs. To be sure, place the GPS outside for 10min with free view to the sky and then start sensor discovery. If this fails also, try with another GPS unit.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS & Arduino Pro mini

Post by mstrens »

As Carbo said, your config seems ok.
Please note that there can be some delay between gps led starts blinking and oXs starts sending data. I think there are several of fixes.
So, I suggest that you wait a little more.
If it still does not work, let me know and we will try some debug options.
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

Thank you, will give it a try and report back!
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

After 15 min outside, green light on GPS blinking, still no sensor discovery. Tried a second Arduino pro mini, same result. I have read that if you "upload sketch" instead of "upload using programmer" that the Arduino bootloader first checks for serial data and if anything is sending serial data it stays in that mode. I am using a FT232RL to upload, when I tried upload using programmer, with Usbasp as the programmer, it would not work, so I used "upload sketch". Perhaps that is the problem?

I am considering connecting the FT232 to the Sport side of the Arduino and seeing if I get any serial information.

Thoughts?

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

Re: GPS & Arduino Pro mini

Post by mstrens »

I use a ftdi too to upload sketch.
I use "upload" with usbasp.
Please note that you have to disconect the gps (at least the signal on arduino Rx) when you upload in order to avoid conflict on the arduino Rx pin between the signal from ftdi and the signal from gps.
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

Thank you for your help! If I choose "upload using programmer" here is the messages I get:

Sketch uses 8796 bytes (28%) of program storage space. Maximum is 30720 bytes.
Global variables use 979 bytes (47%) of dynamic memory, leaving 1069 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cusbasp -Pusb -Uflash:w:C:\Users\ken\AppData\Local\Temp\arduino_build_166996/openXsensor-gps1.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : usb
Using Programmer : usbasp
An error occurred while uploading the sketch
avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'

avrdude done. Thank you.

If I choose "upload" then it uploads just fine. Here is the messages I get:

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : COM9
Using Programmer : arduino
Overriding Baud Rate : 57600
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino
Description : Arduino
Hardware Version: 2
Firmware Version: 1.16
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\ken\AppData\Local\Temp\arduino_build_166996/openXsensor-gps1.ino.hex"
avrdude: writing flash (8796 bytes):

Writing | ################################################## | 100% 4.42s

avrdude: 8796 bytes of flash written
avrdude: verifying flash memory against C:\Users\ken\AppData\Local\Temp\arduino_build_166996/openXsensor-gps1.ino.hex:
avrdude: load data flash data from input file C:\Users\ken\AppData\Local\Temp\arduino_build_166996/openXsensor-gps1.ino.hex:
avrdude: input file C:\Users\ken\AppData\Local\Temp\arduino_build_166996/openXsensor-gps1.ino.hex contains 8796 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 3.72s

avrdude: verifying ...
avrdude: 8796 bytes of flash verified

avrdude done. Thank you.

I completely disconnect the GPS when programming.

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

Re: GPS & Arduino Pro mini

Post by mstrens »

So, with "upload" , arduino is correctly uploaded.
It is the same as what I get.

If oXs still does not communicate with openTx, we have to start some debugging.
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

I have read that Pro Mini has issues with two software serial ports. Some are doing GPS sensors using the hardware serial ports for the GPS and the software port for the Sport connection.

Going to have to do some debugging. Suggestions? I can connect the Pro Mini to the GPS then to the FT232 and try to monitor the serial port?
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS & Arduino Pro mini

Post by mstrens »

after oXs program has been uploaded, you can connect arduino to ftdi and to gps simultanously.
In order to debug you have to:
- uncomment the line #define DEBUG in oXs_config_advanced.h
- check that line #define DEBUGSENDDATA is uncommented in oXs_gps.cpp
- upload the program in arduino (without gps)
- reconnect gps
- connect arduino to ftdi and pc
- open pc terminal session on pc (with ctrl +shift +M I think)
- configure the baudrate on pc terminal ( bottom right of the terminal session) to 38400 (I think)
- restart oXs
- you should get a copy on pc of the messages sent by gps to oXs

this would allow to see if the communication gps-oXs is ok or not
If, yes, then we will have to debug communication between arduino and frsky rx
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

mstrens, thanks for your help! There is no line "#define DEBUGSENDDATA is uncommented in oXs_gps.cpp" in my oXs_gps.cpp. There is a line "#define DEBUG_FORWARD_GPS_MSG_TO_PC" is that the correct line to uncomment?
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS & Arduino Pro mini

Post by mstrens »

Sorry, the version on my pc is not the same as on github.
I will update the version on github to morrow
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

Hello mstrens, tested and there was no characters at 38400, none at 9600. I am now suspecting these pro mini boards are clones- I notice that they are not clearly marked on the back exactly what they are. They seem to run on 3.3V just fine (have my FTDI set at 3.3V) but it is quite possible that these simply have some differences from genuine pro mini boards. I believe I have a nano in my parts bin, I will see if I can get that one programmed and working.

Thank you again for your help!
Ken
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

This is interesting: I carefully checked my work, re uploaded the sketch with debug per your instructions, connected gps, plugged in FTDI restarted oXs and got nothing in the terminal session. I pulled the connectors on the FTDI so that I had VCC, GND, and Rx only. Then restarted and now I get a repeating "openXsens⸮" continuously. Also a blinking led on the Pro Mini and a blinking red on the FTDI, looks like about 1 time per second. However, the GPS does not get a fix, the green led never starts blinking even after waiting a really long time. I must be missing something, any comments appreciated.

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

Re: GPS & Arduino Pro mini

Post by Carbo »

Did you verify, that power is indeed connected to Arduino VCC? Some Arduinos have a huge regulator dropout. Feeding them through VIN/RAW with 5V results in a low VCC voltage.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS & Arduino Pro mini

Post by mstrens »

As far I know, when Arduino is connected to ftdi, it is powered by ftdi directly (bypassing the regulator).
So if ftdi is 3.3 v, arduino vcc is 3.3 v
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS & Arduino Pro mini

Post by mstrens »

I just better checked and I saw that I made a mistake in my previous post.
You have to check that you have #define DEBUGPARSEGPS uncommented (instead of checking #define DEBUGSENDDATA).
Normally it is already the case with the version on github.

Please note that at startup you should get some messages on pc terminal (like "End of GPS setup"), then I think there would be no messages as long as there is no gps fix.
When gps get a fix, oXs should normally send copy of gps messages to pc
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

Ok, with DEBUGPARSEGPS uncommented I get:
openXsensor starting..
milli=0
freeRam=839
Enter setup voltage
Reference voltage:1100
Voltage:1 , pin=6 , offset=0 , mVoltPerStep=18.17
Voltage:2 , pin=8 , offset=0 , mVoltPerStep=2.01
Voltage:3 , pin=8 , offset=0 , mVoltPerStep=3.44
Voltage:4 , pin=8 , offset=0 , mVoltPerStep=3.98
Voltage:5 , pin=8 , offset=0 , mVoltPerStep=1.08
Voltage:6 , pin=8 , offset=0 , mVoltPerStep=3.88
End of GPS setup
FRSky Output Module: TX Pin=4
Sport protocol= 1
End of general set up

and then nothing. Waited 20 min, but GPS never got a fix. When GPS is connected to U-center through FTDI it gets a fix within a minute. FTDI supplies power when connected to U-center. When connected for debug the FTDI supplies power to the Arduino and the GPS with the GPS GND connected to the Arduino GND and the GPS Vcc connected to the Arduino RAW. I am not understanding why it cannot get a fix when connected to the Arduino.

Any other debugging I can do?
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS & Arduino Pro mini

Post by mstrens »

When arduino is powered by ftdi, Vcc from ftdi is directly connected to arduino Vcc and there is no voltage on arduino Raw (arduino raw is connected to the input of a voltage regulator on the arduino board)

After having uploaded the program via ftdi, I normally use a battery as power source. In fact I connect oXs to Frsky rx (via Sport) and arduino is powered by the frsky Rx.
When you want to debug (with ftdi) while oXs is powered supplied by frsky Rx ( red cable from sport being connected to arduino raw) you have to take care that ftdi Vcc is not connected to arduino Vcc. You also have to take care that ftdi support 5 volt because arduino will provide 5 volt signal on his Tx pin. This could be dangerous for your ftdi if it is set on 3.3 Volt.
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

Thank you mstrens, I was careful not to mix voltages and connections. I did find your comment about no power in the Raw pin if powered from the FTDI to be different for mine- had the GPS connected to the Raw pin on one test and it still powered up fine. I also tried an Arduino Nano connected to the GPS and receiver, same results: GPS gets a fix, no communication to the X8R. I ordered a different GPS module, think maybe Carbo is correct about needing to try a different GPS. I still have trouble understanding why a GPS that works fine on U-center through the FTDI will not work when connected to an Arduino through the X8r power.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS & Arduino Pro mini

Post by mstrens »

If the gps can be reconfigure in U-center ( in order to select ubox messages at 38400 instead of nema messages at 9600), then it should work with oXs.

I already got a bad gps but even if it was sell as a ublox, it was a fake one and it could not be reconfigure with U-center.

Please note that It is important that the gps is connected to a power supply (it can be the same as arduino power supply) before or simultanously the arduino get power supply because arduino send command to reconfigure the gps only once at start up (or after pressing reset button).

While in debug mode, you can try to uncomment the line "#define DEBUG_FORWARD_GPS_MSG_TO_PC".
In this case, oXs should send to pc terminal all characters it get from gps even when there is no fix. Still it replace "0xB5" by a new line because it identifies the begin of a new message and it is then easier to read the messages on pc terminal.
You can then see if gps has been reconfigure correctly or not (in order to get ublox messages instead of nema messages).
gps should send such messages even there is no fix yet.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: GPS & Arduino Pro mini

Post by mstrens »

mstrens wrote: Sat Sep 22, 2018 7:23 am If the gps can be reconfigure in U-center ( in order to select ubx messages at 38400 instead of nema messages at 9600), then it should work with oXs.

I already got a bad gps but even if it was sell as a ublox, it was a fake one and it could not be reconfigure with U-center.

Please note that It is important that the gps is connected to a power supply (it can be the same as arduino power supply) before or simultanously the arduino get power supply because arduino send command to reconfigure the gps only once at start up (or after pressing reset button).

While in debug mode, you can try to uncomment the line "#define DEBUG_FORWARD_GPS_MSG_TO_PC".
In this case, oXs should send to pc terminal all characters it get from gps even when there is no fix. Still it replace "0xB5" by a new line because it identifies the begin of a new message and it is then easier to read the messages on pc terminal.
You can then see if gps has been reconfigure correctly or not (in order to get ubx messages instead of nema messages).
gps should send such messages even there is no fix yet.
Carbo
Posts: 467
Joined: Fri Aug 02, 2013 6:55 pm
Country: Germany
Location: Freinsheim RP

Re: GPS & Arduino Pro mini

Post by Carbo »

Our German forum has a very active oXs community and therefore a good overview about troubleshoting oXs. Mstrens GPS routines are working perfect, not a single glitch.

If there were issues, they were hardware or user related. Is Arduino indeed connected to SPort on antenna side? Some, including me, tried with SBus port in the front row, it never worked ;) If + SPort is about 5V and connected to Arduino RAW, it makes sense to measure Arduino VCC, to be sure, there is a sufficient voltage level left for Arduino.
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

Carbo and mstrens, thank you for your help!! I agree it has to be a hardware or user issue, probably me. mstrens the gps can be reconfigured in u-center and it is connected to the receiver + and - at the Sport. The Arduino and gps get power at the same time when the receiver is powered on. I tried pressing the reset button after power up, but it did not make any difference. Carbo the Arduino & gps are plugged into the antenna side Sport but I have not yet tested the voltage at the Arduino Vcc.

I should have a new gps to try tomorrow later in the day, so we will see what happens.
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

Question: I note that in config.basic.h where it says "Arduino measures voltage" if I set that to NO I get a compile error. If I leave YES then it compiles fine. Since I am not using the Arduino to measure voltage, should I be setting that to NO and if so how do I fix the error: "
oXs_out_frsky.cpp:572: error:

#error When VFAS_SOURCE is VOLT_1, VOLT_2,... VOLT_6 then PIN_VOLTAGE must be defined too."

You thoughts?
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: GPS & Arduino Pro mini

Post by kalle123 »

With latest version of oXs I can set "Arduino measures voltage" to NO here and only activate GPS. Don't see an error when compiling.

Please post your oXs_config_basic.h and oXs_config_advanced.h

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

Re: GPS & Arduino Pro mini

Post by mstrens »

I think it is because oXs detects a conflict in the config.
Message says that when VFAS_SOURCE is defined, then the config must also ask for a voltage measurement (because VAFA is just a voltage measurement).
In order to avoid the error when "Arduino measures voltage" is set to NO, you have to set #define VFAS_SOURCE as comment.

This can't explain the issues you have with the GPS.
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

I am testing a new gps and Arduino this morning, will advise. And thank you all for the help!
kenelder
Posts: 14
Joined: Tue Sep 18, 2018 9:07 pm
Country: -

Re: GPS & Arduino Pro mini

Post by kenelder »

Solved!!!! First of all, thank you all for your patience and help!

The one thing I never tested was the brand new connector and wires to connect to the Sport. You would think a brand new wire that was delivering power and ground from the smart port would also be delivering signal. But no, it is apparently broken inside the insulation or a bad crimp. Switched to an old used 3 wire and connector and now the gps works great!

When I first tried the new gps and arduino, same result- it wasn't working. Then I thought, maybe I should test that new wire because it was obviously not getting communication. Simple continuity test and the comm wire was open.

Just my luck! But now it is working great, connects even inside the house almost immediately. Thank you so much for your help!
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: GPS & Arduino Pro mini

Post by kalle123 »

Good to hear it is solved .....

Post Reply

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