OHM Calculation MFD

OrbitHangar

Addon Comments
Joined
Apr 9, 2008
Messages
3,832
Reaction score
18
Points
0

Author: rar76

Version 111017

Some of the new features:
- each MFD is a separate instance, so multiple files can be loaded
- joystick axes functions (supports up to 16 joysticks, each with up to 8 axes); If you wish to test your joystick support, load "joy_test.txt"
- forcefeedback functions to send forcefeedback commands to a joystick(s)
- MFD colors
- large additions to the Help (HLP) screen
- many more features...

Calculation MFD is an mfd to perform math calculations, similar to Excel for
Windows, however calculations are performed in realtime. Users input expressions
and use a wide array of operands such as: +,-, *, /, sqrt, factorial, ^, etc. The
MFD also provides over 50 realtime flight data (variables) including:
pitch
bank
airspeed
periapsis
eccentricity
fuelrate
fuelmass
angular velocity and acceleration
Each equation is also stored in variables (x0 to x63) to use with further math
calculations.
Other features:
- result format and font can also be changed
- calculations can be paused
- calculationmfd.txt stores all the equations to reload whenever orbiter reloads,
and the equations can be edited in this file with notepad.

DOWNLOAD
 
Sorry, forgot to mention: this is a BETA.

I found a few bugs and they are already fixed in next version:
-unary functions (-1) don't work, this is fixed
-perigee changed to periapsis (since perigee is just for Earth)

Please share if you find bugs and also share if you have ideas on how to make this MFD more useful.

Things in next version:
- dx0: rate of change of vars (ie x0) per second
- ix0: definite integral of x0
- more imported functions
[EDIT1]
- multiple instances of Calculation MFD: data and calculations are shared, but the user can change pages or change which equations are viewable on each mfd separately now.
- more on the MFD help pages
- labels for equations. For example, sqrt(x0^2+x1^2+x2^2) looks horrible at quick glance, so now you can add 'velocity'sqrt(x0^2+x1^2+x2^2) and all that the mfd will show is 'velocity'
- better error messages, for example: which variables are unrecognized; which operators (+,-, etc) need more operands (numbers)
- calculation delay: in the first version of Calculation MFD, the results are generated at the same rate as the MFD refresh rate. Now you can set this MFD to refresh less often, for whatever reason you see fit.
 
Last edited:
[changelog to v111.05.17]
- added more functions including:
dx0..dx63: rate of change per second of x0 to x63
ix0..ix63: "area under the graph" of a var x (ie x0) over a 1 second interval
- multiple instances of Calculation MFD: data and calculations are shared, but the user can change pages or change which equations are viewable on each mfd separately now.
- more on the MFD help pages
- labels for expressions. Labels are just asthetic and have no purpose other than for readability. For example, sqrt(x0^2+x1^2+x2^2) looks horrible at quick glance, so now you can add 'velocity'sqrt(x0^2+x1^2+x2^2) and all that the mfd will show is 'velocity'
- better error messages, for example: which variables are unrecognized; which operators (+,-, etc) need more operands (numbers)
- calculation delay: in the first version of Calculation MFD, the results are generated at the same rate as the MFD refresh rate. Now you can set this MFD to refresh less often, for whatever reason you see fit.
- settings and expressions are saved only when the SAV button is pressed.
 

Attachments

  • CalculationMFD.jpg
    CalculationMFD.jpg
    55.9 KB · Views: 10
Last edited:
Thank you Keatah, Tommy and everyone who is enjoying this addon :)

I'll look into that Jarvitä, thx for feedback.

[EDIT] If RPN is postfix: I actually use the shunting yard algorithm to place the infix notation to postfix. I'm just not too familiar with postfix at the moment, ie unary operators, but I'll look at it more. I actually placed some checks in the algorithm to check for infix - if I "relaxed" those checks, I'm pretty sure the algorithm would recognize postfix (and prefix). So would this be: you enter a postfix expression and then it would display the result? Or do you want to see stack calculations?

---------- Post added at 05:52 PM ---------- Previous post was at 05:39 PM ----------

Or something like this?

http://www.naveen.net/calculator/
 
Last edited:
Thanks for the update. BTW, please correct the add-on's date unless you're posting from far away future (day and year are mixed up :cheers:)
 
Date corrected lol - thanks for spotting that Wishbone.

So Jarvitä, what you're proposing is:

example calculator MFD input:
2 5 * 3 +

Or were you thinking more along the lines of 1 number input at a time, click on an operator (+,-, *, etc.), and repeat?
 
example calculator MFD input:
2 5 * 3 +

Correct. First you enter 2 and 5 as stack items, than multiply them (reducing stack to a single item, 10), then introduce another stack item, 3, add stack items 10 and 3, remove them from the stack and add the result - 13 - as the single remaining stack item.
 
Finally looking into this. This will need a different parser all together so it might take a bit of time - however, it's great that the input is already in the right order. I'm just wondering how unary operators are handled.

Also, I added a PID algorithm from another project I had. PID ( proportional, integral, derivative) can be used for autopilots. With the PID, I also included "setters", ie the user can now set the elevator trim, elevators, ailerons, etc., so with the "setters" and the PID the user can create an autopilot and tune it for any types of input the user chooses.
 
That would be VERY helpful, thank you. Is there any way to save and retrieve autopilot/formula configurations and to mark for what vessels they were used?
 
Currently, there is no way to save or retrieve autopilot/formula configurations based on the vessel, but this could be easily implemented - and a great idea!

My first idea: have a file that corresponds to each ship, so instead of calculationmfd.txt it would be calculationmfd_deltaglider.txt or calculationmfd_g42.txt. This would be incredibly quick to implement. Also, an Open button could be used to open a calculationmfd text file of another ship to avoid having to re-enter commonly used calculations, however calculation saves would default to the calculationmfd_<vessel_name>.txt.

Would that be sufficient? I could write up a file/open/save/save as button/menu later on, but that would require quite a bit more time.

RPN

Jarvitä, haven't forgotten about your request: I had to rewrite a parser to make it reject unary operators (took me awhile to find that issue lol). This will take more testing once it's done, since it's lower level. I'm guessing the rpn mode will be a button, that's pressed to toggle whether the calculations entered is infix or rpn.
 
RPN is working. Only one issue now: how to select rpn vs infix notation.

Some options:
1) A MFD setting that makes ALL expressions RPN. I'm guessing if some of you want RPN, you might only want to use RPN. If this is the case, this option would be best.

2) per expression setting. Just like each expression can have it's own precision, I could make it so each expression has to be selected then perhaps an RPN button press will keep the format in RPN. This means that every time someone wants to use RPN they would have to press RPN, which could be troublesome.

3) expression line setting: rpn 3 4 + 2 -
Downside is the user has to type rpn each and every time to use rpn, which might be time consuming.

So guys, if you have input, please share. I'm guessing option 1, but I'm not actually sure how some of you want to use RPN.

For this release, I'll do an MFD setting with an RPN button, where the button will toggle ALL expressions to be either RPN or infix.
 
Update

Ok, tweaking PID: I used the first derivative with the D term, where in most cases, PIDs use second derivative. I found this was easier to use as I could put a "speed limit" on how fast the control output would change. If I had used second derivative, I would have put an acceleration limit on control output, but control output rate of change still crops up.

So, next release will have PID with only first derivative unless someone would like to have second derivative also. Personally, I have about 2 months experience with PIDs so I'm still learning myself as to how to tune them, etc.
 
Not being an expert always thought D to stand for the first derivative. Another thing of note: tried installing the MFD but it complained bitterly that it relies on the debug version of MS VC 2010 runtime, which I haven't got (the release one is widely available, though).
 
Update:

It will be a while still. I noticed some of the computations were taking way too much cpu time, so I will need to make an intermediate language to handle calculations much faster.
 
You can still offload things to a background thread, people are fine with 1 Hz refresh rate for most items.
 
Last edited:
Doh! Did not see page 2 sorry Wishbone. I'll look into the MS VC 2010 runtime error.
 
Ok, finally submitted a "release" exe version with code optimization. Please give feedback if you have issues or would like to see changes.

Sorry, real life got in the way of my astronaut/cosmonaut fun :)

But yeah, if you guys would like to see more built in functions, give a shout! I'm starting to think that maybe joystick input capture would be cool!

I wonder if other devs use directinput to capture joystick.
 
Back
Top