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 Convert Pitch/Roll (Radians) to motions

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by PhillyNJ, May 28, 2024.

  1. PhillyNJ

    PhillyNJ New Member

    Joined:
    Mar 17, 2024
    Messages:
    26
    Balance:
    121Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Hi,

    I am nearing completion of my 2DoF. To control the motors, I am using an Arduino with SMC3. My rig is designed for FS2020 and I am writing my own application to acquire the telemetry data and send the serial commands to SMC3 to move the motors. I have successfully written several applications that interact FS2020 so this part is pretty much done. However, I am stuck trying to convert the Pitch and Roll data, which is in Radians to a value that moves the motors. I have searched high and low and coming up empty.

    The SMC3 expects values from 0 - 1024. Although, SMC3 accepts this range, I will limit this range that meets my sims limits [e.g. 100-800],

    How do I convert the Pitch and Roll radians to a value between 0-1024 that makes sense?
  2. Sebastian2

    Sebastian2 Member Gold Contributor

    Joined:
    Dec 17, 2023
    Messages:
    63
    Balance:
    204Coins
    Ratings:
    +41 / 0 / -0
    Lets do a example for roll.

    The seat of your rig has a maximum roll angle. Unless you do aerobatics, a GA plane will typically not exceed roll angles of 20...30 degrees. Of course this depends on your flying style, but you'll have to pick a number. For this example lets go with 20 degrees.

    If you want to do aerobatics, do barrel rolls or loops, or want to fly fighter jets and do aggressive maneuvers, stuff gets more complicated. For now, lets stick to cessna, airbus and their typical flying styles.

    Now you'll map 800 (the upper limit you've chosen for your rig) to 20 degrees and 100 to (the lower limit you've chosen foe your rig) to -20 degrees. Just linear interpolation in between. 0 degrees should result in 100+(800-100)/2=450.

    Hope this helps?
  3. PhillyNJ

    PhillyNJ New Member

    Joined:
    Mar 17, 2024
    Messages:
    26
    Balance:
    121Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Yes it does! This is a great explanation and much appreciated! This is will work for pitch and roll, however I have one more question.

    Suppose I calculate Pitch equals x, Roll equals y. How are the 2 values combined for the motor input? Is it a arbitrary percentage that I set? For example, say 20% pitch and 80% roll?
  4. Sebastian2

    Sebastian2 Member Gold Contributor

    Joined:
    Dec 17, 2023
    Messages:
    63
    Balance:
    204Coins
    Ratings:
    +41 / 0 / -0
    Oh and i forgot to mention that there needs to be some kind of cut-off, so that any plane roll angle larger than 20 degree does not further increase the seat roll angle. So 25 degrees would still result in an output of 800.

    ---

    You are right, mixing roll and pitch makes it necessary to make more decisions: how to split the motor range between roll and pitch.

    As a first step you might want the maximum plane roll angle equally large as the maximum plane pitch angle, namely 20 degrees. Any roll or pitch angles larger than that won't affect the seat.

    Another thing: in GA aircraft, you either take relativley steep dive or make a relativley hard roll. It hardly happens that you do both at the same time.
    To make use of that, you could decide that you want to "over-allocate" your motor axis by a factor of 1,5.

    You said your output range is 800-100=700 wide, so in the hypothetical case of 20 degree pitch and 20 degree roll you'd want an output of 100+700*1,5=1150 (which will be clipped to 800). So your unclipped output range is 1150-100=1050. As mentioned above, you'd want to split this equally between pitch and roll, so each DOF has a range of 1050/2 = 525.

    So you linearily map +/-20 degree pitch angle to 0...525 output value and do the same for roll. Notice how mixing DOFs reduces maximum seat angle? We tried to soften the blow with axis over-allocation but there is still some serious impact.
    Anyway, now you've got your roll and pitch output value.

    Then you calculate the actual motor output value by going 100+(<pitch-output-value>+/-<roll-output-value>)/<over-allocation-factor>. The +/- depends on which motor you are calculating the value for (they move in opposite directions for roll).

    I hope this makes sense and I didn't make a mistake trying to help you re-inventing the wheel.

    Edit: looking at it, my suggestions regarding the implementation of axis over allocation doesn't really work as intended. Best you assume factor 1,0 until you or someone else comes up with a better suggestion than mine.
    Last edited: May 29, 2024
  5. PhillyNJ

    PhillyNJ New Member

    Joined:
    Mar 17, 2024
    Messages:
    26
    Balance:
    121Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Thank you again for all the help. This is some good information. As for over allocation and splitting pitch and roll for each motor, my plan is to do a lot of testing based on your suggestions. I started building the app which is configurable in order to test different settings. In the end, I am limited to 2 degrees of freedom and its limitations. However, I am confident I'll find the sweet spot.

    Thanks again.
  6. PhillyNJ

    PhillyNJ New Member

    Joined:
    Mar 17, 2024
    Messages:
    26
    Balance:
    121Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    I just wanted to following a provide the solution that I was able to come up with. As this is a work in progress, I might have to tweak it, but here is some high level code:

    // find the mid point of the motors range
    var mid = ((this.trackBarMaxMotorRange.Value - this.trackBarMinMotorRange.Value)/2) + this.trackBarMinMotorRange.Value;

    // calculate how much to move from the mid point
    var pitchMovement = this.trackBarPitch.Value - mid;
    var rollMovement = (this.trackBarRoll.Value - mid);

    // set the pitch
    this._motor1 = (mid - pitchMovement);
    this._motor2 = mid + pitchMovement;
    // update the roll
    this._motor2 -= rollMovement;
    this._motor1 -= rollMovement;

    This is just the basic settings. There is logic added to clip the motors to make sure I don't exceed the motors range. My preliminary testing looks promising