Oscilloscope addon: Difference between revisions
No edit summary |
(Major cleanup; fix double redirect) |
||
Line 1: | Line 1: | ||
[[File:Oscilloscope.png|thumb|This screenshot shows the usual c172p "magnetos checking" Channel 1 (yellow) is '''rpm''' (100 rpm / div).Channel 2 (mauve) is '''magnetos''' (1 / div).Time sweep is 200 ms / div.<ref>{{cite web |url = https://forum.flightgear.org/viewtopic.php?p=325929#p325929 |title = <nowiki> Re: Plot2D and graph helpers </nowiki> |author = <nowiki> rleibner </nowiki> |date = Jan 6th, 2018 |added = Jan 6th, 2018 |script_version = 0.36 }}</ref>]] | [[File:Oscilloscope.png|thumb|This screenshot shows the usual c172p "magnetos checking" Channel 1 (yellow) is '''rpm''' (100 rpm / div).Channel 2 (mauve) is '''magnetos''' (1 / div).Time sweep is 200 ms / div.<ref>{{cite web |url = https://forum.flightgear.org/viewtopic.php?p=325929#p325929 |title = <nowiki> Re: Plot2D and graph helpers </nowiki> |author = <nowiki> rleibner </nowiki> |date = Jan 6th, 2018 |added = Jan 6th, 2018 |script_version = 0.36 }}</ref>]] | ||
The '''oscilloscope''' [[addon]] was created as an example of the use of 3 helpers included in the addon: | |||
* <code>skinnable.nas</code> to create Canvas GUI dialogs including multiple clickable layers. | |||
* <code>graph.nas</code> to create various types of Canvas instruments.<ref>{{cite web | |||
|url = https://forum.flightgear.org/viewtopic.php?p=325332#p325332 | |url = https://forum.flightgear.org/viewtopic.php?p=325332#p325332 | ||
|title = <nowiki> Re: Spoken GCA </nowiki> | |title = <nowiki> Re: Spoken GCA </nowiki> | ||
Line 11: | Line 9: | ||
|date = Dec 27th, 2017 | |date = Dec 27th, 2017 | ||
}}</ref> | }}</ref> | ||
* <code>plot2D.nas</code> the very basic Canvas helpers. | |||
= Background = | But apart from that, the oscilloscope addon itself may be an useful tool for developers and coders. Although I do not know any aircraft that has this instrument in its panel, the on-board engineer will eventually appreciate having it on hand at some point. | ||
== Background == | |||
{{cquote|I was just thinking today that it might be cool to have a built in grapher for simple / quick graphing needs. | {{cquote|I was just thinking today that it might be cool to have a built in grapher for simple / quick graphing needs. | ||
With the property system it would be trivial to pick an arbitrary property from the property tree and graph it over time -- superimposed on top of everything else. | With the property system it would be trivial to pick an arbitrary property from the property tree and graph it over time -- superimposed on top of everything else. | ||
Line 19: | Line 19: | ||
I thought I'd toss this out there in case someone thought it was worth while enough to tackle.<ref>{{cite web |url=http://www.mail-archive.com/flightgear-devel@flightgear.org/msg03651.html |title=idea ... (?)|author=Curtis Olson |date=Fri, 08 Mar 2002 07:43:35 -0800}}</ref>|Curtis Olson}} | I thought I'd toss this out there in case someone thought it was worth while enough to tackle.<ref>{{cite web |url=http://www.mail-archive.com/flightgear-devel@flightgear.org/msg03651.html |title=idea ... (?)|author=Curtis Olson |date=Fri, 08 Mar 2002 07:43:35 -0800}}</ref>|Curtis Olson}} | ||
= How to install = | == How to install == | ||
{{note | | {{note|This is the latest version (Jan 30, 2018)}} | ||
}} | {{note|From version 2017.4.0, the FlightGear launcher accepts the <code>--addon</code> option in the ''Settings/Additional Settings'' tab.}} | ||
}} | |||
= How to use = | If your FlightGear version accepts [[Addon]]s, you can download this feature from the {{fgaddon source|path=Oscilloscope|text=FGAddon repository}}. Download all the 11 files into the directory of your choice. | ||
== Manual mode == | |||
Launch FlightGear including <code>--addon</code> argument, for example: | |||
<nowiki>fgfs <usual args> --addon=/path/to/fgaddon/Oscilloscope</nowiki> | |||
Otherwise, you can install it as a submodule. Contact the author for further instructions. | |||
== How to use == | |||
=== Manual mode === | |||
Just pressing the {{key press|o}} key the oscilloscope window appears: | Just pressing the {{key press|o}} key the oscilloscope window appears: | ||
[[File:Oscilloscope (default skin).png]] | |||
[[File: | |||
Click any BNC connector (Channel 1 or Channel 2) to open the | Clicking the {{key press|?}} button you will have a basic help about ''clickable areas'' and ''readings''. Click {{key press|?}} again to close the help. | ||
==== Connecting to a source ==== | |||
Click any BNC connector (Channel 1 or Channel 2) to open the Channel Source dialog. | |||
[[File:Source dialog.png]] | |||
Enter a valid source as: | Enter a valid source as: | ||
* | * A numeric or boolean property, for example: | ||
: <code>/position/altitude-agl-ft</code> | |||
* | * A numeric Nasal expression, for example: | ||
: <code>getprop("/engines/engine/rpm") /100 ;</code> (do not forget the <code>;</code>) | |||
: | : <code>0 ;</code> (only useful to adjust Offset) | ||
: | : <code>5+4*math.sin(D2R*int(100*systime())) ;</code> | ||
Since the oscilloscope | |||
The | Since the time of oscilloscope is the same as simulated one, simulation must not be paused in order to see the resulting plots. | ||
=== Adjusting | |||
Clicking the | The window above the connector will display the current source value. | ||
The | |||
==== Adjusting gain and offset ==== | |||
Clicking the upper/lower half of the Gain knobs will increase/decrease the gain of the channel. | |||
The window below the knob will display the current gain (units/div). | |||
The Offset knobs respond in a similar way. | The Offset knobs respond in a similar way. | ||
=== One Shot store === | ==== Adjusting timebase ==== | ||
Clicking this button will erase the screen and prepare Channel 2 to act as trigger. | Proceed in the same way with the Timebase knob. The window below the knob will display the current sweep speed (secs/div). | ||
Channel 2 must be an | |||
Click this button again in order to return to the default continuous sweeps. | ==== One Shot store ==== | ||
== | Clicking this button will erase the screen and prepare Channel 2 to act as trigger. | ||
Instead of launching the oscilloscope with the {{key press|o}} key and clicking buttons and knobs, it is possible to instantiate the instrument from a Nasal script. | |||
Channel 2 must be an integer or boolean property. Once its value changes, a single sweep is triggered and the screen freezes. | |||
Click this button again in order to return to the default continuous sweeps. | |||
=== Scripted mode === | |||
{{note|Buttons and knobs will still reacting to manual clicks.}} | |||
Instead of launching the oscilloscope with the {{key press|o}} key and clicking buttons and knobs, it is possible to instantiate the instrument from a Nasal script. | |||
Open the Nasal Console (or the REPL interpreter if you prefer) and execute these lines: | Open the Nasal Console (or the REPL interpreter if you prefer) and execute these lines: | ||
<syntaxhighlight lang="nasal">var Osc = oscilloscope.show.new(); | <syntaxhighlight lang="nasal">var Osc = oscilloscope.show.new(); | ||
Line 66: | Line 86: | ||
Osc.setGain(channel:2, gain:2); | Osc.setGain(channel:2, gain:2); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
You can explore other nasal instructions like: | You can explore other nasal instructions like: | ||
Line 73: | Line 92: | ||
Osc.setChannelInput(1, 'var alt = getprop("/position/altitude-ft"); return alt/10;'); | Osc.setChannelInput(1, 'var alt = getprop("/position/altitude-ft"); return alt/10;'); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= | <!-- == Behind the scenes == | ||
--> | |||
== References == | |||
{{Appendix}} | {{Appendix}} |
Revision as of 11:14, 12 July 2020
The oscilloscope addon was created as an example of the use of 3 helpers included in the addon:
skinnable.nas
to create Canvas GUI dialogs including multiple clickable layers.graph.nas
to create various types of Canvas instruments.[2]plot2D.nas
the very basic Canvas helpers.
But apart from that, the oscilloscope addon itself may be an useful tool for developers and coders. Although I do not know any aircraft that has this instrument in its panel, the on-board engineer will eventually appreciate having it on hand at some point.
Background
I was just thinking today that it might be cool to have a built in grapher for simple / quick graphing needs.
With the property system it would be trivial to pick an arbitrary property from the property tree and graph it over time -- superimposed on top of everything else. Things get a bit trickier if you want to control scaling, how much time history get's graphed, multiple values, etc., but even graphing a single value (or maybe just two values) over time could be of some use. I thought I'd toss this out there in case someone thought it was worth while enough to tackle.[3]— Curtis Olson
|
How to install
Note This is the latest version (Jan 30, 2018) |
Note From version 2017.4.0, the FlightGear launcher accepts the --addon option in the Settings/Additional Settings tab.
|
If your FlightGear version accepts Addons, you can download this feature from the FGAddon repository. Download all the 11 files into the directory of your choice.
Launch FlightGear including --addon
argument, for example:
fgfs <usual args> --addon=/path/to/fgaddon/Oscilloscope
Otherwise, you can install it as a submodule. Contact the author for further instructions.
How to use
Manual mode
Just pressing the o key the oscilloscope window appears:
Clicking the ? button you will have a basic help about clickable areas and readings. Click ? again to close the help.
Connecting to a source
Click any BNC connector (Channel 1 or Channel 2) to open the Channel Source dialog.
Enter a valid source as:
- A numeric or boolean property, for example:
/position/altitude-agl-ft
- A numeric Nasal expression, for example:
getprop("/engines/engine/rpm") /100 ;
(do not forget the;
)0 ;
(only useful to adjust Offset)5+4*math.sin(D2R*int(100*systime())) ;
Since the time of oscilloscope is the same as simulated one, simulation must not be paused in order to see the resulting plots.
The window above the connector will display the current source value.
Adjusting gain and offset
Clicking the upper/lower half of the Gain knobs will increase/decrease the gain of the channel.
The window below the knob will display the current gain (units/div).
The Offset knobs respond in a similar way.
Adjusting timebase
Proceed in the same way with the Timebase knob. The window below the knob will display the current sweep speed (secs/div).
One Shot store
Clicking this button will erase the screen and prepare Channel 2 to act as trigger.
Channel 2 must be an integer or boolean property. Once its value changes, a single sweep is triggered and the screen freezes.
Click this button again in order to return to the default continuous sweeps.
Scripted mode
Note Buttons and knobs will still reacting to manual clicks. |
Instead of launching the oscilloscope with the o key and clicking buttons and knobs, it is possible to instantiate the instrument from a Nasal script.
Open the Nasal Console (or the REPL interpreter if you prefer) and execute these lines:
var Osc = oscilloscope.show.new();
var myFunc = func {return 10+4*math.sin(D2R*int(100*systime()));};
Osc.setTimeBase(0.2);
Osc.setChannelInput(2,'/controls/engines/engine/magnetos');
Osc.setChannelInput(1, myFunc);
Osc.setGain(channel:1, gain:2);
Osc.setGain(channel:2, gain:2);
You can explore other nasal instructions like:
Osc.setChannelInput(2, func {return 5.5;});
Osc.setChannelInput(1, 'var alt = getprop("/position/altitude-ft"); return alt/10;');
References
References
|