• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FS2004 Problem with needle deflection

Messages
1,468
Country
italy
I'm having a niggling problem which I don't quite understand. That is with the needle deflection of a gauge. (L:WINHEAT,number) is either 0,1 or 2 and on its own all the deflections are correct but when I add (L:BUS_SWITCH,number) (P:local time, seconds) I never get the deflection requested by <Item Value="2". Instead It deflects to <Item Value="1". The reason for (L:BUS_SWITCH,number) (P:local time, seconds) is to momentarily set the gauge to zero which it does do perfectly. Can someone explain why the needle doesn't fully deflect to <Item Value="2" and how it should be coded correctly so that it can.
Many Thanks
vololiberista

btw none of the icons are functioning in my new thread composition box. I'm using firefox 9 So contructed the code tags on my keyboard.
Code:
 This  sets up the time delay 
<Click>(G:Var1) 0 != if{ 0 (&gt;G:Var1) 1 (>L:Sound_button,enum) 1 (>L:ground2,enum) 0 (>L:flight,enum) (P:local time, seconds) 0.14 + (>L:BUS_SWITCH,number) } els{ 1 (&gt;G:Var1) 1 (>L:Sound_button,enum) 1 (>L:flight,enum) 0 (>L:ground2,enum) (P:local time, seconds) 0.14 + (>L:BUS_SWITCH,number) }</Click>

Code:
<Value>(L:WINHEAT,number) if{ (L:BUS_SWITCH,number) (P:local time, seconds) &gt; }</Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
            <SYSTEM_ELECTRICAL Action="0"/>
         </Failures>
         <Nonlinearity>
            <Item Value="0" X="11" Y="15"/>
<Item Value="1" X="25" Y="9"/>
            <Item Value="2" X="38" Y="15"/>            
         </Nonlinearity>
 
What do you "think" this is doing?

Code:
(L:WINHEAT,number) if{ (L:BUS_SWITCH,number) (P:local time, seconds) &gt; }

Having (P:local time, seconds) &gt; as a Command is meaningless because it's an Evaluation expression, not a Command statement, and is most likely screwing up the value of (L:WINHEAT,number)...

The prototype syntax is always:
(Evaluation Expressions) if{ Command Statements }
 
I understand what you're saying Bill. But, I have other instances where it does seem to work.
for example
Code:
This is a red light that is always on unless the engine generator is running. Also there is a test button that extinguishes the light and (L:BUS_SWITCH,number) (P:local time, seconds) &lt; which makes the light flicker off and on.
<Value>(A:SIM ON GROUND, bool) (A:ELECTRICAL GENALT BUS VOLTAGE:1,volt) + (A:ELECTRICAL GENALT BUS VOLTAGE:1,volt)  + 5 &lt; (L:feel_test,number) 0 ==  and if{ (L:BUS_SWITCH,number) (P:local time, seconds) &lt; }</Value>
It works well with lights but not so well with dials. I also have this for a voltmeter which shows two readings one with and the other without the engine generators running. the (L:BUS_SWITCH,number) (P:local time, seconds) here makes the needle twitch perfectly. But i can't get it to work correctly with the amps gauge at the top of this post. Yes it goes to zero but not maximum.

vololiberista
Code:
<Value Minimum="0" Maximum="30">(A:ELECTRICAL BATTERY VOLTAGE,volts) abs (A:Electrical genalt3 bus voltage,volts) | (L:BUS_SWITCH,number) (P:local time, seconds) &lt; |</Value>
 
Okay, I suppose I have not been entirely clear here. There are "some" instances where you can have a conditional and/or math expression within a { Command } area.

Evidently in those cases where it "seems to work" it is -as Tom says- "just by luck."

Code:
if{ (L:BUS_SWITCH,number) (P:local time, seconds) &lt; }

In the above, evidently FS is "assuming" that you want to add or multiply those two variables to generate a FINAL variable output.

The problem remains that (P:local time, seconds) &lt; has no intrinsic meaning, in other words "local time in seconds is less than WHAT precisely? It's is an incomplete expression.

Even if you added a "+" sign to indicate adding, without anything to compare "local time in seconds" against, how can anything other than chaos result?

What you want is some complete math that will return ONLY a zero or a one for the final output.

For that you will need to create a really fast timer.

Code:
if{ 
     (L:BUS_SWITCH,number) 
     (P:local time, seconds)  0.02 % 0.01 > ! * 
  }

Evaluating the above, we are multiplying the control variable BUS_SWITCH's value of 1 times the "really fast timer" which is itself switching between 0 and 1 at a rate of 0.01 seconds!

Pass #1: 1 x 0 = 0
Pass #2: 1 x 1 = 1
Pass #3: 1 x 0 = 0
et cetera until we switch the control variable BUS_SWITCH to 0.

I sure hope this is clear enough now... :)
 
Maybe FS evaluates that expression and outputs 0 or 1 (i.e. the results of a boolean expression)?
 
Maybe FS evaluates that expression and outputs 0 or 1 (i.e. the results of a boolean expression)?

FS will evaluate whatever complete expression you put in there, Tom. It's up to US to make sure the math makes sense and outputs only a binary (boolean) value, if that is what we need.
 
Are you saying Billl that it would be better in fact to have (L:BUS_SWITCH,bool) instead of (L:BUS_SWITCH,number). Because what does happen is that the entire value of (P:local time, seconds) plus 0.14 is inserted into (L:BUS_SWITCH,number)
would (P:local time, seconds) 0.14 + (>L:BUS_SWITCH,bool) work better, thus giving me a single digit to play with which would be much easier to test!!!
If I had if{ (L:BUS_SWITCH,number) (P:local time, seconds) 0.02 % 0.01 > ! * } wouldn't that be too fast to test. Also I don't quite see how (L:BUS_SWITCH,number) would end up with a one or zero.
I am only following what is written in other gauges for example:-
Code:
<Update>
(L:Monitor_door_sound, bool)
if{ (L:Sound_door,enum) ! (A:CANOPY OPEN,enum) 0 == and if{ 0 (>L:Monitor_door_sound, bool) 1 (>L:Sound_mes1,enum) (P:local time, seconds) 12.5 + (>L:CAB LIGHT 2,number) and }
}
</Update>
Here (P:local time, seconds) 12.5 + (>L:CAB LIGHT 2,number) sets up a timer for the cabin call light after the doors are closed and activates whilst a message is being played.

Code:
<Value>
     (L:CAB LIGHT ON,number) (L:CAB LIGHT 2,number) (P:local time, seconds) &gt; |
   </Value>
And here the value is acted upon by the cabin call light gauge.
So I'm just trying to follow that same logic!!
vololiberista
 
No, that is not what I'm saying at all. It doesn't matter a bit whether you use "enum", "number" or "bool" for the unit value, as the end result will always be the same: either 0 or 1.

As for the speed, this is a very simple formula:

(P:local time, seconds) (total time) % (on time) > !

Example #1:
Code:
     (P:local time, seconds)  2 % 1 > !
In the example above, the total time is 2 seconds, and the on time is 1 second. This means that the value calculated by this expression will be 1 second on followed by 1 second off.

In other words the calculated value will flip-flop between 0 and 1 every two seconds. It is a trivial matter to adjust the speed of the flip-flop by simply changing the two numeric parameters in the formula... ;)

In the scheme I suggested previously is simply method to turn the "timer" on and off as desired. The output will always be 0 if it is "turned off", and will flip-flop on/off (0 - 1 - 0 - 1 - etc.) at a specific rate whenever "turned on." It is a universal timer circuit.
 
Back
Top