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 I need help with Arduino code for my new 6DOF unlimited YAW

Discussion in 'DIY Motion Simulator Building Q&A / FAQ' started by xxpelle, Jan 31, 2021.

  1. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
  2. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
  3. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
  4. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    Update
    IMG_1348.JPG

    IMG_1349.JPG
    • Like Like x 4
    • Friendly Friendly x 1
  5. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    • Like Like x 2
    • Creative Creative x 1
  6. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
  7. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
  8. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    • Like Like x 1
  9. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    Okay, I now have an Arduino code.

    The code for 1 motor and 1 Arduino

    // ======================================================================================
    // SIMTOOLS STEPPER CONTROL - NEMA34 & DMA860H & NANO V3
    // SIMTOOLS STEPPER CONTROL - DYNAMIC MID-POINT & DEBOUNCED (2025)
    // ======================================================================================
    // – Hardware:
    // - Motor: NEMA 34
    // - Driver: DMA860H (PUL/DIR an 5V Logik)
    // - Board: Arduino Nano V3.0
    // - Sensor: RAMPS 1.4 Optical Endstop (VCC, GND, SIG)
    //
    // – Pinbelegung Nano:
    // - Pin 8: DIR (Richtung) -> Driver DIR- (DIR+ an +5V)
    // - Pin 9: STEP (Puls) -> Driver PUL- (PUL+ an +5V)
    // - Pin 10: SIG (Sensor) -> RAMPS Sensor Signal Pin
    //
    // – SimTools Interface Einstellungen:
    // – Bits per second: 19200
    // – Data bits: 8
    // – Stop bit: 1
    // – Parity: None
    // – Output bits: 10 (Wertebereich 0 - 1023)
    // – Interface Output: R<Axis1a>~
    // – Output Rate: 50 ms
    //
    // – Parameter im Code:
    // – STEPS_PER_UNIT: Skaliert den SimTools-Wert (z.B. 4 = 4092 Schritte bei 1023)
    // – HOMING_SPEED: Geschwindigkeit beim Anfahren des Referenzpunktes
    //
    // – Features:
    // 1. Zeitbasierte Entprellung (Debounce) zur Vermeidung von Fehlauslösungen.
    // 2. Homing beim Start + Nullpunkt-Korrektur bei jeder Überfahrt im Betrieb.
    //
    // ======================================================================================
    //
    //Spezielle Tipps für NEMA 34 & DMA860H:
    //
    // Verkabelung (WICHTIG):
    // Verbinde PUL+ und DIR+ des Treibers mit dem 5V Pin des Nano.
    // Verbinde PUL- mit Nano Pin 9.
    // Verbinde DIR- mit Nano Pin 8.
    // Dies schützt den Nano, da der Treiber die Trennung übernimmt.
    // RAMPS Opto-Sensor:
    // Stelle sicher, dass der Sensor mit 5V (VCC) und GND vom Nano versorgt wird.
    // Die Signal-Leitung (SIG) kommt an Pin 10.
    // Sollte der Reset im Betrieb "falsch herum" auslösen, ändere sensorActiveLow auf false.
    // Mikroschritt-Einstellung:
    // Prüfe die DIP-Schalter am DMA860H. Für SimTools ist oft ein Wert von 1600 oder 3200 Schritten/Umdrehung ein guter Kompromiss aus Kraft
    // und Geschwindigkeit.
    // Netzteil:
    // Ein NEMA 34 zieht viel Strom. Achte darauf, dass das Netzteil am Treiber (z.B. 48V-80V DC) genug Ampere liefert, während
    // der Nano separat über USB oder ein 5V-Modul versorgt wird. Verbinde die GNDs des Hochstromkreises nicht direkt mit dem Nano, falls
    // du die Optokoppler-Variante (Tipp 1) nutzt.
    // Drehrichtung:
    // Wenn der Motor beim Start (Homing) in die falsche Richtung fährt (vom Sensor weg statt zum Sensor hin), tausche
    // entweder zwei Phasen-Kabel des Motors am Treiber (z.B. A+ und A-)
    // oder ändere im Code: stepper.setSpeed(HOMING_SPEED); (entferne das Minuszeichen).
    //
    // ======================================================================================

    #include <AccelStepper.h>

    // --- KONFIGURATION ---
    #define DIR_PIN 8
    #define STEP_PIN 9
    #define HOMING_PIN 10
    #define STEPS_PER_UNIT 4 // Multiplikator für SimTools-Werte
    #define HOMING_SPEED 1000 // Moderate Geschwindigkeit für schwere NEMA34 Lasten
    #define MAX_SPEED 6000 // DMA860H verträgt hohe Frequenzen (ggf. anpassen)
    #define ACCELERATION 4000 // NEMA34 braucht sanftere Rampen wegen hoher Masse

    // --- DEBOUNCE (ENTPRELLUNG) ---
    unsigned long lastDebounceTime = 0;
    const unsigned long debounceDelay = 100; // Erhöht auf 100ms für industrielle Umgebungen

    // RAMPS 1.4 Opto-Endstop Logik:
    // Meistens: Frei = HIGH (LED aus), Unterbrochen = LOW (LED an)
    bool sensorActiveLow = true;
    bool lastSensorState = false;

    String inputString = "";
    bool stringComplete = false;

    // Driver Typ: DRIVER bedeutet ein Driver mit STEP und DIR Pins
    AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);

    void setup() {
    Serial.begin(19200);

    // Der RAMPS Sensor benötigt VCC/GND vom Nano. SIG geht an Pin 10.
    pinMode(HOMING_PIN, INPUT_PULLUP);

    inputString.reserve(20);

    stepper.setMaxSpeed(MAX_SPEED);
    stepper.setAcceleration(ACCELERATION);

    // --- INITIALES HOMING (START) ---
    Serial.println("NEMA34 Homing...");

    // Suche Lichtschranke
    stepper.setSpeed(-HOMING_SPEED);
    while (digitalRead(HOMING_PIN) == (sensorActiveLow ? HIGH : LOW)) {
    stepper.runSpeed();
    }

    stepper.setCurrentPosition(0); // Mitte markieren

    // 200 Schritte freifahren (Sicherheitsabstand für NEMA34)
    stepper.moveTo(200);
    while (stepper.distanceToGo() != 0) { stepper.run(); }

    Serial.println("DMA860H System bereit.");
    }

    void loop() {
    stepper.run();

    // --- DYNAMISCHER RESET BEI ÜBERFAHRT ---
    bool currentSensorState = (digitalRead(HOMING_PIN) == (sensorActiveLow ? LOW : HIGH));

    if (currentSensorState && !lastSensorState) {
    if ((millis() - lastDebounceTime) > debounceDelay) {
    stepper.setCurrentPosition(0);
    lastDebounceTime = millis();
    }
    }
    lastSensorState = currentSensorState;

    // --- SIMTOOLS KOMMUNIKATION ---
    if (stringComplete) {
    processCommand(inputString);
    inputString = "";
    stringComplete = false;
    }
    }

    void serialEvent() {
    while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '~') stringComplete = true;
    }
    }

    void processCommand(String command) {
    if (command.startsWith("R")) {
    String valueString = command.substring(1, command.length() - 1);
    long simToolsValue = valueString.toInt();

    // Ziel berechnen
    long targetPos = (simToolsValue - 512) * STEPS_PER_UNIT;
    stepper.moveTo(targetPos);
    }
    }
    • Like Like x 1
  10. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    The code for 2 motor and 1 Arduino

    // ======================================================================================
    // SIMTOOLS V3 - DUAL STEPPER CONTROL (R & L) - NEMA34 / DMA860H
    // ======================================================================================

    #include <AccelStepper.h>

    // --- PIN-BELEGUNG MOTOR RECHTS (R) ---
    #define DIR_PIN_R 8
    #define STEP_PIN_R 9
    #define HOMING_PIN_R 10

    // --- PIN-BELEGUNG MOTOR LINKS (L) ---
    #define DIR_PIN_L 5
    #define STEP_PIN_L 6
    #define HOMING_PIN_L 7

    // --- PARAMETER ---
    #define STEPS_PER_UNIT 4 // Skalierung: 1023 Einheiten * 4 = 4092 Schritte
    #define HOMING_SPEED 800 // Kraftvolles Homing für NEMA34
    #define MAX_SPEED 6000
    #define ACCELERATION 4000
    const unsigned long debounceDelay = 100;

    // Stepper Instanzen
    AccelStepper stepperR(AccelStepper::DRIVER, STEP_PIN_R, DIR_PIN_R);
    AccelStepper stepperL(AccelStepper::DRIVER, STEP_PIN_L, DIR_PIN_L);

    String inputString = "";
    bool stringComplete = false;
    bool sensorActiveLow = true; // RAMPS Opto-Endstop Logik

    void setup() {
    Serial.begin(19200);
    pinMode(HOMING_PIN_R, INPUT_PULLUP);
    pinMode(HOMING_PIN_L, INPUT_PULLUP);
    inputString.reserve(30);

    stepperR.setMaxSpeed(MAX_SPEED);
    stepperR.setAcceleration(ACCELERATION);
    stepperL.setMaxSpeed(MAX_SPEED);
    stepperL.setAcceleration(ACCELERATION);

    // --- START-HOMING ---
    Serial.println("Homing Motoren...");
    runHoming(stepperR, HOMING_PIN_R);
    runHoming(stepperL, HOMING_PIN_L);
    Serial.println("System Bereit.");
    }

    void loop() {
    // Motoren ständig aktualisieren
    stepperR.run();
    stepperL.run();

    // Verarbeite SimTools Daten wenn vorhanden
    if (stringComplete) {
    parseSimToolsCommand(inputString);
    inputString = "";
    stringComplete = false;
    }
    }

    // Funktion zum Suchen der Nullpunkte
    void runHoming(AccelStepper &s, int pin) {
    s.setSpeed(-HOMING_SPEED);
    while (digitalRead(pin) == (sensorActiveLow ? HIGH : LOW)) {
    s.runSpeed();
    }
    s.setCurrentPosition(0);
    s.moveTo(300); // Sicherheitsabstand vom Sensor
    while (s.distanceToGo() != 0) { s.run(); }
    }

    // Erkennt R<value>~ und L<value>~ im selben Datenstrom
    void parseSimToolsCommand(String command) {
    // Suche Rechts-Wert
    int rIdx = command.indexOf('R');
    if (rIdx != -1) {
    int rEnd = command.indexOf('~', rIdx);
    if (rEnd != -1) {
    long val = command.substring(rIdx + 1, rEnd).toInt();
    stepperR.moveTo((val - 512) * STEPS_PER_UNIT);
    }
    }

    // Suche Links-Wert
    int lIdx = command.indexOf('L');
    if (lIdx != -1) {
    int lEnd = command.indexOf('~', lIdx);
    if (lEnd != -1) {
    long val = command.substring(lIdx + 1, lEnd).toInt();
    stepperL.moveTo((val - 512) * STEPS_PER_UNIT);
    }
    }
    }

    // Serielle Daten sammeln
    void serialEvent() {
    while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '~' && inputString.length() > 3) {
    stringComplete = true;
    }
    }
    }
  11. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    My YouTube account was permanently banned because of my last video. In the video, I was wearing long, ripped pants, so you could see my thigh skin for about two seconds. In my opinion, YouTube is a complete idiot.
  12. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
  13. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    Is there a rig plugin for SimTools for the Circular Stewart Platform, similar to the one for FlyPT Mover?
  14. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    // ======================================================================================
    // SIMTOOLS V3 - TRIPLE STEPPER CONTROL (A, B, C) - HIGH SPEED (2025)
    // ======================================================================================
    // – Hardware: Arduino Nano V3, 3x DMA860H Driver, 3x NEMA 34
    // – Kommunikation: 115200 Baud (High Speed zur Latenzminimierung)
    // – Befehlsstruktur: A<Axis1a>~B<Axis2a>~C<Axis3a>~
    //
    // – SimTools Interface Einstellungen:
    // – Bits per second: 115200 <-- WICHTIG: Hier anpassen!
    // – Data bits: 8 / Stop bit: 1 / Parity: None
    // – Interface Output: A<Axis1a>~B<Axis2a>~C<Axis3a>~
    // ======================================================================================

    #include <AccelStepper.h>

    // --- PIN-BELEGUNG ---
    #define STEP_A 9 // Motor A (z.B. Rechts)
    #define DIR_A 8
    #define HOME_A 10

    #define STEP_B 6 // Motor B (z.B. Links - Invertierung via SimTools)
    #define DIR_B 5
    #define HOME_B 7

    #define STEP_C 3 // Motor C (z.B. Hinten/Heave)
    #define DIR_C 2
    #define HOME_C 4

    // --- PARAMETER ---
    #define STEPS_PER_UNIT 4
    #define HOMING_SPEED 800
    #define MAX_SPEED 6000
    #define ACCELERATION 4500 // NEMA 34 Rampen

    // Stepper Instanzen
    AccelStepper stepperA(AccelStepper::DRIVER, STEP_A, DIR_A);
    AccelStepper stepperB(AccelStepper::DRIVER, STEP_B, DIR_B);
    AccelStepper stepperC(AccelStepper::DRIVER, STEP_C, DIR_C);

    String inputString = "";
    bool stringComplete = false;
    bool sensorActiveLow = true;

    void setup() {
    // Erhöhte Baudrate für schnellere Reaktionszeiten
    Serial.begin(115200);

    pinMode(HOME_A, INPUT_PULLUP);
    pinMode(HOME_B, INPUT_PULLUP);
    pinMode(HOME_C, INPUT_PULLUP);

    inputString.reserve(64); // Puffer für 3 Achsen vergrößert

    // Konfiguration der Geschwindigkeiten
    configureStepper(stepperA);
    configureStepper(stepperB);
    configureStepper(stepperC);

    // --- START-HOMING (Sequenziell zur Stromersparnis) ---
    Serial.println("Homing startet...");
    runHoming(stepperA, HOME_A);
    runHoming(stepperB, HOME_B);
    runHoming(stepperC, HOME_C);

    Serial.println("System Bereit - 115200 Baud");
    }

    void loop() {
    // Haupt-Update-Zyklus
    stepperA.run();
    stepperB.run();
    stepperC.run();

    if (stringComplete) {
    parseSimToolsCommand(inputString);
    inputString = "";
    stringComplete = false;
    }
    }

    void configureStepper(AccelStepper &s) {
    s.setMaxSpeed(MAX_SPEED);
    s.setAcceleration(ACCELERATION);
    }

    void runHoming(AccelStepper &s, int pin) {
    s.setSpeed(-HOMING_SPEED);
    // Suche den Endstop
    while (digitalRead(pin) == (sensorActiveLow ? HIGH : LOW)) {
    s.runSpeed();
    }
    s.setCurrentPosition(0);
    s.moveTo(300); // Sicherheitsabstand vom Sensor
    while (s.distanceToGo() != 0) { s.run(); }
    }

    void parseSimToolsCommand(String command) {
    // Verarbeitet A, B und C Marker unabhängig
    updateMotor(command, 'A', stepperA);
    updateMotor(command, 'B', stepperB);
    updateMotor(command, 'C', stepperC);
    }

    void updateMotor(String cmd, char identifier, AccelStepper &s) {
    int idx = cmd.indexOf(identifier);
    if (idx != -1) {
    int endIdx = cmd.indexOf('~', idx);
    if (endIdx != -1) {
    long val = cmd.substring(idx + 1, endIdx).toInt();
    // Umrechnung: SimTools (0-1023) auf Stepper-Schritte um den Mittelpunkt
    s.moveTo((val - 512) * STEPS_PER_UNIT);
    }
    }
    }

    void serialEvent() {
    while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    // Paket ist abgeschlossen, wenn Tilde erscheint
    if (inChar == '~') {
    stringComplete = true;
    }
    }
    }
  15. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    // ======================================================================================
    // SIMTOOLS V3 - 6-AXIS STEPPER CONTROL (A-F) - HIGH SPEED (2025)
    // ======================================================================================
    // – Baudrate: 115200 (SimTools & Serial Monitor)
    // – Befehl: A<Axis1a>~B<Axis2a>~C<Axis3a>~D<Axis4a>~E<Axis5a>~F<Axis6a>~
    // ======================================================================================

    #include <AccelStepper.h>

    // --- PIN-DEFINITIONEN ---
    // Motor A
    #define STEP_A 2
    #define DIR_A 3
    #define HOME_A A0 // Analoge Pins als Digital-Input für Endstops genutzt
    // Motor B
    #define STEP_B 4
    #define DIR_B 5
    #define HOME_B A1
    // Motor C
    #define STEP_C 6
    #define DIR_C 7
    #define HOME_C A2
    // Motor D
    #define STEP_D 8
    #define DIR_D 9
    #define HOME_D A3
    // Motor E
    #define STEP_E 10
    #define DIR_E 11
    #define HOME_E A4
    // Motor F
    #define STEP_F 12
    #define DIR_F 13
    #define HOME_F A5

    // --- PARAMETER ---
    #define STEPS_PER_UNIT 4
    #define HOMING_SPEED 800
    #define MAX_SPEED 6000
    #define ACCELERATION 4000

    // Stepper Instanzen
    AccelStepper sA(AccelStepper::DRIVER, STEP_A, DIR_A);
    AccelStepper sB(AccelStepper::DRIVER, STEP_B, DIR_B);
    AccelStepper sC(AccelStepper::DRIVER, STEP_C, DIR_C);
    AccelStepper sD(AccelStepper::DRIVER, STEP_D, DIR_D);
    AccelStepper sE(AccelStepper::DRIVER, STEP_E, DIR_E);
    AccelStepper sF(AccelStepper::DRIVER, STEP_F, DIR_F);

    String inputString = "";
    bool stringComplete = false;
    bool sensorActiveLow = true;

    void setup() {
    Serial.begin(115200);
    inputString.reserve(100);

    // Pin-Konfiguration Endstops
    int homePins[] = {HOME_A, HOME_B, HOME_C, HOME_D, HOME_E, HOME_F};
    for(int i=0; i<6; i++) pinMode(homePins, INPUT_PULLUP);

    // Motoren-Setup
    configure(sA); configure(sB); configure(sC);
    configure(sD); configure(sE); configure(sF);

    // Sequenzielles Homing
    Serial.println("6-Axis Homing...");
    runHoming(sA, HOME_A); runHoming(sB, HOME_B); runHoming(sC, HOME_C);
    runHoming(sD, HOME_D); runHoming(sE, HOME_E); runHoming(sF, HOME_F);

    Serial.println("6-Axis System Ready (115200)");
    }

    void loop() {
    sA.run(); sB.run(); sC.run();
    sD.run(); sE.run(); sF.run();

    if (stringComplete) {
    parseCommands(inputString);
    inputString = "";
    stringComplete = false;
    }
    }

    void configure(AccelStepper &s) {
    s.setMaxSpeed(MAX_SPEED);
    s.setAcceleration(ACCELERATION);
    }

    void runHoming(AccelStepper &s, int pin) {
    s.setSpeed(-HOMING_SPEED);
    while (digitalRead(pin) == (sensorActiveLow ? HIGH : LOW)) {
    s.runSpeed();
    }
    s.setCurrentPosition(0);
    s.moveTo(300);
    while (s.distanceToGo() != 0) { s.run(); }
    }

    void parseCommands(String cmd) {
    updateM(cmd, 'A', sA); updateM(cmd, 'B', sB); updateM(cmd, 'C', sC);
    updateM(cmd, 'D', sD); updateM(cmd, 'E', sE); updateM(cmd, 'F', sF);
    }

    void updateM(String cmd, char id, AccelStepper &s) {
    int idx = cmd.indexOf(id);
    if (idx != -1) {
    int endIdx = cmd.indexOf('~', idx);
    if (endIdx != -1) {
    long val = cmd.substring(idx + 1, endIdx).toInt();
    s.moveTo((val - 512) * STEPS_PER_UNIT);
    }
    }
    }

    void serialEvent() {
    while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '~') stringComplete = true;
    }
    }
  16. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    // ======================================================================================
    // SIMTOOLS V3 - 6-AXIS STEPPER CONTROL (A-F) - HIGH SPEED (2025)
    // ======================================================================================
    // – Baudrate: 115200 (SimTools & Serial Monitor)
    // – Befehl: A<Axis1a>~B<Axis2a>~C<Axis3a>~D<Axis4a>~E<Axis5a>~F<Axis6a>~
    // ======================================================================================

    #include <AccelStepper.h>

    // --- PIN-DEFINITIONEN ---
    // Motor A
    #define STEP_A 2
    #define DIR_A 3
    #define HOME_A A0 // Analoge Pins als Digital-Input für Endstops genutzt
    // Motor B
    #define STEP_B 4
    #define DIR_B 5
    #define HOME_B A1
    // Motor C
    #define STEP_C 6
    #define DIR_C 7
    #define HOME_C A2
    // Motor D
    #define STEP_D 8
    #define DIR_D 9
    #define HOME_D A3
    // Motor E
    #define STEP_E 10
    #define DIR_E 11
    #define HOME_E A4
    // Motor F
    #define STEP_F 12
    #define DIR_F 13
    #define HOME_F A5

    // --- PARAMETER ---
    #define STEPS_PER_UNIT 4
    #define HOMING_SPEED 800
    #define MAX_SPEED 6000
    #define ACCELERATION 4000

    // Stepper Instanzen
    AccelStepper sA(AccelStepper::DRIVER, STEP_A, DIR_A);
    AccelStepper sB(AccelStepper::DRIVER, STEP_B, DIR_B);
    AccelStepper sC(AccelStepper::DRIVER, STEP_C, DIR_C);
    AccelStepper sD(AccelStepper::DRIVER, STEP_D, DIR_D);
    AccelStepper sE(AccelStepper::DRIVER, STEP_E, DIR_E);
    AccelStepper sF(AccelStepper::DRIVER, STEP_F, DIR_F);

    String inputString = "";
    bool stringComplete = false;
    bool sensorActiveLow = true;

    void setup() {
    Serial.begin(115200);
    inputString.reserve(100);

    // Pin-Konfiguration Endstops
    int homePins[] = {HOME_A, HOME_B, HOME_C, HOME_D, HOME_E, HOME_F};
    for(int i=0; i<6; i++) pinMode(homePins, INPUT_PULLUP);

    // Motoren-Setup
    configure(sA); configure(sB); configure(sC);
    configure(sD); configure(sE); configure(sF);

    // Sequenzielles Homing
    Serial.println("6-Axis Homing...");
    runHoming(sA, HOME_A); runHoming(sB, HOME_B); runHoming(sC, HOME_C);
    runHoming(sD, HOME_D); runHoming(sE, HOME_E); runHoming(sF, HOME_F);

    Serial.println("6-Axis System Ready (115200)");
    }

    void loop() {
    sA.run(); sB.run(); sC.run();
    sD.run(); sE.run(); sF.run();

    if (stringComplete) {
    parseCommands(inputString);
    inputString = "";
    stringComplete = false;
    }
    }

    void configure(AccelStepper &s) {
    s.setMaxSpeed(MAX_SPEED);
    s.setAcceleration(ACCELERATION);
    }

    void runHoming(AccelStepper &s, int pin) {
    s.setSpeed(-HOMING_SPEED);
    while (digitalRead(pin) == (sensorActiveLow ? HIGH : LOW)) {
    s.runSpeed();
    }
    s.setCurrentPosition(0);
    s.moveTo(300);
    while (s.distanceToGo() != 0) { s.run(); }
    }

    void parseCommands(String cmd) {
    updateM(cmd, 'A', sA); updateM(cmd, 'B', sB); updateM(cmd, 'C', sC);
    updateM(cmd, 'D', sD); updateM(cmd, 'E', sE); updateM(cmd, 'F', sF);
    }

    void updateM(String cmd, char id, AccelStepper &s) {
    int idx = cmd.indexOf(id);
    if (idx != -1) {
    int endIdx = cmd.indexOf('~', idx);
    if (endIdx != -1) {
    long val = cmd.substring(idx + 1, endIdx).toInt();
    s.moveTo((val - 512) * STEPS_PER_UNIT);
    }
    }
    }

    void serialEvent() {
    while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
    if (inChar == '~') stringComplete = true;
    }
    }
  17. accelero

    accelero Member

    Joined:
    Jun 30, 2015
    Messages:
    63
    Location:
    france
    Balance:
    287Coins
    Ratings:
    +12 / 0 / -0
    My Motion Simulator:
    2DOF, AC motor, Arduino
    really great project , very innovative and good looking
    all the parts are 3D printed? and what about teeth of the large ring, will they stand the pressure?
  18. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    Thanks. Yes, all the red parts are made of PETG and were 3D printed. The gears and the ring gear are in excellent condition. After about 100 hours of operation, I haven't noticed any wear. So they're really holding up well. The main load is on the rollers, so the stress on the plastic is relatively low. That was one of the reasons I chose this kinematics setup. Unfortunately, the kinematics aren't fully supported in SimTools; it only shows up as Stuart 6 DOF, which means the yaw axis isn't being fully utilized.
  19. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    With my old simulation rig using a worm gear, the wear and tear was enormous and therefore quite expensive.
  20. xxpelle

    xxpelle Discord "TPMax#9574" Gold Contributor

    Joined:
    Dec 24, 2017
    Messages:
    135
    Occupation:
    Discord "TPMax#9574"
    Location:
    Germany
    Balance:
    713Coins
    Ratings:
    +154 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino, Motion platform, 6DOF
    Although the worm gear could be reversed and reused on the other side, this was very time-consuming and the replacement parts were expensive. The entire load and weight always rested entirely on the gear. With the new geometry, the main load now rests on the rollers; the motors only need to provide the driving force. A small portion of the weight is still transferred to the gear, but only a very small amount. The greater the distance between the motors, the greater the force acting on the gear. However, this can easily be absorbed by rubber bands, as they generate higher tension when stretched. Therefore, the more force required to support the weight, the more force the rubber band absorbs. I already have ideas on how to improve this even further; the rubber band wasn't even part of the original design.