Page 1 of 6 12345 ... LastLast
Results 1 to 10 of 55
  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

    Scaling Localiser and Glideslope Needles for HSI

    Hi everyone,

    After the completion of the code for the range counter (thanks so much Nico!!!), I have just two final things left to do (in terms of motors) on my HSI Unit.

    These two things are the Localiser and Glideslope Needles.

    Unfortunately, I have had a hard time thinking of a way to scale these two needles. They are both driven by a standard DC motor controlled by the USBDCMotors Card. These Motors are then on the same shaft as a potentiometer which provides feedback for the position of the needles.

    The reason it is hard for me to scale them is for two reasons:

    - Firstly, they are not controlled by the USBServos Card, but by the Motors card. This means that I cannot provide precision needle control directly through SIOC. I must use a calculation based on the potentiometer position.

    - Secondly, the "0" point of the needles are not "0" potentiometer value. This is obvious, because what exactly is the "0" point? The lowest point, or the middle? Furthermore, the localiser and glideslope needles pass both forward and backwards from a central point, so I must take this into account.

    I previous developed a script for my Course pointer, but it is rather inefficient (30,000 lines of code for the full 360 degrees). Also, this script cannot provide the backward and forward motion required by a localiser or glideslope.

    If you have any ideas on what particular methods/calculations I can use to script these needles, it would be most appreciated.

    Kindest regards,

    Jack

  2. #2
    500+ This must be a daytime job



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Scaling Localiser and Glideslope Needles for HSI

    Jack

    The OC card only has 8 bit resolution, hence your difficulty in getting consistent accuracy. Why not try the Leo Bodnar card which you can still interface with SIOC through a FSUIPC offset and use a quality pot. See this link

    http://www.mycockpit.org/forums/show...ht=#post114560

    Re the coding, I think that you need to write out the sequence of what you want to achieve and then try to code it. There is no shining light of truth, just logic and hard work

    Confucius, he say, longest journey starts with first step. Honestly, try to break down the elements of the problem and match that against the commands available in SIOC to develop a solution. Doubtless your 30,000 lines of code on the earlier exercise could be condensed considerably by using a subroutine and passing the changing arguments to it. You have learnt a lot on your last exercise with Nico, so go for it

    Regards

    David

  3. Thanks kiek thanked for this post
  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: Scaling Localiser and Glideslope Needles for HSI

    Hi David,

    My problem is the actual difference between the potentiometer values and the FSUIPC Offset values.

    Regardless of any sort of scripting logic, the first obstacle is that when the Offset reads 0, the Pot reads 57. As you know, there is no number that you can divide a positive integer by to get 0.

    Previously, in the CRS thread, I manually assigned each potentiometer value to an FSUIPC value. I am looking for a way to assign/match/"scale" these values in a single calculation, not by doing it one-by-one.

    I have, however, done as you said. The principals of the logic are as follows:

    - If X is GREATER than Y, the motor moves backwards

    - If X is SMALLER than Y, the motor moves forwards

    - If X = Y, then the motor stops

    (Where X = Offset and Y = Pot)

    As you can see, it is quite a simple logic. However, we meet a massive problem in the fact that the FSUIPC Localiser offset ranges from -117 to +117. This means that SIOC will think that X is greater than Y when it is infact smaller, and vice versa, because the Offset value both grows and shrinks when approaching the 0 (centre) mark.

    I'm sorry if that is confusing, but I hope you could understand the general jist.

    Regards,

    Jack

  5. #4
    500+ This must be a daytime job



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Scaling Localiser and Glideslope Needles for HSI

    Jack

    Probably too simplistic but based on your logic flow

    Offset value of 0 is same position as pot reading 57

    If X is GREATER than Y + 57, the motor moves backwards

    - If X is SMALLER than Y + 57, the motor moves forwards

    - If X = Y + 57, then the motor stops

    (Where X = Offset and Y = Pot)



    "As you can see, it is quite a simple logic. However, we meet a massive problem in the fact that the FSUIPC Localiser offset ranges from -117 to +117. This means that SIOC will think that X is greater than Y when it is infact smaller, and vice versa, because the Offset value both grows and shrinks when approaching the 0 (centre) mark".

    Why not do a test for a negative offset value, if so, then use the ABS function to make it positive and code the movement accordingly to recognise that it is negative
    If the offset value is positive then code it as a normal positive value

    This is based on limited knowledge of your problem but hopefully is a "starter for ten"

    Regards

    David

  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: Scaling Localiser and Glideslope Needles for HSI

    Hi David,

    Great idea about the +57; that's the type of scaling advice I am looking for.

    One thing: for every "FSX" degree the pot will move approx 2 values. This is because the pot ranges approximately from about 1-57-110, whilst the FSUIPC Offset has a greater range. This means that, as a ratio, the pot moves more than the FSX.

    Regards,

    Jack

  7. #6
    500+ This must be a daytime job



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Scaling Localiser and Glideslope Needles for HSI

    Quote Originally Posted by Boeing 747 Flyer View Post
    Hi David,

    One thing: for every "FSX" degree the pot will move approx 2 values. This is because the pot ranges approximately from about 1-57-110, whilst the FSUIPC Offset has a greater range. This means that, as a ratio, the pot moves more than the FSX.
    Jack

    So scale it the same way you would with a servo.

    Programming in SIOC is not rocket science, it is about finding a way to use the available tools. You should now have sufficient knowledge and experience to take this to the next stage and impress Nico

    Regards

    David

  8. #7
    10+ Posting Member
    Join Date
    Apr 2007
    Location
    SC
    Posts
    14
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Scaling Localiser and Glideslope Needles for HSI

    Jack... If u can plot the output then you can derive an equation for a line through that output... May well be non linear.. Or you might need two or three equations to represent two or three differing data zones... Just thinking out loud...

    But I have no idea the constraints of SOIC...

  9. #8
    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: Scaling Localiser and Glideslope Needles for HSI

    Hi David,

    This was the data I collected:

    Code:
    MOTOR:
    
    Top = 171
    
    1st Dot = 161
    
    2nd Dot = 148
    
    Middle Line = 130
    
    3rd Dot = 119
    
    4th Dot = 103
    
    Bottom = 97
    
    ////////////////
    
    FSX:
    
    Top = 138
    
    1st Dot = 
    
    2nd Dot = 
    
    Middle Line = 254
    
    3rd Dot = 
    
    4th Dot = 
    
    Bottom = 119
    
    The FSX GS needle moves from 138 (TOP) to 254 (MIDDLE). The next value after 254 is 0, and it starts counting up again from 0.
    
    138 -> 254 -> 0 -> 119
    The MOTOR results are the potentiometer readings for my GS needle. The FSX results are what SIOC reads when the FSX GS needle is at various points (namely middle, top and bottom).

    My GS needle has 4 dots, and the FSX one has just 2. So, I am thinking of just using the top, middle and bottom results from both readings as these are the only ones that are common.

    As you can see, the FSX needle resets to 0 at the middle, so I need to make the top value (13 slowly increase linearly from top to bottom.

    What I mean is, instead of,

    138 -> 254 -> 0 -> 119

    This:

    138 -> 254 -> 255 -> 373

    As you can see, the second value goes up equally. The first resets to 0, which will make the scaling much more difficult.

    I am wondering how to achieve such a goal. Unfortunately it's not a simple case of adding a number.

    Regards,

    Jack

  10. #9
    500+ This must be a daytime job



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Scaling Localiser and Glideslope Needles for HSI

    Jack

    This is a moving feast

    You say

    "As you can see, it is quite a simple logic. However, we meet a massive problem in the fact that the FSUIPC Localiser offset ranges from -117 to +117"

    Now you say that the FSX values go from 138 to 254 and then count back up again to 119" that is different but not insurmountable.

    I suggest, again, that you write out the logic in simple text of what you want to happen ie

    Read FSX value
    Is FSX value more than 138 and less than 254
    If yes then we are in stage 1

    Else we are in stage 2

    Stage 1 move motor to ??
    How? work out ramping to match scale
    Is the scaling linear ie Do we need one ramp or do we need more
    Move motor
    Have we got there yet yes or no
    if no then repeat

    Stage 2 move motor to ??
    How? work out ramping etc etc

    Just initial crude first thoughts, but ESSENTIAL for you to solve this. Break down the problem into little units, test, amend etc etc.

    Try this, it is not as difficult as you may think.

    Regards

    David

  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: Scaling Localiser and Glideslope Needles for HSI

    Hi David,

    I have had a go and this is the fruit of my labour for the scaling.

    Please note, I am scaling the glideslope needle first, not the localiser:

    Code:
    Var 100 link FSUIPC_IN Length 1 Offset $023A   // seconds of FS time  (0 - 59)
    {
     CALL &Value_Calc
     CALL &Position // Call our variables that control the motor
    }
    
    Var 0005, name GS, Link FSUIPC_IN, Offset $0C49, Length 1 // FSUIPC GS Source
    
    Var 30, name Calc // Calculation holding variable
    
    Var 58, name Pot, Link USB_ANALOGIC, Input 2, PosL 0, PosC 127, PosR 250 // Potentiometer
    
    Var 3, name Value_Calc, Link SUBRUTINE // Provides a scale between GS and Pot
    {
     L0 = &Pot - &GS
     &Calc = L0 + &Pot
    }
    
    Var 0001, name Motor_1, Link USB_DCMOTOR, Output 1 // Motor
    
    Var 0002, name Position, Link SUBRUTINE // The Calculations for driving the motor
    {
     IF &GS >= 138
     {
      IF &GS <= 254
      {
       IF &Calc > &GS
       {
        &Motor_1 = 120
       }
       ELSE
        {
         IF &Calc < &GS
         {
          &Motor_1 = 250
         }
          ELSE
          {
           IF &Calc = &GS
           {
            &Motor_1 = 128
           }
          }
        }
      }
     }
    }
    As you can see, the variable "Calc" holds the value that "translates" between the FSX and Potentiometer values.

    This is for STAGE 1 ONLY, ie from the top to middle.

    Regards,

    Jack

Page 1 of 6 12345 ... LastLast