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

2DOF simulator servo model

Discussion in 'DIY Motion Simulator Projects' started by Svensson, May 7, 2015.

  1. smallmadtv

    smallmadtv The Astrophotgrapher Gold Contributor

    Joined:
    Dec 23, 2020
    Messages:
    10
    Occupation:
    Tech Manager
    Location:
    Belgium - Sambreville
    Balance:
    100Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, Arduino, 4DOF, 6DOF

    Thnk you for the reply will have a look in more depth to the documentation.
    I can understand the 100% per axis in the game and testing with Roll, pitch, heave... But when I'mdirectly using the axis it shouldn't have any impact.

    Anyway I test it ... :( no change... , I've also reduce the Axis limiting.
    upload_2020-12-27_13-47-10.png

    A testI have already done in the past, but nothing change...
    upload_2020-12-27_13-48-0.png

    all it change is sending the code to the Arduino from 13 to 242 instead of 0 to 255
    90 of 256 is 229-230 so the 90% of the total range242-13=229




    Reading the pdf and tips toseeif I can find something...

    Thank you!
  2. smallmadtv

    smallmadtv The Astrophotgrapher Gold Contributor

    Joined:
    Dec 23, 2020
    Messages:
    10
    Occupation:
    Tech Manager
    Location:
    Belgium - Sambreville
    Balance:
    100Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, Arduino, 4DOF, 6DOF
    Well, I'm using the

    R<Axis1qa>~ based on the code:

    now this one, as it seem towork berter:
    R<Axis1a>R<Axis1a>L<Axis2a>L<Axis2a>F<Axis3a>F<Axis3a>V<Axis4a>V<Axis4a>~*

    Let me do a video to show the jiggle at "-1"

    Regarding the Code, I've edited to:
    - extend to 6dof (but even in 2 dof I've the issue)
    - add a lcd to display some info
    - rework the code to move the motor all in one on '*'

    Code:
    //************************************************************************************************
    // RC Model Servo
    // Original code By EAOROBBIE (Robert Lindsay)
    // Completely mangled by aarondc
    // Reworked by Andy Strappazzon
    // For free use for Sim Tool Motion Software
    //***********************************************************************************************
    
    // LibrairieLCD
    // Ecran LCD
    #include "LiquidCrystal.h"
    LiquidCrystal lcd(3,2,11,10,9,8);
    
    
    #include <Servo.h>
    //#define DEBUG 1                                    // comment out this line to remove debuggin Serial.print lines
    const int kActuatorCount = 6;                       // how many Actuators we are handling
    
    
    
    // the letters ("names") sent from Sim Tools to identify each actuator
    // NB: the order of the letters here determines the order of the remaining constants kPins and kActuatorScale
    // R<Axis1a>~L<Axis2a>~F<Axis3a>~V<Axis4a>~*
    const char kActuatorName[kActuatorCount] = { 'R', 'L', 'F', 'V', 'M', 'N' };   ////'L', 'F', 'V','M','N'
    const int kPins[kActuatorCount] = {4,5,6,7,12,13};                        // pins to which the Actuators are attached 4,5, 6, 7
    const int kActuatorScale[kActuatorCount][2] = { { 179, 0 },         // R Actuator scaling ,
                                                    { 179, 0 },         // L side Actuator scaling
                                                    { 179, 0 },         // F
                                                    { 179, 0 },         // V
                                                    { 179, 0 },         // M
                                                    { 179, 0 }          // N
                                                   };     
    const char kEOL = '~';                                    // End of Line - the delimiter for our acutator values
    const char kESP = '*';                                    // end of Order - Execute positioning
    const int kMaxCharCount = 3;                              // some insurance...
    Servo actuatorSet[kActuatorCount];                        // our array of Actuators
    int actuatorPosition[kActuatorCount] = {90,90,90,90,90,90};     // current Actuator positions, initialised to 90 , 90, 90, 90
    int currentActuator;                                      // keep track of the current Actuator being read in from serial port
    int valueCharCount = 0;                                   // how many value characters have we read (must be less than kMaxCharCount!!
    int dataFromSimtools[kActuatorCount];                     // Data From Simtools live
    
    
    // set up some states for our state machine
    // psReadActuator = next character from serial port tells us the Actuator
    // psReadValue = next 3 characters from serial port tells us the value
    // psEndOfLine
    enum TPortState { psReadActuator, psReadValue, psEndOfLine };   
    TPortState currentState = psReadActuator;
    
    
    // Setup of the system
    void setup()
    {
        // attach the Actuators to the pins
        for (int i = 0; i < kActuatorCount; i++)
            actuatorSet[i].attach(kPins[i]);
        
        // initialise actuator position
        //for (int i = 0; i < kActuatorCount; i++)
            updateActuator(1);
    
        lcd.begin(16,2);    // Initialize the LCD Screen     
        Serial.begin(115200); // opens serial port at a baud rate of 9600
    }
    
    
    
    // Main loop not used
    void loop()
    {
    
    }
    
    
    
    
    
    // this code only runs when we have serial data available. ie (Serial.available() > 0).
    // ------------------------------------------------------------------------------------
    void serialEvent() {
        
        // Initialisation of variables
        //-----------------------------------------------
        char tmpChar;         // Character * or ~  RLVF
        int tmpValue;         // Value
        int oneAtTime;    // avoid multiple instance
    
        
        // Main While on Serial.available
        // -----------------------------
        while (Serial.available()) {
            
            
            // if we're waiting for a Actuator name, grab it here
            //---------------------------------------------------
            if (currentState == psReadActuator) {
                              tmpChar = Serial.read();
                  
                              
                              // look for our actuator in the array of actuator names we set up
                               for (int i = 0; i < kActuatorCount; i++) {
                                                    if (tmpChar == kActuatorName[i]) {
                                              
                                                                currentActuator = i;                        // remember which actuator we found
                                                                currentState = psReadValue;                 // start looking for the Actuator position
                                                                actuatorPosition[currentActuator] = 0;      // initialise the new position
                                                                valueCharCount = 0;                         // initialise number of value chars read in
                                                                break;
                                                    }
                              }
                              // look for our actuator in the array of actuator names we set up
            }
            // if we're waiting for a Actuator name, grab it here
            //---------------------------------------------------
    
    
    
            
            // if we're ready to read in the current Actuator's position data
            // --------------------------------------------------------------
            if (currentState == psReadValue) {
                while ((valueCharCount < kMaxCharCount) && Serial.available()) {
    
    
                    // Step One grab the Serial Message
                    tmpValue = Serial.read();   // read Serial input
                    
                    
                    // If differnet from the  end of line charachter  '~' or end of message '*'
                    // -------------------------------------------------------------------------
                              if ((tmpValue != kEOL)||(tmpValue != kEOL)) {
                              tmpValue = int(tmpValue);
                              dataFromSimtools[currentActuator] = tmpValue;
                              actuatorPosition[currentActuator] = tmpValue;
                              valueCharCount++;                                           
                        
                              }
                  // -----------------------------------------------
                            
                             else break;
                }
                
                              // if we've read the value delimiter, update the Actuator and start looking for the next Actuator name|| valueCharCount == kMaxCharCount
                              if (tmpValue == kEOL ) {
                                          
                                    // Adjust the TempValue to avoid division per Zero
                                    // scale the new position so the value is between 0 and 179   0 255
                                    actuatorPosition[currentActuator] = map(actuatorPosition[currentActuator] -24, 1, 255, kActuatorScale[currentActuator][0], kActuatorScale[currentActuator][1]);
                                    dataFromSimtools[currentActuator] = actuatorPosition[currentActuator];
                              
                              }
    
                              // if we'read the end of Order execute the update of the servo
                              //------------------------------------------------------------
                              if (tmpValue == kESP || valueCharCount == kMaxCharCount) {
                
                                updateActuator(currentActuator);
                                currentState = psReadActuator;
                              }
    
                
            }
        }
    
    
    }
    // ------------------------------------------------------------------------------------
    // ------------------------------------------------------------------------------------
    
    
    // write the current Actuator position to the passed in Actuator
    //--------------------------------------------------------------
    void updateActuator(int thisActuator) {
    
    
    
    
    
                    lcd.setCursor(0,1);
                    lcd.print('R');
                    lcd.print(actuatorPosition[0]);
                    lcd.setCursor(0,0);
                    lcd.print('R');
                    lcd.print(dataFromSimtools[0]);
    
    
    
                    lcd.setCursor(4,1);
                    lcd.print('L');
                    lcd.print(actuatorPosition[1]);
                    lcd.setCursor(4,0);
                    lcd.print('L');
                    lcd.print(dataFromSimtools[1]);
    
                    lcd.setCursor(8,1);
                    lcd.print('F');
                    lcd.print(actuatorPosition[2]);
                    lcd.setCursor(8,0);
                    lcd.print('F');
                    lcd.print(dataFromSimtools[2]);
                    
    
                    lcd.setCursor(12,1);
                    lcd.print('V');
                    lcd.print(actuatorPosition[3]);
                    lcd.setCursor(12,0);
                    lcd.print('V');
                    lcd.print(dataFromSimtools[3]);
                    
                    
        //actuatorSet[thisActuator].write(actuatorPosition[thisActuator]);
        for (int i = 0; i < kActuatorCount; i++)
            actuatorSet[i].write(actuatorPosition[i]);
          
    
    
    }
  3. smallmadtv

    smallmadtv The Astrophotgrapher Gold Contributor

    Joined:
    Dec 23, 2020
    Messages:
    10
    Occupation:
    Tech Manager
    Location:
    Belgium - Sambreville
    Balance:
    100Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, Arduino, 4DOF, 6DOF
    Last edited: Dec 27, 2020
  4. smallmadtv

    smallmadtv The Astrophotgrapher Gold Contributor

    Joined:
    Dec 23, 2020
    Messages:
    10
    Occupation:
    Tech Manager
    Location:
    Belgium - Sambreville
    Balance:
    100Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, Arduino, 4DOF, 6DOF
    I can't believe it!

    An update from my test...

    Ok after multiple investigation, I change arduino for a Mega that I have in my bags...

    And with the original code. I mange to make it work perfectly...

    So I've upgrade to 6dof and try some test...

    Thankx for the massages and help...

    :)
  5. kuky

    kuky New Member

    Joined:
    May 7, 2021
    Messages:
    1
    Balance:
    - 2Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF
    Hello everyone, for the first time, thank you for all this information. I wanted to recreate such a small simulator for myself.
    Unfortunately I don't get any further. I am desperate. Hopefully someone can tell me where my mistake is.

    Did everything according to these instructions. The test software worked and the motors moved as I set it up.
    Code:
    //********************************************************************************************
    // RC Model Servo
    // Original code By EAOROBBIE (Robert Lindsay)
    // Completely mangled by aarondc
    // For free use for Sim Tool Motion Software
    //********************************************************************************************
    #include <Servo.h>
    //#define DEBUG 1                                    // comment out this line to remove debuggin Serial.print lines
    const int kActuatorCount = 2;                       // how many Actuators we are handling
    
    // the letters ("names") sent from Sim Tools to identify each actuator
    // NB: the order of the letters here determines the order of the remaining constants kPins and kActuatorScale
    const char kActuatorName[kActuatorCount] = { 'R', 'L' };
    const int kPins[kActuatorCount] = {4, 5};                       // pins to which the Actuators are attached
    const int kActuatorScale[kActuatorCount][2] = { { 0, 179 } ,    // Right Actuator scaling
                                                    { 179, 0 }      // Left side Actuator scaling
                                                   };     
    const char kEOL = '~';                              // End of Line - the delimiter for our acutator values
    const int kMaxCharCount = 3;                        // some insurance...
    Servo actuatorSet[kActuatorCount];                  // our array of Actuators
    int actuatorPosition[kActuatorCount] = {90, 90};    // current Actuator positions, initialised to 90
    int currentActuator;                                // keep track of the current Actuator being read in from serial port
    int valueCharCount = 0;                             // how many value characters have we read (must be less than kMaxCharCount!!
    
    // set up some states for our state machine
    // psReadActuator = next character from serial port tells us the Actuator
    // psReadValue = next 3 characters from serial port tells us the value
    enum TPortState { psReadActuator, psReadValue };   
    TPortState currentState = psReadActuator;
    
    void setup()
    {
        // attach the Actuators to the pins
        for (int i = 0; i < kActuatorCount; i++)
            actuatorSet[i].attach(kPins[i]);
        
        // initialise actuator position
        for (int i = 0; i < kActuatorCount; i++)
            updateActuator(i);
        
        Serial.begin(9600); // opens serial port at a baud rate of 9600
    }
     
    void loop()
    {
    
    }
    
    // this code only runs when we have serial data available. ie (Serial.available() > 0).
    void serialEvent() {
        char tmpChar;
        int tmpValue;
    
        while (Serial.available()) {
            // if we're waiting for a Actuator name, grab it here
            if (currentState == psReadActuator) {
                tmpChar = Serial.read();
                // look for our actuator in the array of actuator names we set up
    #ifdef DEBUG           
    Serial.print("read in ");           
    Serial.println(tmpChar);           
    #endif
                for (int i = 0; i < kActuatorCount; i++) {
                    if (tmpChar == kActuatorName[i]) {
    #ifdef DEBUG           
    Serial.print("which is actuator ");           
    Serial.println(i);           
    #endif
                        currentActuator = i;                        // remember which actuator we found
                        currentState = psReadValue;                 // start looking for the Actuator position
                        actuatorPosition[currentActuator] = 0;      // initialise the new position
                        valueCharCount = 0;                         // initialise number of value chars read in
                        break;
                    }
                }
            }
            
            // if we're ready to read in the current Actuator's position data
            if (currentState == psReadValue) {
                while ((valueCharCount < kMaxCharCount) && Serial.available()) {
                    tmpValue = Serial.read();
                    if (tmpValue != kEOL) {
                        tmpValue = tmpValue - 48;
                        if ((tmpValue < 0) || (tmpValue > 9)) tmpValue = 0;
                        actuatorPosition[currentActuator] = actuatorPosition[currentActuator] * 10 + tmpValue;
                        valueCharCount++;
                    }
                    else break;
                }
                
                // if we've read the value delimiter, update the Actuator and start looking for the next Actuator name
                if (tmpValue == kEOL || valueCharCount == kMaxCharCount) {
    #ifdef DEBUG           
    Serial.print("read in ");           
    Serial.println(actuatorPosition[currentActuator]);           
    #endif
                    // scale the new position so the value is between 0 and 179
                    actuatorPosition[currentActuator] = map(actuatorPosition[currentActuator], 0, 255, kActuatorScale[currentActuator][0], kActuatorScale[currentActuator][1]);
    #ifdef DEBUG           
    Serial.print("scaled to ");           
    Serial.println(actuatorPosition[currentActuator]);           
    #endif
                    updateActuator(currentActuator);
                    currentState = psReadActuator;
                }
            }
        }
    }
    
    
    // write the current Actuator position to the passed in Actuator
    void updateActuator(int thisActuator) {
        actuatorSet[thisActuator].write(actuatorPosition[thisActuator]);
    }
    b1.png

    b2.png

    b3.png

    at "turn on" the Arduino goes on (LED is ON). but nothing moves ??

    What information is still missing to isolate the problem.

    Or did you already know it. Everyone (YouTube) sets the parameters and the motors move, just not with me.

    Thanks for the help.
  6. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,533
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    145,022Coins
    Ratings:
    +10,776 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    The only thing that obviously looks wrong is your Axis Assignments, The Dir boxes being checked orange or not determines which way each axis moves and the value is how much of the total allocation is assigned.

    This is what SimTools expects: https://www.xsimulator.net/community/faq/which-way-to-set-simtool-axis-movements.230/

    Grab the SimTools Manual and keep it handy for reference: https://www.xsimulator.net/community/faq/rtfm-start-with-the-official-simtools-documentation.117/

    If you set sensible Axis Assignment values, say 25, then configure the Dir for each axis and Save, does Output Testing work?
  7. Joqueson

    Joqueson New Member

    Joined:
    May 5, 2020
    Messages:
    19
    Balance:
    64Coins
    Ratings:
    +2 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN5, SCN6, SimAxe, Arduino, JRK, Joyrider, SimforceGT, Motion platform, 4DOF, 6DOF
    First, I want to congratulate you for the excellent work.
    I am master (Mini Project 3DOF with 3 Micro Servo Motors S9 SG90).
    My goal is to better understand the SIMTOOLS SOFTWARE, so that later I can build a 3DOF Simulator Platform with larger 12Volts or 24Volts Motors.
    I'm a beginner, I need your help for my project.
    I am very grateful for all the help and collaboration.

    Attached Files:

  8. Joqueson

    Joqueson New Member

    Joined:
    May 5, 2020
    Messages:
    19
    Balance:
    64Coins
    Ratings:
    +2 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN5, SCN6, SimAxe, Arduino, JRK, Joyrider, SimforceGT, Motion platform, 4DOF, 6DOF
  9. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,533
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    145,022Coins
    Ratings:
    +10,776 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Nice job :thumbs

    A working model is a great way to explore design ideas and learn about SimTools and associated software/hardware.

    Grab a copy of the SimTools manual and keep it handy for reference: https://www.xsimulator.net/community/faq/rtfm-start-with-the-official-simtools-documentation.117/

    Dir boxes being checked orange or not determine which way each axis moves, this is what SimTools expects: https://www.xsimulator.net/community/faq/which-way-to-set-simtool-axis-movements.230/

    You can go a little over but be mindful that total Axis Assignment should be around 100%, to avoid clipping: https://www.xsimulator.net/community/faq/axis-assignment-percentage-totals.120/

    Once you have the basics sorted, an verified in Output Testing, you can move on to game testing.

    LFS needs to be run before it is patched for motion: https://www.xsimulator.net/communit...run-in-first-person-mode-before-patching.365/

    Then see the motion profile tuning tips in the FAQs: https://www.xsimulator.net/community/faq/steps-to-create-a-motion-profile.228/
  10. Elvis A. Ramírez

    Elvis A. Ramírez Flight simulator

    Joined:
    Aug 1, 2022
    Messages:
    11
    Occupation:
    Engineer
    Location:
    Dominican Repúblic
    Balance:
    79Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Helloo guys, this information has been working for me, my servos works very nice. But i have a question about live for speed. I installed simtools and everything is working, but when i want to get information from de LFS game, it apears simtools is'nt getting information. I patched the game using GameManager, there are a way to make me sure if i already installed de LFS plugging, even when it is supposed to install when simtools install.
  11. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,533
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    145,022Coins
    Ratings:
    +10,776 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    The game LFS needs to be run before patching it for motion, as that generates some required files, see the FAQs here: https://www.xsimulator.net/communit...run-in-first-person-mode-before-patching.365/
  12. Elvis A. Ramírez

    Elvis A. Ramírez Flight simulator

    Joined:
    Aug 1, 2022
    Messages:
    11
    Occupation:
    Engineer
    Location:
    Dominican Repúblic
    Balance:
    79Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
  13. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,533
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    145,022Coins
    Ratings:
    +10,776 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Un-patch LFS and then re-patch LFS after LFS has been run, there should then be data in the top row of the SimTools Tuning Center when LFS is run.
  14. Elvis A. Ramírez

    Elvis A. Ramírez Flight simulator

    Joined:
    Aug 1, 2022
    Messages:
    11
    Occupation:
    Engineer
    Location:
    Dominican Repúblic
    Balance:
    79Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    Thank youuuuuu! Its working, Im gratefull, where can i get some tips to fit the axis assigments? What would you recommend?
  15. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,533
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    145,022Coins
    Ratings:
    +10,776 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  16. Gigino83

    Gigino83 Member

    Joined:
    Mar 16, 2023
    Messages:
    59
    Balance:
    202Coins
    Ratings:
    +9 / 0 / -0
    My Motion Simulator:
    2DOF, Arduino
    beautiful project congratulations! I think it would be very nice to modify an rc car and make sure that the tires stay still and the bodywork moves.