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 Need 6dof configuration for simtools

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by Shashank Patil, Mar 17, 2024.

Tags:
  1. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    Hi, I'm building a mini model of a 6dof rig using servo motors to sync with LFS. I've assembled the platform and connected to Arduinos, yet a few questions :
    1. Do I need motor controller and what type ?
    2. Can't figure out the simtools configuration for axis, interface and such ( I have the free/demo version ).
    So if anyone would help me I'd be grateful.
  2. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,862
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,009Coins
    Ratings:
    +10,845 / 53 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  3. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    I'm trying to replicate hooshang's rig, I have the platform set but I'm confused how to move forward.
    Currently I have just the Arduinos and servo motors, unsure if I need motor controllers or SMC3 to make it work just like that.
    Would appreciate if I get specific instructions as codes/software isn't exactly my forte
  4. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,862
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,009Coins
    Ratings:
    +10,845 / 53 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    You can grab the code from the provided link, instructions to expand the Arduino code to 6 servos, and see a basic interface setting example. SMC3 is not needed for RC servo powered models, just the Arduino, modified code and associated SimTools Interface and related profile settings.
    • Like Like x 1
  5. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    Quick question, how does the servo code and simtools relate ?
  6. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,862
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,009Coins
    Ratings:
    +10,845 / 53 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    The code and Arduino provide the RC servo control, SimTools translates game data to be able to tell the Arduino and RC servos where to move to.
  7. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    So first I run the code, then simtools simultaneously takes data from the game to manipulate the code and thus the motors ?
  8. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,862
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,009Coins
    Ratings:
    +10,845 / 53 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Th
    The code gets installed to the Arduino using the Arduino IDE. That allows SimTools to translate game data to instructions the Arduino can now understand.
  9. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    Strange, simtools isn't registering or working on 2 of my 6 motors after implementing the code and configuring
    any idea why this is happening
  10. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,862
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,009Coins
    Ratings:
    +10,845 / 53 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Have you properly modified the RC servo code for 6dof, then ensured that is properly configured in the Interface Settings, followed by testing a configured Default Axis Assignment in Output Testing?

    Pictures and discriptions of what you have done would help others offer advice.
  11. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    My friend has taken it off my hands to have a look. will update you as soon as he returns it. till then, can you give an example of what a modified code should really look like for my rig ?
    please and thank you
  12. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,862
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,009Coins
    Ratings:
    +10,845 / 53 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  13. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    Welp, I guess I didn't configure the Interface properly. A little help with this axis assignment ?
    Also, t Screenshot 2024-03-21 163431.jpg Screenshot 2024-03-21 163451.jpg his is the code I've been using


    #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
    const char kActuatorName[kActuatorCount] = { 'A', 'B' , 'C' , 'D' , 'E' , "F" };
    const int kPins[kActuatorCount] = {4, 5, 6, 7, 8, 9}; // pins to which the Actuators are attached
    const int kActuatorScale[kActuatorCount][6] = { { 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]);
    }

    Attached Files:

  14. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    20,862
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,009Coins
    Ratings:
    +10,845 / 53 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Following the guide:

    const char kActuatorName[kActuatorCount] = { 'A', 'B' , 'C' , 'D' , 'E' , "F" }; should be: const char kActuatorName[kActuatorCount] = { 'A', 'B' , 'C' , 'D' , 'E' , 'F' };

    const int kActuatorScale[kActuatorCount][6] = { { 0, 179 } , // Right Actuator scaling
    { 179, 0 } // Left side Actuator scaling should be:

    const int kActuatorScale[kActuatorCount][2] = { { 0, 179 } , // 1 Actuator scaling
    { 179, 0 } , // 2 Actuator scaling
    { 179, 0 } , // 3 Actuator scaling
    { 179, 0 } , // 4 Actuator scaling
    { 179, 0 } , // 5 Actuator scaling
    { 179, 0 } }; // 6 Actuator scaling

    int actuatorPosition[kActuatorCount] = {90, 90}; should be:
    int actuatorPosition[kActuatorCount] = {90, 90, 90, 90, 90, 90};
  15. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    I guess I'm still doing something wrong with the interface, looking at my axis assignment what should I put in the interface output box ? I'm using Serial type interface 9600 bits
  16. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    So far I'm here. Fried some pins on one of my Arduinos testing the servos. Any specific power supplies/ battery recommendations for MG995/ MG996R servos ? Would appreciate if it is possible for a single Arduino to do it via simtools.

    Attached Files:

  17. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    Update : I'm trying FlyPT for Assetto Corsa, using this code to upload to an ESP32 for testing purpose 20240413_130201.jpg 20240413_130201.jpg Screenshot (6).png .
    Uploaded this, tried the interfacing with the Output window but no movement in platform

    #include <Servo.h>

    // Define servo objects for 6 servo motors
    Servo servo1, servo2, servo3, servo4, servo5, servo6;

    void setup() {
    // Initialize serial communication at 9600 baud rate
    Serial.begin(9600);

    // Attach servo objects to corresponding pins
    servo1.attach(2);
    servo2.attach(3);
    servo3.attach(4);
    servo4.attach(5);
    servo5.attach(6);
    servo6.attach(7);
    }

    void loop() {
    // Check if data is available to read from serial port
    if (Serial.available() >= 18) { // Assuming each set of three numbers is sent for each DOF
    // Read incoming data for all 6 DOFs
    int dof1 = mapValue(Serial.parseInt(), 0, 1023, 0, 180);
    int dof2 = mapValue(Serial.parseInt(), 0, 1023, 0, 180);
    int dof3 = mapValue(Serial.parseInt(), 0, 1023, 0, 180);
    int dof4 = mapValue(Serial.parseInt(), 0, 1023, 0, 180);
    int dof5 = mapValue(Serial.parseInt(), 0, 1023, 0, 180);
    int dof6 = mapValue(Serial.parseInt(), 0, 1023, 0, 180);

    // Control servo motors based on incoming DOF data
    servo1.write(dof1);
    servo2.write(dof2);
    servo3.write(dof3);
    servo4.write(dof4);
    servo5.write(dof5);
    servo6.write(dof6);
    }
    }

    // Function to map incoming value to new range
    int mapValue(int value, int fromLow, int fromHigh, int toLow, int toHigh) {
    return map(value, fromLow, fromHigh, toLow, toHigh);
    }
  18. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    1,903
    Location:
    Portugal
    Balance:
    13,910Coins
    Ratings:
    +2,270 / 17 / -0
    My Motion Simulator:
    6DOF
    Did you set the rig for 10 bits (0 to 1024) in the rig module of Mover?
    In your code you are using 9600 baud rate, in Mover you have 115200, it should be the same.
    Also, serial is a stream, you have no way to know when you are receiving the data for the first axis.
    You need to use a delimiter for that in your string.
    For example 3 bytes with 255, that's something that never happens for 10 bits
  19. Shashank Patil

    Shashank Patil New Member

    Joined:
    Dec 7, 2022
    Messages:
    21
    Balance:
    95Coins
    Ratings:
    +1 / 0 / -0
    My Motion Simulator:
    3DOF, AC motor, Arduino, Motion platform, 6DOF
    So do I change the bits in the mover or the code ? I'm not sure I understand anything after the "serial is a stream..." Don't happen to be a coder geek :(. All I have is a basic understanding and made this code using bits and pieces from online and some ai. Also, is it fine if I change the range of motors 2,4,6 with 180,0 ( since it's inverted on the 2 4 6 position? )