1. 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!
  2. 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
  3. 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

iRacing oversteer / traction loss 1DOF

Discussion in 'DIY Motion Simulator Projects' started by noSaint, Jan 9, 2021.

  1. noSaint

    noSaint New Member Gold Contributor

    Joined:
    Jan 9, 2021
    Messages:
    24
    Balance:
    154Coins
    Ratings:
    +12 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Never had a motion simulator in my life, tried a few - now I'm ready for a serious DIY project
    First off, I'm interested finding out how fast the response from iRacing and motionplatform I get.
    My goal is to get the feeling from the racing seat to assist the feeling from my Fanatec DD1 wheel and result in more driving closer to the edge of the grip.

    If this is a success I will upgrade to 2DOF, but I guess it's called 3DOF when added on top of my first one.

    My first plan is to make a prototype on cardboard with RC servo in front of monitor and film when I'm driving in my GTTrack stationary cockpit. I'm using VR so I cannot see whats going on before watching the recording.
    • Like Like x 1
  2. Ads Master

    Ads Master

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
  3. noSaint

    noSaint New Member Gold Contributor

    Joined:
    Jan 9, 2021
    Messages:
    24
    Balance:
    154Coins
    Ratings:
    +12 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    Was a bit confused yesterday, but after some testing I ended up with this arduino code:
    Code:
    /*
    Working 10.January 2021
    SimTools v2.5.1, EkitsZone MEGA2560 (obs usable pwm pins 2-13, check your own board)
    Simtools Interface Settings the comport, COM5, 500000, 8, none, 1
    Simtools Interface Settings output format, 8bit, Decimal
    Simtools Interface Settings Output string startup example, "90a90b90c" (ie 90 degrees on servo 1a, 2a, 3a) (skip the double quotes)
    Simtools Interface Settings Output string syntax, "<Axis1a>a<Axis2a>b<Axis3a>c<Axis4a>d<Axis5a>e<Axis6a>f" (skip the double quotes)
    I will use only one servo for testing so my syntax is "<Axis1a>a", no need to change the arduino code
    
    Simtools Interface Settings Output string shutdown example, "45a45b45c" (skip the double quotes)
    Setting the 3 first servos to 45 degrees
    */
    
    
    
    #include <Servo.h>
    
    //create servo objects to control a servo
    Servo objServo_01;
    Servo objServo_02;
    Servo objServo_03;
    Servo objServo_04;
    Servo objServo_05;
    Servo objServo_06;
    
    String txtInputString = "";
    char chInputChar = 0;
    int iTmp = 0;
    
    void setup()
    {
      objServo_01.attach(3);  // pin3 pwm (check your board if this pin supports pwm output)
      objServo_02.attach(4);  // pin4 pwm (check your board if this pin supports pwm output)
      objServo_03.attach(5);  // pin5 pwm (check your board if this pin supports pwm output)
      objServo_04.attach(6);  // pin6 pwm (check your board if this pin supports pwm output)
      objServo_05.attach(7);  // pin7 pwm (check your board if this pin supports pwm output)
      objServo_06.attach(8);  // pin8 pwm (check your board if this pin supports pwm output)
     
      objServo_01.write(90);  // start angle of servo (max180)
      objServo_02.write(90);  // start angle of servo (max180)
      objServo_03.write(90);  // start angle of servo (max180)
      objServo_04.write(90);  // start angle of servo (max180)
      objServo_05.write(90);  // start angle of servo (max180)
      objServo_06.write(90);  // start angle of servo (max180)
     
      Serial.begin(500000);   // opens serial port at a baud rate of 500000
    }
    
    void loop() {
     
      // read serial input
      while (Serial.available() > 0) {
      
        // read the current value from serial stream
        chInputChar = Serial.read();
      
        // when the current value is a number we store it in a string
        if (isDigit(chInputChar)) {
          txtInputString += chInputChar;
        }
     
        // when the current value is "the letter a" we move Servo 1 to new position
        if (chInputChar == 'a') {
          iTmp = (txtInputString.toInt());    // convert the numbers stored in string to a integer number
        
          // map the numbervalue 0-255(8bit) to 180 degrees i.e. 0-179
          iTmp = map(iTmp, 0, 255, 10, 169);  // in this case I limit the last 10 degrees as show below
          objServo_01.write(iTmp);            // move the servo
          txtInputString = "";                // clear the temporary string before we start over again
        }
        if (chInputChar == 'b') {
          iTmp = (txtInputString.toInt());
          iTmp = map(iTmp, 0, 255, 0, 179);
          objServo_02.write(iTmp);
          txtInputString = "";
        }
        if (chInputChar == 'c') {
          iTmp = (txtInputString.toInt());
          iTmp = map(iTmp, 0, 255, 0, 179);
          objServo_03.write(iTmp);
          txtInputString = "";
        }
        if (chInputChar == 'd') {
          iTmp = (txtInputString.toInt());
          iTmp = map(iTmp, 0, 255, 0, 179);
          objServo_04.write(iTmp);
          txtInputString = "";
        }
        if (chInputChar == 'e') {
          iTmp = (txtInputString.toInt());
          iTmp = map(iTmp, 0, 255, 0, 179);
          objServo_05.write(iTmp);
          txtInputString = "";
        }
        if (chInputChar == 'f') {
          iTmp = (txtInputString.toInt());
          iTmp = map(iTmp, 0, 255, 0, 179);
          objServo_06.write(iTmp);
          txtInputString = "";
        }
      }
    }
    got the iRacing plugin and hoping for the simtools license so I can test my favourite cars with the servo