Jump to content

Help needed with XML Fuel Tank Selector


Recommended Posts

As the title says, I'm working on a fuel tank selection gauge for the DC-6.

Four engines with two tanks (main and aux) per engine, so a total of 8 tanks.

In normal operations each engine is feeded by one of it's own tanks, chosen by a selector lever S.

X-feed levers X only drop in if the aircraft gets unstable due to one or more engine losses.

 

Everything worked OK, there are built-in securities that prevent selecting empty tanks, and automatically selecting the needed X-feed positions.

 

DOPfNbL.png

(below the gauge is a Blackbox control window for some variables)

 

 

For example when Aux Tank is near to empty, the Selector switch refuses to go to position 1 (which is the way I want it).

 

But this had a flaw: when in position 0 (main), one can't go to position 2(off) when position 1 unaccessible due to an empty tank.

And in some cases this should be possible.

 

So I wrote this extra piece of code in the tank selection procedure:

 

   



(L:Sw1,enum) -- 0 max (>L:Sw1,enum)  
               [color=#ff0000](L:Sw1,enum) 1 ==[/color]                                   
                   [color=#ff0000]{if (A:FUEL TANK LEFT TIP LEVEL,percent) (L:MinPercent,percent) 
                       [color=#ff0000]{if 0 (>L:Sw1,enum) } }[/color]                    




(L:Sw1,enum) ++ 2 min (>L:Sw1,enum)   
                [color=#ff0000](L:Sw1, enum) 1 ==[/color]                                    
                   [color=#ff0000]{if (A:FUEL TANK LEFT TIP LEVEL,percent) (L:MinPercent,percent) 
                       [color=#ff0000]{if 2 (>L:Sw1,enum) [/color]                            
                           [color=#ff0000](L:Xf1,enum) 0 == {if 1 (>L:Xf1,enum) } } } [/color]  


 

What it should do: when the switch comes to position 1, it checks if there's still fuel in the aux tank, and if not it moves directly to the next position.

 

Problem is: whatever the amount of fuel in the aux tank, the selector never stays at 1, but moves to 2 or 0 directly.

Seems like the quantity comparison for whatever reason always returns TRUE.

 

Without the red code, the selector nicely stays at 1 when selected.

 

So something in my code is wrong, but I can't find it.

Any ideas?

 

Wim

b727fcaptain.jpgx701captain5.jpg
Link to comment
Share on other sites

I only viewed it on my small phone. So this may be nothing. But both conditions look very much the same to me. They have the same variables, then

and then one makes it 0 (zero), the other makes it 2.

 

I would think either the second one should be >

 

---

or the first should be (A:FUEL TANK LEVEL LEFT TIP) 0 ==

and the second one 0 >

(

or minpercent ==

and minpercent >

)

 

To be honest I don't really get the reason for L:minpercent. Is that beatse the tanks don't run fully dry?

---

i'm not to sure. Can't see the image too clearly on phone. But expressions look very much the same to me.

[sIGPIC][/sIGPIC]
Link to comment
Share on other sites

To be honest I don't really get the reason for L:minpercent. Is that beatse the tanks don't run fully dry?

Yes.

At initialisation (not shown) I set L:MinPercent to whatever suits me. If I set it to 0.0, I allow the tanks to run dry.

 

But expressions look very much the same to me.
They are, first is for when moving the lever up (2->1->0), second for when moving the lever down (0->1->2).

 

Wim

b727fcaptain.jpgx701captain5.jpg
Link to comment
Share on other sites

I looked at it in Notepad now.

 

?

You want to

click up

and if at that time switch is in position 1

and not enough fuel in tank

-->Set switch to 0

 

and

click down

and if a that time position is 1

and not enough fuel

-->set Switch to 2

--> and also set crossfeed

?

Did I get that right?

 

Then maybe a few more AND signs (&&) are needed, instead of if{ -----}

 

something like: (this is very rough)

 

(L:Sw1,enum) -- 0 max (>L:Sw1,enum)

(L:Sw1,enum) 1 ==

&& (A:FUEL TANK LEFT TIP LEVEL,percent) (L:MinPercent,percent)

{if 0 (>L:Sw1,enum) }

 

(L:Sw1,enum) ++ 2 min (>L:Sw1,enum)

(L:Sw1, enum) 1 ==

&& (A:FUEL TANK LEFT TIP LEVEL,percent) (L:MinPercent,percent)

{if 2 (>L:Sw1,enum)

(L:Xf1,enum) 0 == {if 1 (>L:Xf1,enum) }

 

 

I must admit, there's something that throws me off here.

the line

(L:Sw1,enum) ++ 2 min (>L:Sw1,enum)

especially

I never used ++ or -- myself, so I can't say if that is correct. But I guess you know what you are doing.

Also the 'enum' throws me off a bit. It's been a long since I had time to work on gauges.

 

Cheers,

il.

[sIGPIC][/sIGPIC]
Link to comment
Share on other sites

a) Yes, you got the logic right.

b) I'll try the AND operator, although I had more trouble with that in the past than with sequential IFs. The && is not at the correct place in yr example (should be at the end), but I understand what you mean. You've warned it was rudimental.

 

(L:Sw1,enum) ++ 2 min (>L:Sw1,enum)

Adds 1 to Sw1, but tops it off at 2.

If Sw1 was 2 already, (2 ++) returns 3. Then (3 2 min) returns 2.

So it tops off.

 

I guess I'll try isolating these expressions in a small test gauge, without all the other conditional test which are not shown here. So I'm sure my problem lays in these lines of code, and not somewhere else.

 

Wim

b727fcaptain.jpgx701captain5.jpg
Link to comment
Share on other sites

Sorry, I forgot to put a code box around my last post.

I then also fixed two mistakes in it. In the if statements. (was {if instead of if{ )

 

EDIT

Also changed position of && in both statements

 



(L:Sw1,enum) -- 0 max (>L:Sw1,enum)  
               (L:Sw1,enum) 1 ==                                   
               (A:FUEL TANK LEFT TIP LEVEL,percent) (L:MinPercent,percent) 
                  if{ 0 (>L:Sw1,enum) }                    





(L:Sw1,enum) ++ 2 min (>L:Sw1,enum)   
                (L:Sw1, enum) 1 ==                                    
                  (A:FUEL TANK LEFT TIP LEVEL,percent) (L:MinPercent,percent) 
                       if{ 2 (>L:Sw1,enum)                             
                           (L:Xf1,enum) 0 == {if 1 (>L:Xf1,enum) }    



 

 

 

I think you can also simplify the last line to:

         if{ 2 (>L:Sw1,enum) 1 (>L:Xf1,enum) }     

 

(just set X feed, no need to check if it's in position 'off' first.

checking is what a human would do;) )

[sIGPIC][/sIGPIC]
Link to comment
Share on other sites

Ok:) In the mean time I'll ponder the logic some more.

 

Edit btw. In the last post I just also changed position of && in both sections.

 

 

--

and while doing that, I also noticed something else.

(A:FUEL TANK LEFT TIP LEVEL,percent) (L:MinPercent,percent)

 

how ca it be lower then minimum.

After all, this read true if fuel tank level is less then L:MinPercent.

I would think it could only become equal to L:MinPercent. Not less.

[sIGPIC][/sIGPIC]
Link to comment
Share on other sites

Doh... what a bummer. Found out I was using {if in stead of if{ in this piece of code (see OP).

Overlooked it for hours and days...

 

Once corrected it worked.

But taking some of your remarks in account, I reviewed and simplified the logic quite a lot.

 

a) check for empty aux tank only needed when moving the lever down

b) check for engaging X-feed is already done somewhere else in the gauge, not needed here

c) no need for checking if lever is at position 1

 

The working result (too simple to be true):

 

  



           (L:Sw1,enum) -- 0 max (>L:Sw1,enum) 





           (L:Sw1,enum) ++ 2 min (>L:Sw1,enum)
           (A:FUEL TANK LEFT TIP LEVEL,percent) (L:MinPercent,percent)              if{ 2 (>L:Sw1,enum) }

 

Thanks,

Wim

b727fcaptain.jpgx701captain5.jpg
Link to comment
Share on other sites

I know the feeling, I have just finished coding a VSI, eveything worked fine except for the VS set bug & I coundn't find anything wrong with the code, so I started fom the beginning redoing it exactly the same (as far as I know) & bingo everything worked.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...