1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Question Axis plugin. Offset % How to calculate?

Discussion in 'SimTools Pro & Entertainment Version' started by Trigen, Sep 8, 2019.

  1. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Hello

    Im trying to make this work so i can set an offset for where a force starts or stops working.

    What im experiencing is that i need to keep a force to 100% to use 0-1 and the decimals within. If i set 30% on the heave and 40% for the offset it wont work even though it should give a value of 0.4.

    Im quite sure i need to convert lets say 30% for the heave here and turn that number into a 100% range for the TL offset.

    It will also need a flip value for code that needs 40% to be -0.4 or whichever number that will be after the conversion as an example

    Id appreciate any help for the code

    Code:
                    'DOF3
                    Select Case ._Axis1DOF3
                        Case "-"
                            Axis1_Value3_Out = 0
                            Axis1_TL_Offset = 0
                        Case "Heave"
                            'Get percent used for DOF
                            Axis1_Value3_Out = _Heave_Input * (._Axis1PER3 * 0.01)
                            Axis1_TL_Offset = ._Snap_TL_Upper_per * 0.01
                            'OffsetDiv = (Axis1_Value3_Out / Axis1_TL_Offset) * 100
                            'finalnr = OffsetDiv * 0.01
                            'Flip if necessary
                            If ._Axis1DIR3 = True Then
                                Axis1_Value3_Out = Axis1_Value3_Out * -1
                            End If
                            If Axis1_Value3_Out > 0.8 Then
                                Axis1_Value3_Out = Axis1_Value3_Out * 0
    
    offsets.png
    Last edited: Sep 8, 2019
  2. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,133
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    47,907Coins
    Ratings:
    +5,027 / 16 / -0
    This sounds like a dead zone and boundary filter?
  3. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Depends on the definition of a DZ, in the normal sense then no. A DZ is just a narrow band in the middle to remove minor forces in the center (depending on where the flap is) which is why it has been limited to 10% in the software. For the boundary, yes. It will stop it at X%

    Its an offset to where the force should start at.
    What the main thin and usage is that it is taking the traction loss (using heave for testing here) and slamming it to 0 (or continue as normal) once it passes a threshold of say 80% This way it will not lower the flap in the G seat until it reaches it.

    The calculations would be the same for both just in the opposite way though as far as i know. It just needs converting the first 80 of DOF to be 100% range for the offset.
    Last edited: Sep 8, 2019
  4. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,133
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    47,907Coins
    Ratings:
    +5,027 / 16 / -0
    This is how the DeadZone works thou?
  5. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Its an offset, not a DZ ;)
    DZ in Simtools is a max 10% that works from any given point to reduce spiking etc. Just think of it as a boundary in reverse.

    In any case if you dont mind just ignore all this and help me out with the conversion. I got it working as i wish i just need the conversion.
    Last edited: Sep 9, 2019
  6. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,133
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    47,907Coins
    Ratings:
    +5,027 / 16 / -0
    I don't understand what your doing different than the dead zone filter does is all.
    So I thought I would jump in the conversation to see if i could help.
  7. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Got ya and i appreciate it but sometimes i just want a straight answer to what question i'm actually asking. Im pretty sure you know the answer to this one ;)

    Ill explain this in detail
    DZ 0-10% from any given point the axis is at, agree? Could be wrong but I can't do anything with 10 and I've asked about this In relation to traction loss before.
    Boundary 0-100% works from to X% point
    Offset 0-100% Force does not work until X% if you set it to 50% it will not do anything for the first half of the axis.

    In my case a G seat. Sway raises the axis, Traction loss lowers it. Simplified i set both to 50% and they will cancel each other out. Now i dont want Traction loss to have any effect for the first 80% (80% of 50)so it does not interfere with sway. If i then offset Traction loss offset to 80% or 0.8 (it needs -0.8) in the code then it will accomplish this.

    Code:
                    'DOF4 Traction loss
                    Select Case "Extra1"
                        Case "-"
                            Axis1_Value4_Out = 0
                            Axis1_TL_Offset = 0
                        Case "Extra1"
                            'Get percent used for DOF
                            Axis1_Value4_Out = _Extra1_Input * (._Axis1PER4 * 0.01)
                            'Flip if necessary
                            If ._Axis6DIR3 = True Then
                                Axis1_Value4_Out = Axis1_Value4_Out * -1
                            End If
                            ' get offset for Traction loss
                            Axis1_TL_Offset = _Extra1_Input * (._Snap_TL_Upper_per * 0.01) ' not usin this at the moment
                            ' Tune for kick at snapout or overall feel
                            If ._Snap_TL = True And Axis1_Value4_Out > -0.8 Then
                                Axis1_Value4_Out = Axis1_Value4_Out * 0
                            End If
                            If ._Snap_TL = False And Axis1_Value4_Out > 0 Then
                                Axis1_Value4_Out = Axis1_Value4_Out * 0
                            End If
    
    
    Last edited: Sep 9, 2019
  8. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    And just for arguments sake I don't have access to any filter code, just the example 3 dof code. also for dz and maybe we are talking past each other I have to think within the bounds of how it's set in the current Simtools but technically dz if as on a joystick then it would be fine
    Last edited: Sep 9, 2019
  9. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    5,133
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    47,907Coins
    Ratings:
    +5,027 / 16 / -0
    If you want help with code, you need to give people a chance to understand what you trying to do and or need.

    Which is why I was trying to figure out what you needed. :thumbs

    Yes, its the same.
    You would just need to modify the percentage it allows is all.

    Code:
     
    #Region "DeadZone"
        '~~~~~~~~~~~~ Deadzone ~~~~~~~~~~~~
        Private DeadZone_Axis As Double = 0
        Public Function DeadZone(InputValue As Double, DeadZoneValue As Integer) As Double
            If DeadZoneValue = 0 Then
                'Return InputValue
                Return InputValue
            Else
                If InputValue < DeadZone_Axis - (DeadZoneValue * 0.00001) Then
                    'compute outputs   
                    DeadZone_Axis = DeadZone_Axis + (InputValue - (DeadZone_Axis - (DeadZoneValue * 0.00001)))
                    'keep in range
                    If DeadZone_Axis < -1 Then
                        DeadZone_Axis = -1
                    End If
                ElseIf InputValue > DeadZone_Axis + (DeadZoneValue * 0.00001) Then
                    'compute outputs 
                    DeadZone_Axis = DeadZone_Axis + (InputValue - (DeadZone_Axis + (DeadZoneValue * 0.00001)))
                    'keep in range
                    If DeadZone_Axis > 1 Then
                        DeadZone_Axis = 1
                    End If
                End If
            End If
    
            'Return rescalled InputValue
            Return DeadZone_Axis + (DeadZone_Axis * (DeadZoneValue * 0.00002))
        End Function
    #End Region
    Take care,
    yobuddy
    • Informative Informative x 2
  10. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Thank you, appreciate that!

    And yeah, what seems very clear to me may not be for others, lesson learned :)

    Now since i dont know how to use this as a function (can use the code anyway of course) ill have to figure that out. Its good for learning VB
    Last edited: Sep 9, 2019
  11. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    472
    Balance:
    2,826Coins
    Ratings:
    +176 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Ive been testing this a lot (in 2d advanced) and DZ works the way I've described it from the beginning, not the way a joystick does. Its essentially moving the center point . It will give you a DZ of 10% from the point the axis is currently at not only -0.1 to 0.1. It will start at 0 and give you 10%. If it moves instantly to 0.5 it will give you a 10% deadzone again from there. around. Im assuming you ctrl-c-p the code so its the same.

    If the deadzone worked as a normal deadzone you could call it that but It needs the offset or from Simtools rules a reverse boundary

    offset.png

    This is also why (i think) when i move the heave output test slider to the right it works as normal with no DZ but if i move it to the left regardless of what % its at it will kick in and move to 0 from my IF code. I cant actually make it work like it does in the Generic 2d Advanced filters though so i guess something aint quite right. Either way im rather sure it wont work.


    Code:
        Private Axis1_TL_DZ As Integer = 0 ' Traction loss offset
        Private Axis1_TL_final As Double = 0
    
    Code:
                    Select Case ._Axis1DOF3
                        Case "-"
                            Axis1_Value3_Out = 0
                            Axis1_TL_DZ = 0
                            Axis1_TL_final = 0
                        Case "Heave"
                            'Get percent used for DOF
                            Axis1_Value3_Out = _Heave_Input * (._Axis1PER3 * 0.01)
                            Axis1_TL_DZ = ._Snap_TL_Upper_per
                            Axis1_TL_final = DeadZone(Axis1_Value3_Out, Axis1_TL_DZ)
                            'Flip if necessary
                            If ._Axis1DIR3 = True Then
                                Axis1_TL_final = Axis1_TL_final * -1
                            End If
                            If Axis1_Value3_Out < Axis1_TL_final Then
                                Axis1_Value3_Out = Axis1_Value3_Out * 0
                            End If
    
    
    Last edited: Sep 9, 2019