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 Motion SIM Model - Arduino Uno

Discussion in 'SimTools DIY Version' started by marky000, Dec 21, 2014.

  1. marky000

    marky000 New Member

    Joined:
    Aug 23, 2014
    Messages:
    19
    Balance:
    306Coins
    Ratings:
    +6 / 0 / -0
    My Motion Simulator:
    Arduino


    Hey guys,

    Haven't posted for a while. Not sure if you remember but a few months back I was having some troubles getting the SIM of the ground but thanks to @eaorobbie , the idea of using servos rather than dc motors certainly made our vision feasible and we are now at the early stages of building our first SIM.

    My colleague (metal fabricator) has been constructing the SIM whilst I have been assisting with the software related areas (i.e. Arduino sketch and SimTools etc).

    Anyway, my colleague wanted me to upload this video and would welcome any comments. We have been playing around with the Tuning Center and various profile settings in Game Engine but we still feel that correlation between in-game-motion and simulator motion is not where we would like it to be.

    I will post back later with the Game Engine settings we have been using. Just thought I would present the video first.

    I should also point out that this video is few weeks old and my colleague has already made some additions to the SIM. One major addition has been the attaching of an accelerometer to the SIM. We were hoping the data outputted by the accelerometer might build on the information derived from the Simtools Tuning Centre. Unfortunately, the data derived at this stage has been rather inconclusive.

    Looking forward to your comments.

    Mark
    • Like Like x 1
    Last edited: Dec 21, 2014
  2. Pit

    Pit - - - - - - - - - - - - - - - - Gold Contributor

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,409Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    hi @marky000 IMO there may be something wrong with any settings.
    • Agree Agree x 1
  3. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,463
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    144,614Coins
    Ratings:
    +10,741 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Thanks for the video...posting the settings will allow knowledgeable members like @Pit to provide accurate suggestions.
    • Friendly Friendly x 1
  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,913Coins
    Ratings:
    +5,027 / 16 / -0
    Tuning Center
    I would suggest that you use a “medium” track and car while using the tuning center.
    Then once the game is going, click “capture new Min Max” and then click the “Reset” button.
    Now drive for a short while at 80% as hard as you usually would, being careful not to hit any walls or anything unusual. A lap or less is usually enough.
    Now save the new settings.
    Game Profile

    Now for the profile, build it one DOF at a time.
    First get surge working, so add surge to axis 1 and 2 at 50% (so you leave 50% for sway on both axis). Once it looks good set the % for surge to 0% for both and then do the same procedure for sway. Once you like what you see, simply set the % for surge back to 50% for each axis.

    Doing it this way will enable you to see exactly what is happening with each DOF.
    yobuddy
  5. marky000

    marky000 New Member

    Joined:
    Aug 23, 2014
    Messages:
    19
    Balance:
    306Coins
    Ratings:
    +6 / 0 / -0
    My Motion Simulator:
    Arduino
    Thanks heaps @yobuddy. I will take some time to try the things you suggested. In the meantime, here is the profile settings that I think were used at the time of the video being created:

    Axis_Assingments.jpg
    Interface_Settings.jpg

    Interesting that you mentioned surge and sway because most of the write-ups I have seen have been using roll and pitch.
    Last edited: Dec 23, 2014
  6. value1

    value1 Nerd SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Jan 9, 2011
    Messages:
    2,184
    Location:
    Zug, Switzerland
    Balance:
    14,463Coins
    Ratings:
    +3,318 / 11 / -1
    My Motion Simulator:
    2DOF, DC motor, JRK, Joyrider
    Pitch and surge as well as roll and sway often behave likewise. The hood of the car goes up when accelerating → pitch up, the car rolls in a curve, where you also experience sway. [Just to mention: yaw and heave are not in sync.] Therefore sway/roll, surge/pitch are somewhat similar.
  7. Pit

    Pit - - - - - - - - - - - - - - - - Gold Contributor

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,409Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    As far as i can see you @marky000 are using the Arduino code of RacingMat, please have a look to the linked screenshot below and correct your settings (BitsPerSec, Outputtype...) http://www.xsimulator.net/community/attachments/com-output-simtools-jpg.9478/

    PS!!! Interface output is wrong, you have mistyped using "P" instead of "L"

    Just my friendly advice: @Guys, if you have any issues we will help ASAP but first read thoughtfully the manuals or instructions. Thank you.
    • Agree Agree x 3
    Last edited: Dec 23, 2014
  8. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,463
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    144,614Coins
    Ratings:
    +10,741 / 52 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Good eyes @Pit!
  9. insanegr

    insanegr !N$@n€

    Joined:
    Jan 14, 2014
    Messages:
    505
    Location:
    Athens
    Balance:
    16,715Coins
    Ratings:
    +498 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
  10. marky000

    marky000 New Member

    Joined:
    Aug 23, 2014
    Messages:
    19
    Balance:
    306Coins
    Ratings:
    +6 / 0 / -0
    My Motion Simulator:
    Arduino
    @Pit Not true. Using @eaorobbie arduino code. As you can see in the code, Actuator Name = R, P

    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', 'P'};
    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.attach(kPins);
     
        // 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) {
    #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]);
    }
    • Like Like x 1
  11. Pit

    Pit - - - - - - - - - - - - - - - - Gold Contributor

    Joined:
    Oct 2, 2013
    Messages:
    3,013
    Location:
    Switzerland
    Balance:
    30,409Coins
    Ratings:
    +3,088 / 31 / -0
    My Motion Simulator:
    DC motor, Arduino, 6DOF
    mea culpa, this code was not known to me. Sorry for the false information. Anyway I suggest you to try out the proven SMC3 code.
    • Informative Informative x 1