Freitag, November 16, 2018

Condition on parameter - Low bus voltage

I took this feature to the next level.

The previous situation with a link between a switch and an instrument does not reflect the true logic of an small airplane. The new idea is when the bus power drops below a certain value, some instruments go off. The BATTERY SWITCH has no effect. For that you have to use "BUS_1_VOLTS". Imagine your battery in the airplane is dead, you can use the switch, but no reaction on the instruments. Or what if the generator fails during flight and you do not charge the battery. After a while you will get some electrical instruments failure. How exactly the behaviour is, I have to check on a real aircraft.

Remark: in the X-Plane C172, if the voltage drops below 20V most virtual instruments go off, like GPS and fuel indicators. Temperature and pressure indicators don't go off. I tested that. The corresponding dataref for low voltage is sim/aircraft/limits/red_lo_bat_volt. Now if the condition is also set to 20V, also the hardware instruments go off when voltage is below 20V. Which is nice to observe.

The syntax for the condition is:
<pin number> <parameter>
1 Bus_1_Volts

Here the relevant lines of the data.cfg. In yellow the condition and comparison of that condition.

[Conditions]
1 Bus_1_Volts
# -----------------------------
[Input]
S8.0 Beacon_Light
S8.1 Battery1_Switch
S8.2 Avionics_Master_Switch
S8.3 Bus_Cross_Tie
E8.5 Baro_Setting
# -----------------------------
[Output]
P30.0 Fuel_Level_Tank1  r=0,19.7,39.4,59,79.4 m=0,38,56,72,100   c=C1>20   f=x
P30.1 Fuel_Level_Tank2  r=0,19.7,39.4,59,79.4 m=0,38,56,72,100   c=C1>20   f=x
P30.2 Oil_Temp_C_Eng1  r=0,80,160,290         m=0,42,64,100   
P30.3 RPM_Engine1.      r=0,2260               m=0,100

Sonntag, November 11, 2018

Condition on function

Finally, I figured out / understood the syntax of "conditions". The goal was to implement the logic if the BATTERY SWITCH is off, then also all COIL-GAUGES are switched off and indicating no value. In SimVimCockpit 0.9.27a the new flag "x" makes this possible. The description below explains how to use it.

Two steps are needed:

1. add condition to PWM output. In my case the BATTERY SWITCH is connected to multiplexer Pin 8.1. The logic is the following: if the condition is met (SWITCH ON), then the function (GAUGE) is active. If condition is not met (SWITCH OFF), then the function is inactive and values go to zero.
Syntax: c=S<Pin number>
c=S8.1

2. add the flag to set output values to zero if the specified condition is met.
In this case here, if BATTERY SWITCH is ON also the COIL GAUGE will show the values.
The flag works on PWM (coil instruments), Stepper and Servo.
Syntax: f=x
f=x

Option: add the mode when no hardware (switch, button) is assigned to a Arduino pin.
Syntax: S<Pin number> Mode_Switch
S8.1 Mode_Switch

Here is the current version of my "data.cfg". Marked yellow the condition and flag:
*1-1U1
# written by VAKA Nov 2018
# -----------------------------
# RJn = Connector number
# A or B = jumper setting on Breakout Board
# Dn or An = pin numbers on Arduino
# RJ1 Digital In:  A=D8,  B=D9 
# RJ2 Digital In:  A=D10, B=D11
# RJ3 Digital In:  A=D12, B=D13
# RJ4 Analog  In:  A=A0,  B=A1
# RJ5 Analog  Out: A=D30, B=D31
# RJ6 Digital Out: A=D40, B=D41
# -----------------------------
[Input]
S8.0 Beacon_Light
S8.1 Battery1_Switch
S8.2 Avionics_Master_Switch
S8.3 Bus_Cross_Tie
E8.5 Baro_Setting
# -----------------------------
[Output]
P30.0 Fuel_Level_Tank1 r=0,19.7,39.4,59,79.4 m=0,38,56,72,100 c=S8.1  f=x
P30.1 Fuel_Level_Tank2 r=0,19.7,39.4,59,79.4 m=0,38,56,72,100 c=S8.1  f=x
P30.2 Oil_Temp_C_Eng1 r=0,80,160,290 m=0,42,64,100 c=S8.1  f=x
P30.3 RPM_Engine1 r=0,2260 m=0,100
# -----------------------------
[Startup]
XPDR_CODE v=7000
Com1_Active_6 v=119625
Com1_Stby_6 v=134125
Beacon_Audio_Switch v=0


10s Videoclip: