Page 1 of 7 12345 ... LastLast
Results 1 to 10 of 69
  1. #1
    500+ This must be a daytime job Boeing 747 Flyer's Avatar
    Join Date
    Nov 2009
    Location
    England
    Posts
    635
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    HSI Pulse Range Counter Display - How to manipulate in SIOC?

    Hi everyone,

    Whilst I have, for now, gotten the flags and course pointer on my HSI to work (there's still the remaining motors left though!), I'm currently working on a logic for the HSI pulse counter.

    Basically, my HSI display works like a heartbeat. I have an "engage pin" connected to the display, and when 5V is going to this pin, I send pulses (ON/OFF/ON/OFF) to the display.

    Each routine of OFF/ON/OFF counts as one pulse, and counts the display up by 1.

    Previously, I have been using Nico's LED blink script to simulate this, executed by a button press.

    Obviously, I cannot rely on this alone, as in FSX, this value is changed by the disstance from the VOR1 station (tuned).

    My friend Mikael Stockfors has very kindly designed a logic for the range display, which certainly looks like it could work. Please analyse the logic (NOTE, is is NOT formatted to work with SIOC yet, it is just a visual draft to show how things work):

    Code:
    "VAR 1, name CurrentDistance"
    "VAR 2, name NewDistance, LINK (FSUIPC output source)"
    {                                                                                                         
            L0 = NewDistance - CurrentDistance;    
                                                                                                             
            IF L0 > 0 THEN
            {                                                                                              
                 Set output to make counter count UP;     // Pulses make the counter go UP      
                 NoPulses = L0;                                       
            }
             ELSE
            {                                                                                          
                Set output to make counter cound DOWN;    // Same technique, except the pulses count DOWN, due to an
                                                                                // extra pin which can change the UP to a DOWN count
                NoPulses = L0                             
                                                                                                         
             }         
                                                                                                    
             Send NoPulses to the range display;       // One pulse = 1 digit count           
                                                                                                        
             CurrentDistance = NewDistance;                         
                                                                                                       
    }
    My question is, how can I accurately control the number of pulses outputted by SIOC, and is there a better way than just using an LED blink script? EG, if I want 5 pulses, I just want to send 5 pulses straight to the display. Is there a better way to achieve this goal?

    Kindest regards,

    Jack

  2. Thanks 737NUT thanked for this post
  3. #2
    500+ This must be a daytime job kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    698
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?

    Jack,
    What is the "length" of one pulse? I mean, how many milli seconds do you need for each cycle? Or in other words: the time between two ON's ?

    Nico

  4. #3
    500+ This must be a daytime job Boeing 747 Flyer's Avatar
    Join Date
    Nov 2009
    Location
    England
    Posts
    635
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?

    Hi Nico,

    I think 100 milli-secs would do (that's 10 pulses per second).

    Kindest regards,

    Jack

  5. #4
    500+ This must be a daytime job kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    698
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?

    Hi Jack,
    I have not checked this code, i'm not sure whether SIOC allows recursive calls of subroutines, but I don't see why not.

    The idea is to call the subroutine Pulses with the number of pulses that you want to send.
    Code:
    Var 100 name Main
    {
      &Out = 0
      L0 = 3   // 3 is just an example
      CALL &Pulses L0  // generate L0 number of pulses
    }
    
    Var 1 name Pulses link SUBRUTINE    // parameter is number of pulses ...
    {
      &Out = 1
      &PulseDown = DELAY &Pulses 5  // 50 msec for a half pulse
    }
    
    Var 2 name PulseDown
    {
      L0 = &PulseDown
      IF L0 > 0 {
        &Out = 0
        &Finish = DELAY L0 5  // 50 msec for the other half of the pulse
      }
    }
    
    Var 3 name Finish
    {
      L0 = &Finish
      IF L0 > 0
      {
        IF L0 > 1
        {
          L0 = L0 - 1
          CALL &Pulses L0   // recursive subroutine call
        }
        ELSE
        {
          &PulseDown = 0   // make responsive for another series of pulses.
          &Finish = 0      // make responsive for another series of pulses.
        }
      }
    }
    
    Var 4 name Out link ... pulse train here
    An alternative is the TIMER approach. One way or the other you need to build in wait periods in your script. In the example above I do that with the DELAY statement. Note that a SIOC program immediately continues with the statement after the DELAY statement (if present), that's why I needed three different Vars to send a pulse.

    regards,
    Nico
    Last edited by kiek; 05-19-2011 at 03:14 PM.

  6. #5
    500+ This must be a daytime job Boeing 747 Flyer's Avatar
    Join Date
    Nov 2009
    Location
    England
    Posts
    635
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?

    Hi Nico,

    That is superb! Thanks so much! Thanks for helping me out at such short notice; it is really fantastic =).

    It is 11:00PM here, so I shall double-check the code tomorrow. However, I have read through it and can understand how it works. The line "L0 = 3"; as you say 3 is an example. As "3" could theoretically be any number, wouldn't it be better to make L0 equal to another variable specifically designed for the pulse value (ie L0 = X, where X is the number of pulses).

    Thank you so much, I am so grateful for your help.

    Regards,

    Jack

  7. #6
    500+ This must be a daytime job kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    698
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?

    Jack,
    Like I said, L0 = 3 is just an example. L0 = &NoPulses is also possible.

    If this subroutine works you should also be careful not to call it too often because sending a large number of pulses would take some time.

    Maybe you should use the endless timer approach. In the control routine you check the NewDistance - CurrentDistance and act accordingly. If the number of pulses to be sent is too much for the control cycle period, you maximise the amount to what is possible and take care of the rest in the next control cycle.

    regards,
    Nico
    Last edited by kiek; 05-19-2011 at 06:21 AM.

  8. #7
    500+ This must be a daytime job Boeing 747 Flyer's Avatar
    Join Date
    Nov 2009
    Location
    England
    Posts
    635
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?

    Hi Nico,

    I shall consider the endless timer approach should we need to use it for the range display in the future.

    I have now taken your script, replaced "3" with NoPulses.

    Firstly, this is the script that calculates NoPulses (all finished now):

    Code:
    Var 1, name CurrentDistance
    
    Var 4, name NoPulses
    
    Var 3, name UP_Pin, Link IOCARDS_OUT, Output X
    
    Var 5, name DOWN_Pin, Link IOCARDS_OUT, Output X
    
    Var 2, name NewDistance, Link FSUIPC_IN, Offset $0300, Length 2  // FSUIPC VOR1 DME Input Source
    {                                                                                                         
     L0 = NewDistance - CurrentDistance                                                                         
     IF L0 > 0 THEN
     {  
      &DOWN_Pin = 0 // Ensure down pin is OFF                                                                                            
      &UP_Pin = 1 // Pulses make the counter go UP      
      NoPulses = L0                                      
     }
       ELSE
       {                                                                                          
        &UP_Pin = 0 // We don't want to count up here!
        &DOWN_Pin = 1// ...But we need to count down, so DOWN pin is ON
        &NoPulses = L0 * -1                           
       }                                                                                                                     
        CurrentDistance = NewDistance                                                                                                                          
    }
    Please note: The "Up" and "Down" pins are extra outputs that must be activated in order to provide a pulse. They receive no actual pulses themselves and don't do anything else.

    This is your script, adapted slightly to work with the above:

    Code:
    Var 100 name Main
    {
      &Out = 0
      L0 = NoPulses   // 3 is just an example
      CALL &Pulses L0  // generate L0 number of pulses
    }
    
    Var 1 name Pulses link SUBROUTINE    // parameter is number of pulses ...
    {
      &Out = 1
      &PulseDown = DELAY &Pulses 5  // 50 msec for a half pulse
    }
    
    Var 2 name PulseDown
    {
      L0 = &PulseDown
      IF L0 > 0 
     {
        &Out = 0
        &Finish = DELAY &PulseDown 5  // 50 msec for the other half of the pulse
     }
    }
    
    Var 3 name Finish
    {
      L0 = &Finish
      IF L0 > 0
      {
        IF L0 > 1
        {
          L0 = L0 - 1
          CALL &Pulses L0   // recursive subroutine call
        }
        ELSE
        {
          &PulseDown = 0   // make responsive for another series of pulses.
          &Finish = 0      // make responsive for another series of pulses.
        }
      }
    }
    
    Var 4, name &Out, Link IOCARDS_OUT, Output X
    Obviously, the "X"s in each script will be replaced with a correct working output number.

    So, as it stands, can you see any obvious errors? I just use the first to calculate the pulses, and your script to send them.

    At the moment, the script(s) don't cater for when you loose the VOR1 signal or something else like that happens; but that's okay for now, it's just a test.

    Thanks very much for your time.

    Kindest regards,

    Jack

  9. #8
    500+ This must be a daytime job kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    698
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?

    Hi Jack,

    I think it is better to integrate the two scripts.
    We need a Var 0 with some initialisations, and in the NewDistance var we have to call the Pulses subroutine.
    In this example there is no need for a NoPulses variable.

    Maybe you should test this first. I'm not sure about the value in FSUIPC offset 0x0300, the documentation says nm * 10 ...
    Let's see what happens.

    Code:
    Var 0 Value 0
    {
      &Out = 0
      &CurrentDistance = 0   // ??
    }
    
    Var 1, name CurrentDistance
    
    Var 2, name UP_Pin, Link IOCARDS_OUT, Output X
    
    Var 3, name DOWN_Pin, Link IOCARDS_OUT, Output X
    
    Var 4, name &Out, Link IOCARDS_OUT, Output X
    
    Var 5, name NewDistance, Link FSUIPC_IN, Offset $0300, Length 2  // FSUIPC VOR1 DME Input Source
    {                                                                                                         
      L0 = &NewDistance - &CurrentDistance                                                                         
      &CurrentDistance = &NewDistance  
      IF L0 <> 0 
      {                                                                                                                       
        IF L0 > 0 
        {  
          &DOWN_Pin = 0  // Ensure down pin is OFF                                                                                            
          &UP_Pin = 1    // Pulses make the counter go UP      
        }
        ELSE
        {                                                                                          
          &UP_Pin = 0    // We don't want to count up here!
          &DOWN_Pin = 1  // ...But we need to count down, so DOWN pin is ON
          L0 = L0 * -1
        }
        CALL &Pulses L0                           
      }                                                                                                                     
    }
    
    Var 10 name Pulses link SUBRUTINE    // parameter is number of pulses ...
    {
      &Out = 1
      &PulseDown = DELAY &Pulses 5  // 50 msec for a half pulse
    }
    
    Var 11 name PulseDown
    {
      L0 = &PulseDown
      IF L0 > 0 
     {
        &Out = 0
        &Finish = DELAY L0  5  // 50 msec for the other half of the pulse
     }
    }
    
    Var 12 name Finish
    {
      L0 = &Finish
      IF L0 > 0
      {
        IF L0 > 1
        {
          L0 = L0 - 1
          CALL &Pulses L0   // recursive subroutine call
        }
        ELSE
        {
          &PulseDown = 0   // make responsive for another series of pulses.
          &Finish = 0      // make responsive for another series of pulses.
        }
      }
    }
    Nico
    Last edited by kiek; 05-19-2011 at 03:15 PM.

  10. #9
    500+ This must be a daytime job kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    698
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?

    Jack,
    Here is the endless timer approach.
    I believe this script is much more robust.

    Code:
    Var 0 Value 0
    {
      &Out = 0
      &CurrentDistance = 0   
      &Control = 0
      &Control = TIMER 1 0 100   // control is called each second
    }
    
    Var 100 name Control Link SUBRUTINE
    {
      L0 = NewDistance - CurrentDistance                                                                         
      IF L0 <> 0 
      {                                                                                                                       
        IF L0 > 0 
        {  
          &DOWN_Pin = 0  // Ensure down pin is OFF                                                                                            
          &UP_Pin = 1    // Pulses make the counter go UP  
          IF L0 > 9
          {
            L0 = 9  // no more then 9 pulses per second
            &CurrentDistance = &CurrentDistance  + 9
          } 
          ELSE
          {
            &CurrentDistance = &NewDistance
          }  
        }
        ELSE
        {                                                                                          
          &UP_Pin = 0    // We don't want to count up here!
          &DOWN_Pin = 1  // ...But we need to count down, so DOWN pin is ON
          L0 = L0 * -1
          IF L0 > 9
          {
            L0 = 9  // no more then 9 pulses per second
            &CurrentDistance = &CurrentDistance  - 9
          } 
          ELSE
          {
            &CurrentDistance = &NewDistance
          }  
        }
        CALL &Pulses L0                           
      }                                                                                                                     
    }
    
    Var 1, name CurrentDistance
    
    Var 2, name UP_Pin, Link IOCARDS_OUT, Output X
    
    Var 3, name DOWN_Pin, Link IOCARDS_OUT, Output X
    
    Var 4, name Out, Link IOCARDS_OUT, Output X
    
    Var 5, name NewDistance, Link FSUIPC_IN, Offset $0300, Length 2  // FSUIPC VOR1 DME Input Source
    
    Var 10 name Pulses link SUBRUTINE    // parameter is number of pulses ...
    {
      &Out = 1
      &PulseDown = DELAY &Pulses 5  // 50 msec for a half pulse
    }
    
    Var 11 name PulseDown
    {
      L0 = &PulseDown
      IF L0 > 0 
      {
        &Out = 0
        &Finish = DELAY L0 5  // 50 msec for the other half of the pulse
      }
    }
    
    Var 12 name Finish
    {
      L0 = &Finish
      IF L0 > 0
      {
        IF L0 > 1
        {
          L0 = L0 - 1
          CALL &Pulses L0   // recursive subroutine call
        }
        ELSE
        {
          &PulseDown = 0   // make responsive for another series of pulses.
          &Finish = 0      // make responsive for another series of pulses.
        }
      }
    }
    Nico
    Last edited by kiek; 05-19-2011 at 03:14 PM.

  11. #10
    500+ This must be a daytime job Boeing 747 Flyer's Avatar
    Join Date
    Nov 2009
    Location
    England
    Posts
    635
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: HSI Pulse Range Counter Display - How to manipulate in SIOC?

    Hi Nico,

    Thanks so much for your help, I'll try the endless timer script (hopefully tonight).

    About the Offset * 10...

    At first, I thought I'd have to divide this offset by 10 to use it "sensibly". However, it turns out the the range display on the HSI as a dot between the 3rd and 4th digits (like a decimal point).

    So, therefore, if I'm 33.3nm away from the station, FSUIPC/SIOC will recognised this as "333" nm, and send 333 pulses. The HSI will then read 333, but because of the DP, it will actually read "33.3".

    See what I mean? Or is it better to leave this out?

    Regards,

    Jack

Page 1 of 7 12345 ... LastLast