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

Issues while communicating to Arduino

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by Tintin Boulsard, Feb 7, 2024.

  1. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    Hello,
    I recently built some actuators using stepper motors. The wiring is done and everything is fixed on the chassis. I'm now tackling the software part.
    I'm using an Arduino R4 Minima. I plan to use Simtools or FlyPt. I've tested a lot of Arduino code (even Lebois' SRT100) that could work with my stepper, but nothing works, no motor moves. So I downloaded a test code that just moves the actuators up and down without any communication with Simtools or anything else, in a loop. It works perfectly. So there's no problem with the wiring or the motors. I tried the previous codes by testing them on the Serial Monitor. And there, I get nothing. I tested this with eaorobbie's code and this "remix":

    Code:
    //********************************************************************************************
    // Simtools Stepper 1 Axis code
    // Based on code By EAOROBBIE (Robert Lindsay)
    // By Peter Brennan
    
    //********************************************************************************************
    
    #include <AccelStepper.h>
    
    #define DEBUG 1                                    // comment out this line to remove debuggin Serial.print lines
    
    // Define a stepper and the pins it will use
    AccelStepper stepper(AccelStepper::DRIVER, 2, 3);
    
    const char kEOL = '~';                              // End of Line - the delimiter for our acutator values
    const int kMaxCharCount = 3;                        // some insurance...
    int valueCharCount = 0;                             // how many value characters have we read (must be less than kMaxCharCount!!
    int actuatorPosition = 0;                           // current Actuator position, initialised to 0
    int newActuatorPosition = 0;                        // initialise variable to collect new motor position
    
    // set up some states for our state machine
    // psReadActuator = 0
    // psReadValue = 1
    int currentState = 0;
    
    void setup()
    {
      // Set base values for stepper speed and acceleration as well as setting current pos to 0
      stepper.setMaxSpeed(2000);
      stepper.setAcceleration(1000);
      stepper.moveTo(0);
    
       Serial.begin(9600); // opens serial port at a baud rate of 9600
    }
    
    
    
    // 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 == 0) {
                tmpChar = Serial.read();
    
    #ifdef DEBUG
    Serial.print("read in ");           
    Serial.println(tmpChar);
    #endif
    
    if (tmpChar == 'P') {
    
    #ifdef DEBUG
    Serial.print("which is actuator ");           
    Serial.println('P');
    #endif
    
    currentState = 1;                 // start looking for the Actuator 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 == 1) {       
            
                while ((valueCharCount < kMaxCharCount) && Serial.available()) {
                
                    tmpValue = Serial.read();
                  
                    if (tmpValue != kEOL) {
                    
                        tmpValue = tmpValue - 48;
          
                        if ((tmpValue < 0) || (tmpValue > 9)) tmpValue = 0;
                        // Determine the new position for the stepper
                        newActuatorPosition = newActuatorPosition * 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("Move to ");           
    Serial.println(newActuatorPosition);
    #endif
    // Transfer the new actuator value to the current one, and reset the new position
              actuatorPosition = newActuatorPosition;
              currentState = 0;
              newActuatorPosition = 0;
                }
            } }
        }
      
        void loop()
    {
    // Move the stepper to the desired position if nto already there
         stepper.moveTo(actuatorPosition);
    stepper.run();
    }
    Any help could be precious.
    Thank you,
    Tintin Boulsard
  2. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    I also found this one but when I send for example "R170~" in the Serial Monitor, I don't receive anything in return and the stepper motor does not move.
    So I think the problem is not coming from the code but from the Arduino or the communication with it. My Arduino R4 Minima is new, I just ordered it a few days ago. I had the same problem with an Arduino R3 before ordering the R4 but it was an unofficial Arduino, so that is matbe why it could not work before.

    I hope someone could help me,
    Thanks,
    Tintin Boulsard

    Code:
    //
    #define DEBUG 1                                    // comment out this line to remove debuggin Serial.print lines
    
    // Declare pins
    int STEP[] = {31,33,35,37,39,41};    // Step Pins,  active HIGH
    int DIR[] = {30,32,34,36,38,40};     // Direction Pins, active HIGH
    byte DIR_ACTIVE[] = {LOW, LOW, LOW, LOW, LOW, LOW};
    
    const int kAxisCount = 6;                          // how many axis we are handling
    
    int Pos[] = {0,0,0,0,0,0}; //Position logging
    
    const char kAxisName[kAxisCount] = {'R','P','H','Y','S','U'};    // the letters ("names") sent from Sim Tools to identify each axis
    const int kAxisScale[kAxisCount][6] = { {0,999},{0,999},{0,999},{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,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);
     
      // Define pins
      for (int i=0; i < kAxisCount; i++)  {
        pinMode(STEP[i], OUTPUT);
        pinMode(DIR[i], OUTPUT);
      }
    }
    
    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;
                }
            }
        }
    }
  3. harrie

    harrie Member

    Joined:
    Oct 1, 2022
    Messages:
    48
    Location:
    coevorden
    Balance:
    221Coins
    Ratings:
    +20 / 0 / -0
    My Motion Simulator:
    Arduino, 4DOF
    i also into steppenmotor setup . arduino setup ,nema 34 with 12 nm . arduno uno , got 2 of them here r3 . a red one and a bleu one . did do a blink test with them and figure out that the blue did not recieve code ..not blinking no writing onto it , broke ? , the red one did blink and accept writing..what arduino are you using ? red , blue , black ? i.m in the proces to wire things up , but do steppenmotors not need a ..home ..position ? with switch ? i got steppenmotors with no encoders . looking to ad home switch onto it . will this weekend wire them up and using the code above . with my other wp motors motion rig i did get the same problem , orderd a new uno r3 elegoo black . for going from 2 dof to 4 dof , blinking test onto my home pc did work . game pc wil not see the new uno ? 2 uno setup is with direct usb input to the game pc , not with a hub ..game pc is with new install windows 11 , maybe i,m missing some drivers ? i did wanted to open a new topic for steppenmotors , but i did see this topic , so i,m jumping into this one .. seem to be that whe are in the same direction and procedure ..and problems :cool:

    Attached Files:

  4. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    Hi harrie,
    Welcome to this topic... I can see that we are working on a same project. So that's nice, maybe will we work together and help each other....
    For info, I use 4 stepper motors with encoder of 8,5Nm. I first decided to buy them in open loop and 12Nm but I read on Internet that closed loop were more precise, and also there was much more infos were I bought them.
    I'm using an official Arduino R4 Minima, so it is not totally blue but between the green and the blue. Often, the red, blue and black Arduino s are not official.
    Personally, I don't use any home position switches, I'm going to calibrate them my self on the software, such as Simtools or FlyPt Mover.
    Normally, you should be able to connect the Arduino to your gaming PC without any problem. You don't need any driver, except the Arduino IDE software.
    I'll do more tests with Arduino and the steppers, and I'll send you the results. Maybe it will help you if I arrive to make it work.

    Tintin Boulsard
    • Like Like x 1
  5. harrie

    harrie Member

    Joined:
    Oct 1, 2022
    Messages:
    48
    Location:
    coevorden
    Balance:
    221Coins
    Ratings:
    +20 / 0 / -0
    My Motion Simulator:
    Arduino, 4DOF
    hi @Tintin Boulsard.

    i,m using the nema 34 without encoder , because i did update my cnc machine with servos . so left over 4 x nema 34 . wil gone wiring up 1 nema this weekend and test it with above sketch : this sketch is for mega 2560 when i see pin connections ?


    // Declare pins
    int STEP[] = {31,33,35,37,39,41}; // Step Pins, active HIGH
    int DIR[] = {30,32,34,36,38,40}; // Direction Pins, active HIGH
    byte DIR_ACTIVE[] = {LOW, LOW, LOW, LOW, LOW, LOW};

    and nice to share for to setting this up . when wired up i give it a test and writhe the result in here . i did printed the actuator parts in 10% alu filament , verry rare and absoluut strong filament . printing with 170 C , the setup is with 1605 trapezium tread and pom-c ballnuts . got the tool for making these ballnuts . did orderd the alu profiles 300mm lengte , amazone, its all a cheap setup for parts , but i wanted to give it a try because the leftover nema,s .. did read alot onto this forum , but not much for steppenmotors . my first sim motion rig is working for now with 2 dof , this steppenmotor setup wil go into the ferrari p4/5 project .:)
    IMG_20240209_102423.jpg IMG_20240209_102407.jpg
    Last edited by a moderator: Feb 9, 2024
  6. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    Hi @harrie,
    The code above is made for the Arduino Mega, as you said, but you can easily modify it for your 4 motors and your Arduino Uno :

    Code:
    // Declare pins
    int STEP[] = {2,4,6,8};    // Step Pins,  active HIGH
    int DIR[] = {3,5,7,9};     // Direction Pins, active HIGH
    byte DIR_ACTIVE[] = {LOW, LOW, LOW, LOW};
    
    const int kAxisCount = 4;                          // how many axis we are handling
    
    int Pos[] = {0,0,0,0}; //Position logging
    
    const char kAxisName[kAxisCount] = {'R','P','H','Y'};    // the letters ("names") sent from Sim Tools to identify each axis
    const int kAxisScale[kAxisCount][6] = { {0,999},{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,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!!
    
    It looks like you 3D printed the slider used for the OpenSFX100 but these use a 100x100 aluminium profile. And as I can see, you ordered 80x80 profiles, so it will not work. Am I wrong ?

    Tintin Boulsard
  7. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    And here is the wiring I use, if it can help you...
    [​IMG]
    • Informative Informative x 1
  8. harrie

    harrie Member

    Joined:
    Oct 1, 2022
    Messages:
    48
    Location:
    coevorden
    Balance:
    221Coins
    Ratings:
    +20 / 0 / -0
    My Motion Simulator:
    Arduino, 4DOF
    you are wright , sfx-100 slider . the slider was my first print from a stl site sfx-100 . based onto the nema 80x80 dimension i design the actuator 80x80x300., did have an arduino mega and already downloaded the sketch onto it . after a error type error my motion seat 1 is broke , gone fix this tomorrow , and get back to wiring up the nema setup .. we wil see if it wil work with this sketch , i wil posting here when i got them wired up and testrun
  9. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    I tested multiple codes.
    None of the Arduino codes above work, so I'm writing my own code and testing it step by step. It is for the moment working perfectly. I have to add a few others lines to make it totally work with Simtools, and I'll share it with you..

    Tintin Boulsard
  10. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    Hi @harrie ! :)
    Did you wired yours actuators? And tested them?

    I just finished the code, which is working almost perfectly! You can run it using Simtools, or in DEBUG mode in the Serial Monitor but you have to uncomment the "//define DEBUG 1" line. Actually, I'm using a code made by @eaorobbie that I then modified to make it work properly on stepper motors.
    If you want to use it, you must install the StepperDriver library and modify the pins in the code, depending on you wiring.
    The datas sent are in this format : "Rxxx~" where xxx is a value between 0 and 255. Also, there is a scaling value that corresponds in this code to the range (look at picture below). I don't know if this value is in steps or microsteps, or other but I recommend you to test, and adjusting to the range of your actuator, by increasing a little bit at each time. Attention, leave the negative sign : { -10000, 10000 }.
    You can modify the speed of the stepper : #define RPM 400.
    It is for the moment for only one axis, but I'm going to modify it for 4 axis soon.
    And lastly, the only issue I have is that when I "Output Test" the code and steppers with Simtools, I have to slide the cursor slowly, otherwise, it goes in multiple directions fastly, and after a few seconds it stops and works well again. I have to fix that, but I'm using Simtools in Demo, so maybe it is not coming from my code, so I'll buy a licence.

    Tintin Boulsard


    Code:
    #include <BasicStepperDriver.h>
    
    //------------------------- Can be modified --------------------------//
    #define STEP 3
    #define DIR 4
    #define RPM 400
    #define MICROSTEPS 16
    #define MOTOR_STEPS 200
    //define DEBUG 1
    //--------------------------------------------------------------------//
    
    BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP);
    
    const int kActuatorCount = 1;  //Number of actuators
    const char kActuatorName[kActuatorCount] = {'R'};
    const int kActuatorScale[kActuatorCount][2] = { { -10000, 10000 } }; //Scaling, where 1000 is the range
    const char kEOL = '~';
    const int kMaxCharCount = 3;
    int actuatorPosition[kActuatorCount] = {0};
    int actuatorPosition2[kActuatorCount] = {0};
    int currentActuator;
    int valueCharCount = 0;
    int remember[kActuatorCount] = {0};
    enum TPortState { psReadActuator, psReadValue }; 
    TPortState currentState = psReadActuator;
    
    void setup(){
      Serial.begin(9600);
      stepper.begin(RPM, MICROSTEPS);
      }
    
    void loop()
    {
    }
    
    void serialEvent(){
        char tmpChar;
        int tmpValue;
    
        while (Serial.available()) {
            if (currentState == psReadActuator) {
                tmpChar = Serial.read();
      
    #ifdef DEBUG           
    Serial.print("read in ");           
    Serial.println(tmpChar);           
    #endif
    
                for (int i = 0; i < kActuatorCount; i++) {
                    if (tmpChar == kActuatorName[i]) {
    
    #ifdef DEBUG           
    Serial.print("which is actuator ");           
    Serial.println(i);           
    #endif
    
                        currentActuator = i;
                        currentState = psReadValue;             
                        actuatorPosition[currentActuator] = 0; 
                        valueCharCount = 0;         
                        break;
                    }
                }
            }
          
            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 (tmpValue == kEOL || valueCharCount == kMaxCharCount) {
    
    #ifdef DEBUG           
    Serial.print("read in ");           
    Serial.println(actuatorPosition[currentActuator]);           
    #endif
    
    
                    actuatorPosition[currentActuator] = map(actuatorPosition[currentActuator], 0, 255, kActuatorScale[currentActuator][0], kActuatorScale[currentActuator][1]);
    #ifdef DEBUG           
    Serial.print("scaled to ");           
    Serial.println(actuatorPosition[currentActuator]);   
    #endif
    
    actuatorPosition2[currentActuator] = actuatorPosition[currentActuator] - remember[currentActuator];
    remember[currentActuator] = actuatorPosition[currentActuator];   //Remember actuator position
                    updateActuator(currentActuator);
                    currentState = psReadActuator;
                }
            }
        }
    
        
    }
    
    
    void updateActuator(int thisActuator) {
        stepper.move(actuatorPosition2[thisActuator]); 
    }
    
    
    • Winner Winner x 1
    • Useful Useful x 1
    Last edited: Feb 10, 2024
  11. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    Range.png
    Range Image
    Capture d'écran 2024-02-10 162910.png
    SimTools Settings
  12. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    Hi @harrie,
    Have a look to this post, maybe it can help you : LINK.

    Best regards,
    Tintin Boulsard
  13. harrie

    harrie Member

    Joined:
    Oct 1, 2022
    Messages:
    48
    Location:
    coevorden
    Balance:
    221Coins
    Ratings:
    +20 / 0 / -0
    My Motion Simulator:
    Arduino, 4DOF
    just did cnc make some parts for the broken rig , got the actuator parts almost ready now and will assemble it and test run when wiring up the whole thing ...stil bizzy with assembeling the new/broken motion box .
    IMG_20240212_150738.jpg

    Attached Files:

    • Like Like x 1
  14. harrie

    harrie Member

    Joined:
    Oct 1, 2022
    Messages:
    48
    Location:
    coevorden
    Balance:
    221Coins
    Ratings:
    +20 / 0 / -0
    My Motion Simulator:
    Arduino, 4DOF
    what i understand is that the demo simtool works like the licens , with lfs for a demo game . did workt here onto the other rig i got .licens is only for that you can ad more plugins? correct me if i,m wrong .. and yes , always start low in settings and dont make a typing error ...... like i did ..:( thats why the other rig motionbox did broke . realy did lift me out of the seat :D
  15. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    Hello @harrie,
    Be careful with your "motion box" ! The goal of motion simulators is not to hurt you...
    Your rig looks awesome! Did you make it yourself?
    Yes, you can download Simtools plugins from the "Downloads" section of XSimulator website, or buy a licence so you can download as much plugins as you want, in addition to the Simtools software licence.
    Which Arduino code are you going to use? The one a modified myself, one of the codes at the top of this topic, or even an other one?
    For the home position switch, I see that you absolutely want to use them, so you can easily add some lines to the code. I recommend you to use the code I modified because I added a variable that "remember" the position of the actuators, so it calculate the distance to go, either it will turn again and again, thinking at each loop that the actuator is at the home position. I do my best to explain you that in English, so sorry if I'm not clear enough. Then you can add some precision in the position of the actuator, by using your home switches and adding in the loop something like "if the Arduino receive a signal from the switch, it set my "remember" variable to '0' (127 coming out of Simtools then scaled to 0 for the StepperDriver library).

    I hope you can understand me,
    Best regards,
    Tintin Boulsard
  16. harrie

    harrie Member

    Joined:
    Oct 1, 2022
    Messages:
    48
    Location:
    coevorden
    Balance:
    221Coins
    Ratings:
    +20 / 0 / -0
    My Motion Simulator:
    Arduino, 4DOF
    the rig nr 1 , home made prototype . al plans in autocad , free to share . al made on my home cnc . verry nice fitting/assembeling , cheap wooden parts . the body position is perfect .... al evening dirtrally , no problem with not good sitting , pain ore something .. it is a prototype and already making it in alu and carbon parts . al wil be finish in alcantare like the seat . complete rig in alcantara ...the side arms that go up for getting into the seat is electrik . also foot pedals are electric forward ore backwards . IMG_20240113_170005.jpg
    good idee for me is to wait with the software , i,m seeing you are better with arduino writing then me.. this setup is for rig nr 2 ferrari , i,m not in a hurry with it . got it al layout now , nema motor , driver , power , wiring to arduino mega2560 . but no software onto the mega yet ...
    motion box almost ready again , for a new testdrive again ....and now with 3 dof and yaw motion . IMG_20240113_143030.jpg
    • Like Like x 1
  17. early_m

    early_m Active Member

    Joined:
    Jul 28, 2016
    Messages:
    318
    Location:
    Chelmsford
    Balance:
    814Coins
    Ratings:
    +345 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    I tried this code in V3, but doesn't work for me. The stepper just starts turning randomly when I click test in interface settings. What should the microstepping dip switches be set to on the stepper?
  18. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    Hi @early_m,
    I'm sorry that the code doesn't work for you.
    Try to replace the line "//define DEBUG" by "#define DEBUG". Check that Simtools is totally closed. Then open the Serial Monitor from Arduino IDE, select 9600 baud rate, and try to send "R127~". Normally, it should not move, or only of one or two steps. Then send "R255~" and it should turn a lot in a direction, and if you send R127~ again, it should turn in the opposite direction, to get back at the first position.
    If it works, your issue maybe comes from the communication with Simtools... Which version of Simtools are you using?
    And please, can you send me what stepper are you using, and the name of the driver, so I can send you back the driver switches configuration.

    Best regards,
    Tintin Boulsard

    Edit : If it works in the Serial Monitor, compare the Simtools configuration with the one I published there. If it still doesn't work, try to change the Output Type to Binary, Hex, or Decimal....and remove all your axis assignments, and in Output Test, select, instead of DOF axis, the second option where you can find Axis1a...
    • Friendly Friendly x 1
    Last edited: Feb 13, 2024
  19. early_m

    early_m Active Member

    Joined:
    Jul 28, 2016
    Messages:
    318
    Location:
    Chelmsford
    Balance:
    814Coins
    Ratings:
    +345 / 4 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
  20. Tintin Boulsard

    Tintin Boulsard Member

    Joined:
    Dec 23, 2022
    Messages:
    40
    Location:
    France
    Balance:
    152Coins
    Ratings:
    +17 / 0 / -0
    My Motion Simulator:
    3DOF, Arduino
    As it works well in the Serial Monitor, it seems that the problem is coming from the communication between Simtools and the Arduino.
    You should try installing Simtools v2, the v3 is still in Beta, so maybe it will work better using Simtools v2...
    Which Arduino do you use? I had an unofficial Arduino Uno R3, that I had bought on AliExpress, but thinking it would be more reliable, I bought an official Uno R4 Minima. I then tested my code on the R4, using the Serial Monitor and it was working well. But, on Simtools, there was no any response. No any motor moved. So I tested with my "fake" Uno R3, and it worked perfectly on Simtools. As a conclusion, my fake Uno R3 works better than my official Uno R4 Minima.
    So maybe using a different Arduino will work?
    And for the switches configuration, you normally have a sticker on the stepper where you have all the configurations. I use the "3200" one, but it is not our problem, as it is working in the Serial Monitor...

    Best regards,
    Tintin Boulsard
    • Informative Informative x 1