Jump to content
The simFlight Network Forums

FSUIPC To Excel?


RJP

Recommended Posts

Hi All,

A slightly random question......... Is it possible for FSUIPC to pass a location to Excel? If any other variables (particularly heading & aircraft type and / or registration) could be passed also it would be ideal! It would be ideal if I could get the lat / lon into cells in Excel.

If it's possible where might I find some pointers on how to start with doing so? Once I've got information into Excel I can handle it from there but would be lost with the bit before that (hence not knowing if it's even possible).

Best regards & many thanks

Richard

 

Link to comment
Share on other sites

1 hour ago, RJP said:

Is it possible for FSUIPC to pass a location to Excel?

Er, no. FSUIPC is an interface into FS for applications. I don't think Excel has an FSUIPC interface connection built it, has it? You'd need a program to link it.

1 hour ago, RJP said:

It would be ideal if I could get the lat / lon into cells in Excel.

Ah, you mean write a file which Excel could read? That's different. 

Certainly it is easy enough to have a small plug-in which sends data from FS to a file, perhaps in "CSV" format ("comma separated variables") which I know Excel can read into a table. There's an example of such a plug-in called "Record to csv.lua" in the Lua examples ZIP in your FSUIPC documents folder!

Pete

 

Link to comment
Share on other sites

59 minutes ago, Pete Dowson said:

Ah, you mean write a file which Excel could read? That's different.

Hi Pete,

Many thanks again for another speedy reply!

Almost, I meant put the lat / lon (& any other info which might be available) into specific cells in an existing Excel file. I.e. that a single specific cell gets updated at intervals with the current lat (and a single specific cell for each of the other bits of data) (not that it records a series of locations a-la a flight recorder).

Ah, by coincidence I've just been reading a few bits about Lua, I'll happily admit that most of it went straight over my head haha I'll look in more depth when I get a chance though, thanks for the info!

Another option I thought of is if there is a way of passing a location to google maps in a browser? I've previously created an Excel tool for image cataloguing which would extract lat / lon from an images exif.  If they weren't present then the user was given an option to open google maps, centre the map over the image location then return to the Excel file and the location would be taken from the browser address.  Certainly nothing startling but it might be another way to get a lat / lon into what I'm trying to do.

As someone who can blunder their way around VBA only, but with (usually lol) a bit of success do you think trying to do something with Lua to put the location straight into an existing Excel file or trying to put the location into a browser / google maps and read it from there would be the easier option? (For the second one if the location is in the browser address the rest is no problem).

Best regards & many thanks

Richard

 

Link to comment
Share on other sites

1 hour ago, RJP said:

I meant put the lat / lon (& any other info which might be available) into specific cells in an existing Excel file. I.e. that a single specific cell gets updated at intervals with the current lat

I don't know any way of doing that. Does Excel have such a programmable interface?

1 hour ago, RJP said:

Ah, by coincidence I've just been reading a few bits about Lua, I'll happily admit that most of it went straight over my head haha I'll look in more depth when I get a chance though, thanks for the info!

You can try the Lua plug-in I mentioned. The file it produces can be immediately displayed in Excel. But I've no idea how you'd ever get that display updating automatically.

1 hour ago, RJP said:

if there is a way of passing a location to google maps in a browser?

I think there are programs which link to FS and display the location dynamically on Google Earth. You'd need to do a search.

1 hour ago, RJP said:

As someone who can blunder their way around VBA only, but with (usually lol) a bit of success do you think trying to do something with Lua to put the location straight into an existing Excel file or trying to put the location into a browser / google maps and read it from there would be the easier option?

Sorry, I know nothing of VBA so I really cannot comment on this.

Pete

 

Link to comment
Share on other sites

In 2012 a forum member called gr8guitar claimed to have the FSUIPC programming interface working in VBA inside Excel. I assume he ported the VB6 interface.

Here's a link to the post were he says he got it to work...

http://forum.simflight.com/topic/12740-fsuipc-vb6-users-need-help/?do=findComment&comment=441067

You may be able to contact him through the forum if you're interested in going that route. (Click on his name and send him a message).

Paul

Link to comment
Share on other sites

Hi Pete,

Thanks for the info! I couldn't get anywhere with the thought of using google maps in between FSX & Excel, however, see below.

Hi Paul,

Thanks for the info / link.

The visual basic modules do indeed seem to work in VBA. Well with the code from one of the accompanying text files I was able to get the aircraft title into Excel.  A simple bit of info yes but hopefully it means the other bits of info I need won't be an issue (lat / lon primarily, perhaps also altitude & speed). I had a quick try last night with altitude and couldn't get it to work but I believe it's just the format of how I'm calling the read function so as it's in VBA now I'm happy that I'll find / blunder my way to a solution.

Best regards

Richard

 

 

Link to comment
Share on other sites

Using a list of airfields (filtered in this example to just the Bahamas) I created a scatter graph of locations (orange: those I've visited, blue: not visited) and also the aircraft position.

It's working well, I've put the code which gets the aircraft position into a timer loop so it updates every second, sure enough I see the green circle move around the chart.

 

 

FS2.JPG

Link to comment
Share on other sites

Thanks Paul.

Yep, very true.... After a few issues (probably caused by me), I'm getting decent results manipulating the autopilot too.

I think once I've finished the initial project (Excel based map with ability to randomise flights (within distance & runway limitations) ) then I might look at something to provide guidance to airfields without nav-aids (to guide towards an extended centre-line). 

Best regards

Richard

Link to comment
Share on other sites

  • 1 year later...

Hi, Richard.

Congratulations for the work, the purpose I'm a beginner in programming I do not understand but I'm studying.

What you posted is exactly what I need today because I am trying to develop an application for MSFS by excel / vba already I got 70% of what I want but seeing the FSUIPC_SDK documentation I tried a few lines but it did not work.

Could you share your code with us or via mp or email?

I appreciate your attention in advance.

Rudolf

Link to comment
Share on other sites

  • 10 months later...

Okay, back at it again. I know Excel (VBA) can read FSUIPC offsets:

Dim ElevPosInd As Integer
If FSUIPC_Read(&HBB4, 2, VarPtr(ElevPosInd), dwResult) Then
If FSUIPC_Process(dwResult) Then
Range("a18").Value = Format(ElevPosInd, "000")
End If
End If

But can it read Lvar's (L:SomeValue, number)? If so, what is the format? Thanks.

 

Link to comment
Share on other sites

17 hours ago, gr8guitar said:

But can it read Lvar's (L:SomeValue, number)? 

Maybe. FSUIPC has a facility to read and write LVars. You need to be able to write a string (The name of the Lvar) to an offset. Can the Excel code do that?

If you search for Lvar or L:var in the FSUIPC offsets list you'll find the offsets you need and how to use them. 

I'm away at the moment, back on Sunday. If you can't get it to work I'll be able to help more next week. I don't have access to the documentation right now.

Paul

Link to comment
Share on other sites

Hello. Thanks for your reply. I do know that FSUIPC can indeed write and read Lvars and from FSUIPC offsets. But as far as I know, the FSUIPC offsets are known. So I guess in other words, are there unused/spare FSUIPC offsets that can be written and read? And if there are FSUIPC unused/spare offsets available, what is/are their address(es) and what would their format be (i.e.: single integer, double integer, etc.)? I wanted to use Excel so I could chart certain (LVar) data. Currently I wrote an XML gauge to chart the data but I prefer Excel.

Link to comment
Share on other sites

I'm not sure what you're asking with regard to the spare offsets. Reading and writing lvars with FSUIPC is done using two specific offsets. One offset is where you write the name of the lvar you want. The other offset is where you read the result (value).

No spare offsets are needed.

I can't tell you the actual offset numbers until next week, but they are clearly listed in the offset status list. Search for the word Lvar or L:var. Have you looked?

Paul

Link to comment
Share on other sites

Hello. Thank you for your reply. I do not need an existing list of FSUIPC's default offsets as they apply to MSFS. I was wondering if FSUIPC had some spare offsets that one could use in a case just as this. And if so, what their data type would be. Again, thanks for your time and information.

Link to comment
Share on other sites

Ah yes. It's been awhile since I last was flight simming. I had forgotten my own work. And I still don't have access to my books and other documents, or my old hardware since our house was repaired from a flood a year ago. I do recall that range now. So for anyone else that needs a simple example:

1) fsuipc.ini:

[Auto]
1=Lua ShowLvar

[LuaFiles]
1=ShowLvar

[Keys]
0=36,8,L1:R,0

[Buttons]
1=P10,10,Cx610066C0,x00090001
2=P10,11,Cx510066C0,x00090001.

This counts up/down 1 at a time up to 9 . PS, can use keys too.

BTW: I think the actual datatype for 66Cx is SB, not UD.

 

2) ShowLvar.lua (taken from some other example):

function Board(offset, val)
val = ipc.readUD(0x66C0)         
    ipc.writeLvar("L:BOARD", val)
end

event.offset(0x66C0,"UD","Board")

3) ShowLvar.xml 

<Element>
      <Visible>(L:BOARD, number) 8 &lt;= </Visible>
      <Position X="25" Y="13"/>
      <Text X="80" Y="15" Length="8" Fixed="Yes" Font="arial" Adjust="Left" VerticalAdjust="Top" Color="#EAEAEA"   Bright="Yes">
    <String>%((L:BOARD, number))%!07d!</String>
      </Text>
   </Element>    

 

4) Running FS2004 (yes, I still primarily use FS2004), under the Modules tab: FSUIPC:
I have selected a rotary pushbutton , so under the tab of Buttons + Switches, I select the button I want and then click on the box next to: Select for FS control, then select Offset DWord Cyclic Increase (and another button for Offset DWord Cyclic Decrease), say 66C0. Then under Parameter: 1/9. I used the above combination to be able to select different gauges (Nav/Com) using the same rotary switches.

My thought process must have been to find out if there was another available range. I have not tried writing to 66Cx, but that is now the attempt. I suppose for the ***.lua, it would be...?

function Board(offset, val)
val = ipc.readLvar("L:Board",val)        
    ipc.writeUD(0x66C0)
end

not sure what to do with the below statement though...

event.offset(0x66C0,"UD","Board")

Suggestion? 

BTW: I think the datatype for 66Cx is SB, not UD.

 

Link to comment
Share on other sites

On 10/14/2018 at 4:33 AM, gr8guitar said:

BTW: I think the datatype for 66Cx is SB, not UD.

The user offsets 66C0-66FF are just bytes . You can use them for any format data you wish.! UD will use 4 bytes (for example 66C0-66C3) to store a 32-bit integer. You could use all 64 bytes to store a string, or an array of 8 64-bit dpouble floating point numbers, etc etc. It is up to you!

Incidentally, you appear to be getting the wrong idea here:

ival = ipc.readLvar("L:Board",val)        
    ipc.writeUD(0x66C0)


I think you must mean 

val = ipc.readLvar("L:Board")        
    ipc.writeUD(0x66C0, val)


Please do refer to the Lua library document for the correct syntax.

Pete

 

Link to comment
Share on other sites

Hello. I do not think I wrote:  ival = ipc.readLvar("L:Board",val) .  What is ival? And thanks for the correction of the syntax. I was going by what it took to read a Lvar, but I did not understand how to write the Lvar to an offset. In my frustration/impatience, I ended up making an X vs Y graph in the gauge itself instead of using Excel. But now that I have the syntax, I'll use it next time. Graphing in XML is a bit awkward and verbose. Thanks for the information. BTW, in case someone else has solved the Flight Director (FD) problem, that is the end goal here. It has frustrated me for years that the default FD does not always match the CDI and GS when flying an ILS approach in manual mode. Real Boeing FD's do. I have finally decided to tackle that issue and PID is a way to get there - sort of. MS FS2004 (FS9), and I think FSX (don't spend too much time with it) default Autopilot seems to follow a typical PID with the exception of: Max. Bank Angle, Max. Bank Acceleration, Max. Bank Velocity. The Max. Bank Angle, I get and got it working, I currently don't understand how Max. Acceleration and Max. Velocity fit in Mathematically. As a private pilot though, I was taught, for example, when banking at 30°, the lead-in to level out would start about 15° (half the bank angle) from the desired heading.  What I observed from the FS is a slight PID "hunt" and not a lead-in. My take is, this is where the Max. Acceleration and Velocity fit in. If anyone knows, please let me know.

Work-In_Progress-of-PID-gauge.thumb.PNG.79b8e2e582189b0b1167af15c43004b5.PNG

Link to comment
Share on other sites

43 minutes ago, gr8guitar said:

Hello. I do not think I wrote:  ival = ipc.readLvar("L:Board",val) .  What is ival?

Sorry, that was a typo. not ival, just val. but it is wrong in any case. The val inside the parentheses is not needed, it is not in the syntax.

44 minutes ago, gr8guitar said:

I was going by what it took to read a Lvar, but I did not understand how to write the Lvar to an offset.

Do you mean the VALUE of an LVar? I am pretty sure they are all Double floats, so you'd need to use ipc.writeDBL(0x66C0, val). However, if an integer value is sufficent for your needs, the corrected version I provided should work.

Of course it depends on what the program which is reading it needs. Do you know that? Just writing to a user offset  does nothing unless something is reading it.

What now is there not to understand about writing to offsets?

Pete

 

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.