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 Can anyone help? Building 3Dof motion platform with RTelligent Nema Steppers and T60 drivers

Discussion in 'DIY Motion Simulator Projects' started by shwabler, Nov 21, 2021.

  1. shwabler

    shwabler New Member

    Joined:
    Oct 4, 2021
    Messages:
    1
    Occupation:
    Automation controls engineer
    Location:
    Lithuania
    Balance:
    - 26Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    Hello,
    First I would like to say that I am trying to make a Motion sim prototype and I'm giving myself a deadline of next summer. I have already assembled all the parts with my own Solidworks designed 3d printed parts. All of the electrical components are connected as well. All that is left is my big gray zone - Arduino programing with Simtools. I have no idea whatsoever how to get Simtools working and what kind of Arduino code I should write because I'm rather new to Arduino programming.

    Does anybody care to give me some advice?

    I am also attaching all of my progress so far.

    IMG_6639.jpeg

    https://youtu.be/JZKs8c9ofkE - Mechanical construction test

    https://youtu.be/LyNRWqrxfJU - Electrical wiring test

    If I understood correctly I need to get a full license Simtools version in order to get this working? Is it possible to get the DIY package discount?

    I found some Arduino code in the forum :
    https://www.xsimulator.net/community/threads/arduino-code-for-steppers.5434/

    But I don't know how to test it out with Simtools...


    Code:
    #define DEBUG 1                                    // comment out this line to remove debugging Serial.print lines
    
    // Declare pins
    int STEP[]    = {9,10,11};                                          // Step Pins,  active HIGH
    int DIR[]     = {3,5,6};                                            // Direction Pins, active HIGH
    int ENABLE[]  = {4,8,12};                                           // Driver Enable Pins, Active LOW
    
    const int kAxisCount = 3;                                           // how many axis we are handling
    
    int Pos[] = {0,0,0};                                                //Position logging
    
    const char kAxisName[kAxisCount] = {'R','P','H'};                   // the letters ("names") sent from Sim Tools to identify each axis
    const int kAxisScale[kAxisCount][3] = { {0,999},{0,999},{0,999} };  // Scaling
    const char kEOL = '~';                                              // End of Line - the delimiter for our acutator values
    const int kMaxCharCount = 3;                                        // some insurance to 8 bit...
    int axisPosition[kAxisCount] = {0,0,0};                             // current Axis positions, initialised to 127 middle for 8 bit
    int currentAxis;                                                    // keep track of the current Axis 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
                                                                        // psReadAxis = next character from serial port tells us the Axis info that follows
                                                                        // psReadValue = next characters from serial port until we hit our kMaxCharCount or kEOL which tells us the value
    enum TPortState { psReadAxis, psReadValue }; 
    TPortState currentState = psReadAxis;
    
    void setup()  {
      Serial.begin(921600);
     
    
      for (int i=0; i < kAxisCount; i++)  {
        pinMode(STEP[i], OUTPUT);
        pinMode(DIR[i], OUTPUT);
        pinMode(ENABLE[i], OUTPUT);
        
          digitalWrite(ENABLE[i],LOW);
                                          }
    }
    
    void loop()
    {
    for (int i = 0; i < kAxisCount; i++) {
                                                                        // check new position
    if (Pos[i] != axisPosition[i])  {
     
                                                                        // check direction and write DIR pin
      if (Pos[i] >= axisPosition[i])  {
      digitalWrite(DIR[i], LOW);
      Pos[i] = Pos[i] - 1;
        }
      
      if (Pos[i] < axisPosition[i])  {
      digitalWrite(DIR[i], HIGH);
      Pos[i] = Pos[i] + 1;
        }
      
                                                                        // make one step
        digitalWrite(STEP[i], HIGH);
        delayMicroseconds(500);
        digitalWrite(STEP[i], LOW);
        delayMicroseconds(500);
      
                                                                        //break;
    }}}
    
                                                                        // 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 Axis name, grab it here
            if (currentState == psReadAxis) {
                tmpChar = Serial.read();
              
    #ifdef DEBUG           
    Serial.print("read in ");           
    Serial.println(tmpChar);           
    #endif
            for (int i = 0; i < kAxisCount; i++) {                      // look for our axis in the array of axis names we set up
            if (tmpChar == kAxisName[i]) {
    #ifdef DEBUG           
    Serial.print("which is axis ");           
    Serial.println(i);           
    #endif
                        currentAxis = i;                                // remember which axis we found
                        currentState = psReadValue;                     // start looking for the Axis position
                        axisPosition[currentAxis] = 0;                  // initialise the new position
                        valueCharCount = 0;                             // initialise number of value chars read in
                                                                        // break;
                    }
                }
            }
          
                                                                        // if we're ready to read in the current Axis 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;
                        axisPosition[currentAxis] = axisPosition[currentAxis] * 10 + tmpValue;
                        valueCharCount++;
                    }
                    else break;
                }
              
                                                                          // if we've read the value delimiter, update the Axis and start looking for the next Axis name
                if (tmpValue == kEOL || valueCharCount == kMaxCharCount) {
                
                
                                                                          // scale the new position so the value is between 0 and 179
                  axisPosition[currentAxis] = map(axisPosition[currentAxis], 0, 255, kAxisScale[currentAxis][0], kAxisScale[currentAxis][1]);
                                                                          // updateAxis(currentAxis);
                
    #ifdef DEBUG           
    Serial.print("read in ");           
    Serial.println(axisPosition[currentAxis]);
    Serial.print("Position ");           
    Serial.println(Pos[currentAxis]); 
    #endif
                  
                    currentState = psReadAxis;
                }
            }
        }
    } 
  2. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,020
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,824Coins
    Ratings:
    +10,876 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    The demo version of SimTools includes the fully functional plugin for Live For Speed, specifically for testing purposes. Download LFS here: https://www.lfs.net/downloads

    Make sure you run a LFS race in first person mode before patching it for motion, as that generates some required files: https://www.xsimulator.net/communit...run-in-first-person-mode-before-patching.365/

    To qualify for a free license:

    • You must be building a true DIY motion simulator. (Not built from a kit or purchased from a simulator seller, a model simulator does not qualify.)
    • Have a unique build thread or Showcase in DIY Simulator Projects. (The thread should show some effort, which means it should show progress to the rig testing phase.)
    • Have been a member of the community for at least 30 days.
  3. anders jensen

    anders jensen New Member Gold Contributor

    Joined:
    Jan 26, 2022
    Messages:
    1
    Balance:
    6Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, Arduino, JRK, Joyrider, Motion platform
    hello can i ask what kind of motors you are useing :)