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

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:
    - 6Coins
    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. Ads Master

    Ads Master

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

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    17,324
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    125,068Coins
    Ratings:
    +9,800 / 47 / -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.