Building your own GPS with an Arduino controller

You can talk about anything flight (simulation) related here

Moderators: russ, Ralph

Message
Author
monkeysuncle
Posts: 60
Joined: Tue Nov 20, 2018 9:34 pm

Re: Building your own GPS with an Arduino controller

#21 Post by monkeysuncle »

I love the idea of using Air Manager to run this. A direction I never considered. Thanks!

User avatar
PapaLima
Posts: 60
Joined: Fri Jan 05, 2018 10:49 am

Re: Building your own GPS with an Arduino controller

#22 Post by PapaLima »

Hi

I started building the GNS530 Simwarekit. The most complicated thing for passed successfully. It was even easier than I expect. I was afraid of the soldering session but with a sold station a friend own I did it.

Image

Image

Now here is my way to proceed after having built the GPS kit with the 3D printed parts :

- The Arduino 2560 will to the interface with the GPS buttons
- The GPS LCD HDMI screen will be connected to the PC display card output
- I will send the simulator GPS (probably even the RealityXP addon) to the GPS screen
- I will define an empty AirManager instrument to handle the GPS LUA code, Russ provided kindly here : http://www.simwarekits.com/downloads.html

I am right keeping this way to proceed ? Or do dream ? :D

Bye
Philippe

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Building your own GPS with an Arduino controller

#23 Post by Sling »

That should work just fine Philippe.

Let us know how you get on.

Tony

User avatar
PapaLima
Posts: 60
Joined: Fri Jan 05, 2018 10:49 am

Re: Building your own GPS with an Arduino controller

#24 Post by PapaLima »

Hi !

I finally finished this GPS using Air Manager as expected. The simwarekit was documented to be used with ArdSimX and XPlane around an Arduino MEGA 2560.

Since the Arduino support of Arduino inside AirManager, I thought it could be a good way to interface the GPS kit with the simulator. And it works !!

I have been greatly inspired by the LUA code provided by Russ (thanks to him) on the GPS GNS530 kit download page http://www.simwarekits.com/downloads.html to support the Xplane events).
I have updated it to support the FSX event instead. The assigned pin# where the same ;)

In AirManager Desktop, I have defined an empty gauge to support the LUA script which is linked to the Arduino. no graphical output needed. Only GPS key events to send to the sim :)

In the RealityXP manual we have a list of events we can use. Thus the code the the MENU key is like :

Code: Select all

function menu_click()
  print("menu_click")
  fsx_event("GPS_MENU_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D39", menu_click)
or for the double encoders support (two wheels and the push)

Code: Select all

-- 
-- DIAL CHAPTER
--
function dial_chapter(direction)
 print("dial_chapter:"..direction..)
  if direction == 1 then
    fsx_event("GPS_GROUP_KNOB_INC") 
  elseif direction== -1 then
    fsx_event("GPS_GROUP_KNOB_DEC")
	end
end
hw_dial_add( "ARDUINO_MEGA2560_"..channel.."_D29","ARDUINO_MEGA2560_"..channel.."_D28", dial_chapter)

--
-- DIAL PAGE
--
function dial_page(direction)
  print("dial_page"..direction..)
  if direction == 1 then
    fsx_event("GPS_PAGE_KNOB_INC")
	elseif direction== -1 then
    fsx_event("GPS_PAGE_KNOB_DEC")
	end 
end
hw_dial_add( "ARDUINO_MEGA2560_"..channel.."_D22","ARDUINO_MEGA2560_"..channel.."_D23", dial_page)


--
-- CLICK CURSOR
--
function click_cursor()
    fsx_event("GPS_CURSOR_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D27",   click_cursor)

I got some solders to be redone because the contacts failed. It is why you see the "print" method in the code snippet ; it was practical to confirm if the button is wired correctly or not to the Arduino...

Those solderings failed (not seen when plugged)
Image

Here the near view with the differents cards placed in the rack printed in 3D
Image

Rear view :
Image

Front view:
Image

I am not very happy with the stickers ... they do not glue correctly to the 3D buttons.. :roll:

The 5" screen is connected to the PC graphical adapter with the HDMI port. It is seen as another monitor in Windows.
From inside P3D, I undock the GPS view and move it to this 5" screen. It looks like that:
Image

Here I entered a Flight Plan around Tahiti islands. It helps me to tweak the code and performs adjustments in the AirManager script.

Image

Image

Image

I'll provide you the code in case someone is interested or just to see an example of how to handle GPS keys.


Bye
Philippe

User avatar
PapaLima
Posts: 60
Joined: Fri Jan 05, 2018 10:49 am

Re: Building your own GPS with an Arduino controller

#25 Post by PapaLima »

Hi

As promised, I am front of the AirManager running on the simulator, I can copy/paste below the code used to interface the GPS using an Arduino with AirManager Desktop.

Code: Select all


local channel = "A"

--
-- CDI
--
function cdi_click()
  --print("cdi_click")
  fsx_event("GPS_NEAREST_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D30", cdi_click)

--
-- OBS
--
function obs_click()
  --print("obs_click")
  fsx_event("GPS_OBS_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D31", obs_click)

--
-- MSG
--
function msg_click()
  --print("msg_click")
  fsx_event("GPS_MSG_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D26", msg_click)

--
-- FPL
--
function fpl_click()
  --print("fpl_click")
  fsx_event("GPS_FLIGHTPLAN_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D24", fpl_click)

--
-- VNAV
--
function vnav_click()
  --print("vnav_click")
  fsx_event("GPS_VNAV_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D25",vnav_click)

--
-- PROC
--
function proc_click()
  --print("proc_click")
  fsx_event("GPS_PROCEDURE_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D45", proc_click)

--
-- ENT
--
function ent_click()
  --print("ent_click")
  fsx_event("GPS_ENTER_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D44",ent_click)

-- 
-- CLR
--
function clr_click()
  --print("clr_click")
  fsx_event("GPS_CLEAR_BUTTON_DOWN")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D41",clr_click)

-- 
-- MENU
--
function menu_click()
  --print("menu_click")
  fsx_event("GPS_MENU_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D39", menu_click)

--
-- DIRECT-TO key
--
function direct_click()
  --print("direct_click")
  fsx_event("GPS_DIRECTTO_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_A_D38", direct_click)

--
-- ZOOM-IN key
--
function zoom_in_click()
  --print("zoom_in_click")
  fsx_event("GPS_ZOOMIN_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D33", zoom_in_click)

--
-- ZOOM-OUT key
--
function zoom_out_click()
  --print("zoom_out_click")
  fsx_event("GPS_ZOOMOUT_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D35", zoom_out_click)

--
-- COM SWAP key
--
function com_ff_click()
  --print("com_ff_click")
  fsx_event("COM_STBY_RADIO_SWAP")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D34", com_ff_click)

--
-- NAV SWAP key
--
function nav_ff_click()
  --print("nav_ff_click")
  fsx_event("NAV1_RADIO_SWAP")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D32",  nav_ff_click)

--
-- DIAL coarse key
--
function dial_coarse(direction)
  print("dial_coarse:"..tostring(direction))
  if direction == 1 then
    fsx_event("GPS_BUTTON2")
elseif direction== -1 then
    fsx_event("GPS_BUTTON3")
  end
end
hw_dial_add( "ARDUINO_MEGA2560_"..channel.."_D36","ARDUINO_MEGA2560_"..channel.."_D37", dial_coarse)

--
-- DIAL fine key
--
function dial_fine(direction)
  print("dial_fine"..tostring(direction))
  if direction == 1 then
    fsx_event("GPS_BUTTON5")
  elseif direction== -1 then
    fsx_event("GPS_BUTTON4")
  end
end
hw_dial_add( "ARDUINO_MEGA2560_"..channel.."_D42","ARDUINO_MEGA2560_"..channel.."_D43", dial_fine)


-- 
-- CLICK C/V key
--
function click_cv()
  --print("click_cv")
  fsx_event("GPS_BUTTON1")  
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D40",  click_cv)

-- 
-- DIAL CHAPTER key
--
function dial_chapter(direction)
 --print("dial_chapter:"..tostring(direction))
  if direction == 1 then
    fsx_event("GPS_GROUP_KNOB_INC") 
  elseif direction== -1 then
    fsx_event("GPS_GROUP_KNOB_DEC")
	end
end
hw_dial_add( "ARDUINO_MEGA2560_"..channel.."_D28","ARDUINO_MEGA2560_"..channel.."_D29", dial_chapter)

--
-- DIAL PAGE key
--
function dial_page(direction)
  -- print("dial_page:"..tostring(direction))
  if direction == 1 then
    fsx_event("GPS_PAGE_KNOB_DEC")
	elseif direction== -1 then
    fsx_event("GPS_PAGE_KNOB_INC")
  end 
end
hw_dial_add( "ARDUINO_MEGA2560_"..channel.."_D22","ARDUINO_MEGA2560_"..channel.."_D23", dial_page)


--
-- CLICK CURSOR key
--
function click_cursor()
  -- print("click_cursor")
  fsx_event("GPS_CURSOR_BUTTON")
end
hw_button_add( "ARDUINO_MEGA2560_"..channel.."_D27", click_cursor )

--
-- COM1 VOL key
--
function com_1_vol(value)
  --print("com_1_vol:"..tostring(value))
  fsx_event("GPS_POWER_BUTTON",value)
end
hw_adc_input_add("ARDUINO_MEGA2560_"..channel.."_A0", com_1_vol)

--
-- NAV1 VOL key
--
function nav_1_vol(value)
  --print("nav_1_vol:"..tostring(value))
  fsx_event("GPS_POWER_BUTTON",value)
end
hw_adc_input_add("ARDUINO_MEGA2560_"..channel.."_A1", nav_1_vol)

--
-- PWR SET key
--
function pwr_set(flag)
  --print("pwr_set:"..tostring(flag))
  fsx_event("GPS_POWER_BUTTON",flag)
 end
hw_switch_add("ARDUINO_MEGA2560_"..channel.."_D46", pwr_set)
     
Hope it will help someone
Bye


PS: update May 22, 2019 : code updated to handle CDI key support (now switch from GPS to VLOC) and CLR key (reset to default display map)

Post Reply