Welcome to Cockpitbuilders.com. Please login or sign up.

May 20, 2024, 05:57:08 AM

Login with username, password and session length

PROUDLY ENDORSING


Fly Elise-ng
28 Guests, 0 Users
Members
Stats
  • Total Posts: 59,641
  • Total Topics: 7,853
  • Online today: 55
  • Online ever: 831
  • (May 03, 2024, 12:39:25 PM)
Users Online
Users: 0
Guests: 28
Total: 28

COUNTDOWN TO WF2022


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

Welcome

SIOC script for 737 generator functions

Started by dc8flightdeck, July 15, 2013, 01:23:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dc8flightdeck

Im trying use the combined generator status (including APU gen) to control one output on a Outputs card. Im sure there has to be a relatively simple way to to do this.

The idea is, if all three generators are "OFF" then output 01 is activated. If any of the generators in FSUIPC are "ON" then  output  01 will stay "OFF"

The scrip below is to give an idea of what I want, but Im not sure how to make it work as I described. Any help is greatly appreciated.
Justin

Var 22, name gen1pow, Link FSUIPC_INOUT, Offset $3B7C, Length 4     // GENERATOR 1 STATUS
Var 23, name gen2pow, Link FSUIPC_INOUT, Offset $3ABC, Length 4     // GENERATOR 2 STATUS
Var 24, name APUpower, Link FSUIPC_INOUT, Offset $0B51, Length 1    //  APU generator active flag

{
  IF &gen1pow = 0     //  Generator one off
 
If&gen2pow = 0     //  Generator two off

If&APUpower = 0     //  APU off

  &AC_Relay = 1   
   }
   
  ELSE
{
   &AC_Relay = 0  // AC master relay in normally closed position places 737 AC power to "ON" status
}
}

Var 25, name AC_Relay, Link IOCARD_OUT, Output 01     // Master AC relay K1

fordgt40

Justin

You are very close <g>

I am just about to call it a day here and also after a few beers!

All you need to do is to add some curly brackets to each nested IF statement and you are there. Give it a try!

If still a prob, then say so and I will post the solution tomorrow <g>

David

dc8flightdeck

Hello,
That how I first tried it but the output only responds to the last offset (APU) and ignores the position of the first two generator offsets.

I tried some other arrangements but also had no luck.

Justin

fordgt40

Justin

You need to nest each IF statement as below

IF gen1 = off
     {
      IF gen2 = off
        {
            IF gen3 = off
              {
                 relay = on
               }
       }
   }

ELSE
      {
       relay = off
      }

dc8flightdeck

That is how I first tried it, but no luck. 

Thanks,
Justin

fordgt40

Justin

I see the problem. The logic is correct but the code will only run when the variable it is attached to changes value
I will change the code to a subroutine and repost

David

fordgt40

Justin

Apologies, the logic was incorrect. If all generators were off it was ok, however, if gen1 was off and gen 2 was on, then it never ran the code to turn off the relay. It did not get to the ELSE command as it had already partially run the sequence of IFs. I learnt something, so it was a useful exercise :)

Here is the code that works

Var 0 Value 0
{
   &check_state = 0
   &check_state = TIMER 1 0 5
}


var 1 name gen1
var 2 name gen2
var 3 name gen3
var 4 name relay

var 5 name check_state link subrutine
{
IF &gen1 = 0
     {
      IF &gen2 = 0
            {
            IF &gen3 = 0
              {
                 &relay = 1
               }
   ELSE
      {
      &relay = 0
      }


          }
   ELSE
      {
      &relay = 0
      }
   }

ELSE
      {
       &relay = 0
      }
}


I have introduced a TIMER that never stops and calls the check_state variable every 50 milliseconds. The check_state variable then polls the generators condition.

Regards

David

dc8flightdeck

Thank you, Ill try this in the sim this morning.

Justin

727737Nut

There is another way that I used to do a similar function in my sim that I think might be easier and cleaner?  Since the Gen on/off is a true/false statement, i used the C0, C1, C2 functions.  Works well and easier to use in cases like this.
737 Junkie

fordgt40

Rob

You are correct. It was just that I started off trying to keep to roughly the same logic as Justin had used. It did not work :(

The road to hell is paved with good intentions :)

David

dc8flightdeck

David,
It works perfect! Bingo! I think interfacing the overhead has made the engine start become the most interesting part of the 737 project.

Im happy I can use only one output controlled all three generator switches. Below is how the script looks as I used it.


Var 300 Value 0
{
   &check_state = 0
   &check_state = TIMER 1 0 5
}

var 301 name gen1AC, Link FSUIPC_INOUT, Offset $3B7C, Length 4     // GENERATOR 1 STATUS
var 302 name gen2AC, Link FSUIPC_INOUT, Offset $3ABC, Length 4     // GENERATOR 2 STATUS
var 303 name gen3AC, Link FSUIPC_INOUT, Offset $0B52, Length 1    //  APU generator active flag
var 304 name relayAC, Link IOCARD_OUT, Output 01     // Master AC relay K1

var 305 name check_state link subrutine
{
IF &gen1AC = 0
     {
      IF &gen2AC = 0
            {
            IF &gen3AC = 0
              {
                 &relayAC = 1
               }
   ELSE
      {
      &relayAC = 0
      }


          }
   ELSE
      {
      &relayAC = 0
      }
   }

ELSE
      {
       &relayAC = 0
      }
}

Like the Website ?
Support Cockpitbuilders.com and Click Below to Donate