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

Showroom FlyPT - 6DOF Brushless DIY Actuators

Discussion in 'DIY Motion Simulator Projects' started by pmvcda, Aug 29, 2017.

  1. benmax

    benmax Active Member Gold Contributor

    Joined:
    Oct 15, 2013
    Messages:
    188
    Balance:
    1,552Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF
    Yes you’re right !
    My screw is LFM102 . Pitch 2mm diam.10 mm - travel 100mm.
    Yes i use your schematic except the wiring for resistors . The one gave by Gabor is ok .
    And yes I changed the number of actuator in the code .
    The message I got back when using the monitor into arduino is :
    Actuator 0 min=-561 Max=561
  2. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    2,158
    Location:
    Portugal
    Balance:
    15,264Coins
    Ratings:
    +2,532 / 17 / -0
    My Motion Simulator:
    6DOF
    @benmax

    Was looking at the code, the schematics,
    don't know how to help.
    Please verify all the wiring again.
    Replace level shifters, some can be faulty.
    Can't see anything wrong.
    It's like you don't send speed to the drive.
    Did you put the jumpers in the correct position? (in the 8015A)
  3. benmax

    benmax Active Member Gold Contributor

    Joined:
    Oct 15, 2013
    Messages:
    188
    Balance:
    1,552Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF
    Yes the 2 jumpers are OFF what means avi port enable and 60/300degres sensor phrasing’s
    And what about the string between esp32 and mover , tested both without success
  4. benmax

    benmax Active Member Gold Contributor

    Joined:
    Oct 15, 2013
    Messages:
    188
    Balance:
    1,552Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF
    If I don’t send the speed correctly the calibration won’t run as well as it happens .
    During calibration the speed is ok ( so the speed sent correctly )
    When touching the max switch the rotation is well reversed so the pin F/R is ok !
    And at the end of calibration the process calibration stops after hitting the min switch as wanted .
    • Agree Agree x 1
    Last edited: Apr 4, 2020
  5. benmax

    benmax Active Member Gold Contributor

    Joined:
    Oct 15, 2013
    Messages:
    188
    Balance:
    1,552Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF
    What I don’t understand is why the communication seems to be ok making the calibration process ( speed , F/R ) between esp32 and driver and why connecting mover anything happens .
    Normally connecting mover the actuator should immediatly goes to the middle position right ?
  6. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    2,158
    Location:
    Portugal
    Balance:
    15,264Coins
    Ratings:
    +2,532 / 17 / -0
    My Motion Simulator:
    6DOF
    Send me the current setup you have in Mover please.
    Just to be sure
  7. benmax

    benmax Active Member Gold Contributor

    Joined:
    Oct 15, 2013
    Messages:
    188
    Balance:
    1,552Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF
  8. benmax

    benmax Active Member Gold Contributor

    Joined:
    Oct 15, 2013
    Messages:
    188
    Balance:
    1,552Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF
  9. dzq_stone

    dzq_stone New Member

    Joined:
    Jan 22, 2020
    Messages:
    10
    Balance:
    1Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    2DOF
    Would mind tell me where is the mistake during my FlyPT Mover 2.9.5 setting , my problem is the motor almost don't mover although there are some data have sent to them. i use one actuator to operation.

    the situation is i have passed calibration, the the motor stopped when i push the minimum limit switch , but the question is when i send the data from the FlyPT , the motor almost not work . pls check the attachment.

    first, i use the data of Axis1a, the motor move a little . Second, using the simple direct: wind value , at the beginning motor stop, then change the value, no mater how huge of the number , the motor still move a little . how to fix it, hope someone can indicate, thanks a lot .

    Attached Files:

  10. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    2,158
    Location:
    Portugal
    Balance:
    15,264Coins
    Ratings:
    +2,532 / 17 / -0
    My Motion Simulator:
    6DOF
    Change bit output to 15
    And try again.
    This in the rig window and in the direct
  11. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    2,158
    Location:
    Portugal
    Balance:
    15,264Coins
    Ratings:
    +2,532 / 17 / -0
    My Motion Simulator:
    6DOF
    Also, you should use this string:

    <255><255><axis1a><0><0><0><0>

    Replace axis1a with wind in case of using the direct with the key wind
  12. dzq_stone

    dzq_stone New Member

    Joined:
    Jan 22, 2020
    Messages:
    10
    Balance:
    1Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    2DOF
    Thanks a lot , yes i have changed the code

    Serial output configuration
    // ===========================
    // Interface Type: Serial
    // ComPort: The one used by your ESP32
    // BitsPerSec: 921600 - If you want feedback on the serial monitor of the Arduino IDE, you have to change this to 500000 in the defines
    // Data Bits: 8
    // Parity: None
    // Stop Bits: 1
    // Bit Range: 15
    // Type: Binary
    // Interface string format: <255> <255> <Axis1a> <0> <0> <0> <0>
    /// Output Rate: Can be down to 1 ms
  13. benmax

    benmax Active Member Gold Contributor

    Joined:
    Oct 15, 2013
    Messages:
    188
    Balance:
    1,552Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF
    You describe what I’m facing to .
    If you solve it could you tell me how you ‘re solved it
    Thx
  14. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    2,158
    Location:
    Portugal
    Balance:
    15,264Coins
    Ratings:
    +2,532 / 17 / -0
    My Motion Simulator:
    6DOF
    But he's using the wrong string and bit value!
  15. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    2,158
    Location:
    Portugal
    Balance:
    15,264Coins
    Ratings:
    +2,532 / 17 / -0
    My Motion Simulator:
    6DOF

    Don't change anything in the code just this line:

    #define NUMBERACTUATORS 3

    to

    #define NUMBERACTUATORS 1

    In Mover use this:
    upload_2020-4-4_15-45-10.png



    The code you show in your post are just comments, not code
  16. dzq_stone

    dzq_stone New Member

    Joined:
    Jan 22, 2020
    Messages:
    10
    Balance:
    1Coins
    Ratings:
    +3 / 0 / -0
    My Motion Simulator:
    2DOF
    hi pmvcda, thanks for your help , but after change the data as the picture shown , it seems didn't work ,the motor still like before.

    BTW ,the value of min & max range , depend on the time of my push the limit switch , longer maybe min=-1075 max=1075, short, maybe the value is -357 & 357 , does this range will impact the FlyPT interface and make it don't work ?
  17. benmax

    benmax Active Member Gold Contributor

    Joined:
    Oct 15, 2013
    Messages:
    188
    Balance:
    1,552Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF
    I put my oscilloscope on the pwm output .
    Below this is the PWM sent by the esp32 for calibration .
    As the process is well done for calibration you can check that the pwm sent from esp32 to driver.
    I connected Mover and the debug window shows me right that data sent to the esp32 when moving the slider .
    But esp32 sent nothing to the driver . I put the oscilloscope and there is no pwm sent .
    I don't know why but this is i noticed .

    Attached Files:

    • pwm.JPG
      pwm.JPG
      File size:
      171.4 KB
      Views:
      299
    • Informative Informative x 1
  18. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    2,158
    Location:
    Portugal
    Balance:
    15,264Coins
    Ratings:
    +2,532 / 17 / -0
    My Motion Simulator:
    6DOF
    @benmax and @dzq_stone

    Could you both try this code:
    Code:
    // ================================
    // DIY 6DOF Motion Sim by FlyPT
    // TEST VERSION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    // Internal PID calculation
    // ================================
    // SimTools2 ESP32 code to control up to 3 actuators
    // Actuators use brushless motors controlled by BLDC8015A drivers
    // The BLDC8015A receives speed and direction in separated pins
    // Position is obtained from internall hall sensors
    
    
    // ===========================
    // Serial output configuration
    // ===========================
    // Interface Type: Serial
    // ComPort: The one used by your ESP32
    // BitsPerSec: 921600 - If you want feedback on the serial monitor of the Arduino IDE, you have to change this to 500000 in the defines
    // Data Bits: 8
    // Parity: None
    // Stop Bits: 1
    // Bit Range: 15
    // Type: Binary
    // Interface string format: <255><255><Axis1a><Axis2a><Axis3a>
    /// Output Rate: Can be down to 1 ms
    
    
    // ===============
    // PID calculation
    // ===============
    // PID calculation is performed in the ESP32
    // In the PID calculation, we are calculating the speed that we want for the actuator.
    // We have a pretended position and a current position of the actuator and speed is calculated depending on those values.
    // Speed can be from -255 to 255, where negative speed is actuator going down and positive going up.
    // Values beyond this range are cropped.
    // Define each parameter PID in the defines, where:
    // P is the proportional part. The amount of P depends on  the distance
    
    
    // =======
    // Defines
    // =======
    #define P 256                   // Proportional
    #define I 0                     // Integral
    #define D 256                   // Diferential
    #define SERIAL_SPEED 921600     // Define to set up the serial speed comunication
    #define CALIBRATION_SPEED 50    // Speed used to search for minimum and maximum values (0 to 255) if calibration is to fast or to slow, adjust this value
    #define MAXIMUM_BIT_VALUE 32767 // Size of position values received (15 bits, above this, we use it to send other controls/requests besides position)
    #define UP HIGH                 // Define to set up direction as HIGH
    #define DOWN LOW                // Define to set down direction as LOW
    #define PWM_RESOLUTION 8        // 0 to 255
    #define PWM_FREQUENCY 1000      // The 8015A accepts up to 1 KHz
    #define LIMITS_PIN 0            // Array index of pin to capture position from pot wich defines the limits
    #define HALL_1_PIN 1            // Array index of pin used for hall 1 interrupt
    #define HALL_2_PIN 2            // Array index of pin used for hall 2 interrupt
    #define HALL_3_PIN 3            // Array index of pin used for hall 3 interrupt
    #define LAST_ANGLE 4            // Array index of last angle that was detected
    #define LAST_SUM 5              // Array index of last sum to know last direction it took
    #define DIRECTION_PIN 6         // Array index of Pin to se direction
    #define SPEED_PIN 7             // Array index of Pin to set speed with PWM
    #define PWM_CHANNEL 8           // Array index of channel used to generate PWM
    #define MINIMUM_POSITION 9      // Array index of minimum position
    #define MAXIMUM_POSITION 10     // Array index of maximum position
    #define CURRENT_POSITION 11     // Array index of current position
    #define PRETENDED_POSITION 12   // Array index of pretended position
    #define P_PID 13                // Array index of P from PID
    #define I_PID 14                // Array index of I from PID
    #define D_PID 15                // Array index of D from PID
    #define INTEGRATED_ERROR 16     // Array index of sum of differences between pretended and current position
    #define LAST_ERROR 17           // Array index of last difference between pretended and current position
    #define SPEED 18                // Array index of speed of motor rotation
    #define FOUND 19                // Array index of foud, used for in actuator calibration
    #define NUMBERACTUATORS 1       // Number of actuators (for one board, please don't change, current code does not support less than 3 actuators. To use less, just disconnect them at hardware level)
    
    
    // ======================
    // Actuators information:
    // ======================
    // 0  - LIMITS_PIN          - Pin to capture position from pot
    // 1  - HALL_1_PIN          - Pin used for hall 1 interrupt
    // 2  - HALL_2_PIN          - Pin used for hall 2 interrupt
    // 3  - HALL_3_PIN          - Pin used for hall 3 interrupt
    // 4  - LAST_ANGLE          - Last angle that was detected
    // 5  - LAST_SUM            - Last sum to know last direction it took
    // 6  - DIRECTION_PIN       - Pin to se direction
    // 7  - SPEED_PIN           - Pin to set speed with PWM
    // 8  - PWM_CHANNEL         - Channel used to generate PWM
    // 9  - MINIMUM_POSITION    - Minimum position
    // 10 - MAXIMUM_POSITION    - Maximum position
    // 11 - CURRENT_POSITION    - Current position
    // 12 - PRETENDED_POSITION  - Pretended position
    // 13 - P_PID               - P from PID
    // 14 - I_PID               - I from PID
    // 15 - D_PID               - D from PID
    // 16 - INTEGRATED_ERROR    - Sum of differences between pretended and current position
    // 17 - LAST_ERROR          - Last difference between pretended and current position
    // 18 - SPEED               - Speed of motor rotation
    // 19 - FOUND               - Used as help for calibraion
    static int actuator[3][20] = {
    //  00  01  02  03  04  05  06  07  08  09  10  11  12  13  14  15  16  17  18  19
      {  4, 27, 26, 25,  5,  0, 19, 17,  0, -1, -1,  0,  0,  P,  I,  D,  0,  0,  0,  0 },  // Actuator 1
      { 36, 35, 34, 39,  5,  0, 18,  5,  1, -1, -1,  0,  0,  P,  I,  D,  0,  0,  0,  0 },  // Actuator 2
      { 15, 23, 22, 21,  5,  0, 32, 33,  2, -1, -1,  0,  0,  P,  I,  D,  0,  0,  0,  0 }   // Actuator 3
    };
    
    
    // =======================================
    // Variables for info received from serial
    // =======================================
    static int bufferPrevious = 0;      // To hold previous read fom serial command
    static int bufferCurrent = 0;       // To hold current read fom serial command
    static int bufferCount = 0;         // To hold current position in bufferCommand array
    static int bufferCommand[6] = {0};  // To hold received info from serial
    
    
    // ===========================================================================
    // Variables used in PID calculation to avoid repeated definitions in the loop
    // ===========================================================================
    static int limitValue = 1023;
    static int error = 0;
    static int p = 0;
    static int i = 0;
    static int d = 0;
    
    
    // ========================================================
    // Array used to calculate motor position from hall sensors
    // ========================================================
    // Maps to get increment off position from comparing previous hall sensor state with current state
    // In the table, vertical is the new value, horizontal is the old one
    // Stores for 0 and 7, althought they should not ocurr, digital read might get them. They are ignored with zero change.
    // State sequence going up
    // 5=101
    // 1=001
    // 3=011
    // 2=010
    // 6=110
    // 4=100
    // First index for new state, second for old state ([new][old])
    static int stepUp[8][8] = {
      {  0,  0,  0,  0,  0,  0,  0,  0},
      {  0,  0, -2, -1,  2,  1,  3,  0},
      {  0,  2,  0,  1, -2,  3, -1,  0},
      {  0,  1, -1,  0,  3,  2, -2,  0},
      {  0, -2,  2,  3,  0, -1,  1,  0},
      {  0, -1,  3, -2,  1,  0,  2,  0},
      {  0,  3,  1,  2, -1, -2,  0,  0},
      {  0,  0,  0,  0,  0,  0,  0,  0}
    };
    static int stepDown[8][8] = {
      {  0,  0,  0,  0,  0,  0,  0,  0},
      {  0,  0, -2, -1,  2,  1, -3,  0},
      {  0,  2,  0,  1, -2, -3, -1,  0},
      {  0,  1, -1,  0, -3,  2, -2,  0},
      {  0, -2,  2, -3,  0, -1,  1,  0},
      {  0, -1, -3, -2,  1,  0,  2,  0},
      {  0, -3,  1,  2, -1, -2,  0,  0},
      {  0,  0,  0,  0,  0,  0,  0,  0}
    };
    
    
    // ==============
    // Initialization
    // ==============
    void setup()
    {
      // Disable watchdog in both processors
      disableCore0WDT();
      disableCore1WDT();
    
      // Setup serial communication
      Serial.begin(SERIAL_SPEED, SERIAL_8N1);
    
      // Initialize
      for (int n = 0; n < NUMBERACTUATORS; n++)
      {
        // Initialize pins
        pinMode(actuator[n][LIMITS_PIN], INPUT);
        pinMode(actuator[n][HALL_1_PIN], INPUT);
        pinMode(actuator[n][HALL_2_PIN], INPUT);
        pinMode(actuator[n][HALL_3_PIN], INPUT);
        pinMode(actuator[n][DIRECTION_PIN], OUTPUT);
        pinMode(actuator[n][SPEED_PIN], OUTPUT);
    
        // Setup PWM
        ledcSetup(actuator[n][PWM_CHANNEL], PWM_FREQUENCY, PWM_RESOLUTION);
        ledcAttachPin(actuator[n][SPEED_PIN], actuator[n][PWM_CHANNEL]);
        ledcWrite(actuator[n][PWM_CHANNEL], 0);
      }
    
      // Create thread that gets position from hall sensors to run in the core 0
      // It will run in paralell with the main loop that uses core 1 by default
      xTaskCreatePinnedToCore(
        TaskUpdatePositions,  // Task function
        "UpdatePositions",    // Name
        10000,                // Stack size
        NULL,                 // Task input parameter
        1,                    // Priority of the task
        NULL,                 // Task handle
        0);                   // Core
    
      // Initialize pin to light up onboard led and blink for 5 seconds before starting calibration
      pinMode(2, OUTPUT);
      for (byte n = 5; n > 0; n--)
      {
        delay(500);
        digitalWrite(2, HIGH);
        delay(500);
        digitalWrite(2, LOW);
      }
      digitalWrite(2, LOW);
     
      // Calibrate actuators, searching for minimums and maximums
      calibrate();
     
      // Put actuators in the minimum after calibration (for easy access to the rig)
      for (int n = 0; n < NUMBERACTUATORS; n++) actuator[n][PRETENDED_POSITION] = actuator[n][MINIMUM_POSITION];
    }
    
    
    // =========
    // Calibrate
    // =========
    void calibrate()
    {
      // Move all actuators to maximum
      // =============================
      for (int n = 0; n < NUMBERACTUATORS; n++)
      {
        digitalWrite (actuator[n][DIRECTION_PIN], UP);
        ledcWrite(actuator[n][PWM_CHANNEL], CALIBRATION_SPEED);
        actuator[n][FOUND] = false;
      }
      int found = 0;
      while (found < NUMBERACTUATORS)
      {
        for (int n = 0; n < NUMBERACTUATORS; n++)
        {
          // Read limit switch position (we are looking for big value 4095)
          // We read more than one time to be sure (4 times in this case)
          if (!actuator[n][FOUND] && (analogRead(actuator[n][LIMITS_PIN]) + analogRead(actuator[n][LIMITS_PIN]) + analogRead(actuator[n][LIMITS_PIN]) + analogRead(actuator[n][LIMITS_PIN])) / 4 >= 4095)
          {
            ledcWrite(actuator[n][PWM_CHANNEL], 0);
            actuator[n][CURRENT_POSITION] = 0;
            actuator[n][FOUND] = true;
            found++;
          }
        }
      }
      // Move all actuators to minimum
      // =============================
      for (int n = 0; n < NUMBERACTUATORS; n++)
      {
        digitalWrite (actuator[n][DIRECTION_PIN], DOWN);
        ledcWrite(actuator[n][PWM_CHANNEL], CALIBRATION_SPEED);
        actuator[n][FOUND] = false;
      }
      found = 0;
      while (found < NUMBERACTUATORS)
      {
        for (int n = 0; n < NUMBERACTUATORS; n++)
        { 
          // Read limit switch position (we are looking for zero)
          if (!actuator[n][FOUND] && (analogRead(actuator[n][LIMITS_PIN]) + analogRead(actuator[n][LIMITS_PIN]) + analogRead(actuator[n][LIMITS_PIN]) + analogRead(actuator[n][LIMITS_PIN])) <= 0)
          {
            ledcWrite(actuator[n][PWM_CHANNEL], 0);
            actuator[n][MAXIMUM_POSITION] = -actuator[n][CURRENT_POSITION] / 2;
            actuator[n][MINIMUM_POSITION] = -actuator[n][MAXIMUM_POSITION];
            actuator[n][CURRENT_POSITION] = actuator[n][MINIMUM_POSITION];
            actuator[n][FOUND] = true;
            found++;
    
            // Send info to serial monitor for debug (use 500000 in serial speed to work with the Arduino IDE)
            Serial.println();
            Serial.print("Actuator ");
            Serial.print(n);
            Serial.print(":  Minimum=");
            Serial.print(actuator[n][MINIMUM_POSITION]);
            Serial.print("  Maximum=");
            Serial.println(actuator[n][MAXIMUM_POSITION]);
          }
        }
      }
    }
    
    
    // ======================
    // Update actuator action
    // ======================
    // Here we calculate the PID depending of desired vs current position and send respective signal to motor controller
    void updateActuatorSpeed(byte n)
    {
      // Calculate PID
      // =============
      error = actuator[n][PRETENDED_POSITION] - actuator[n][CURRENT_POSITION];
      actuator[n][INTEGRATED_ERROR] += error;
      p = actuator[n][P_PID] * error;
      i = actuator[n][I_PID] * constrain(actuator[n][INTEGRATED_ERROR], -255, 255);
      d = actuator[n][D_PID] * (error - actuator[n][LAST_ERROR]);
      actuator[n][LAST_ERROR] = error;
      actuator[n][SPEED] = FlyPT_Constrain((p + i + d) >> 8, -255, 255); // 2 4 8 16 32 64 128 256 Divide by 256
     
      // Apply changes to motor controller
      // =================================
      if (actuator[n][SPEED] > 0)
      {
        ledcWrite(actuator[n][PWM_CHANNEL], actuator[n][SPEED]);
        digitalWrite (actuator[n][DIRECTION_PIN], UP);
      }
      else
      {
        ledcWrite(actuator[n][PWM_CHANNEL], -actuator[n][SPEED]);
        digitalWrite (actuator[n][DIRECTION_PIN], DOWN);
      }
     
      // Check limits
      // ============
      // Adjust position if minimum or maximum switch is activated in case of a drift in position calculation
      limitValue = (analogRead(actuator[n][LIMITS_PIN]) + analogRead(actuator[n][LIMITS_PIN]) + analogRead(actuator[n][LIMITS_PIN]) + analogRead(actuator[n][LIMITS_PIN])) >> 2;
      // If they are actuated, recalibrate position
      if (limitValue >= 4095) actuator[n][CURRENT_POSITION] = actuator[n][MAXIMUM_POSITION]; // We are at maximum position
      else if (limitValue <= 0) actuator[n][CURRENT_POSITION] = actuator[n][MINIMUM_POSITION]; // We are at minimum position
    }
    
    
    // ======================================================
    // Replacement for constrain function (seems to be buggy)
    // ======================================================
    int FlyPT_Constrain(int value, int low, int high)
    {
      return (value < low) ? low : (value > high) ? high : value;
    }
    
    
    // ====================================
    // Update current position of actuators
    // ====================================
    void updateCurrentPosition(byte n)
    {
      int angle = digitalRead(actuator[n][HALL_1_PIN]) * 4 + digitalRead(actuator[n][HALL_2_PIN]) * 2 + digitalRead(actuator[n][HALL_3_PIN]);
      if (actuator[n][LAST_SUM] > 0) actuator[n][LAST_SUM] = stepUp[angle][actuator[n][LAST_ANGLE]];
      else actuator[n][LAST_SUM] = stepDown[angle][actuator[n][LAST_ANGLE]];
      actuator[n][LAST_ANGLE] = angle;
      actuator[n][CURRENT_POSITION] += actuator[n][LAST_SUM];
    }
    
    
    // ===========================
    // Main loop running on core 1
    // ===========================
    // Here we get the simtools commands and make the actuator move
    void loop()
    {
      if (Serial.available())
      {
        bufferPrevious = bufferCurrent; // Store previous byte
        bufferCurrent = Serial.read(); // Get the new byte
        bufferCommand[bufferCount] = bufferCurrent; // Put the new byte in the array
        bufferCount++; // Change to next position in the array
        if(bufferCurrent==255 && bufferPrevious==255) bufferCount = 0; // Two 255 in sequence are the start of the position info
        if(bufferCount==NUMBERACTUATORS*2) // Having 6 bytes means we have the 3 positions and that we can update the pretended position
        {
            for (int n = 0; n < NUMBERACTUATORS; n++)
            { 
    
          actuator[n][PRETENDED_POSITION] = map((bufferCommand[n*2] * 256) + bufferCommand[n*2+1], 0, MAXIMUM_BIT_VALUE, actuator[n][MINIMUM_POSITION], actuator[n][MAXIMUM_POSITION]);
    
            }
        
          bufferCount=0;
        }
      }
    
      // Update orders sent to motor driver
      for (int n = 0; n < NUMBERACTUATORS; n++)
      { 
            updateActuatorSpeed(n);
      }
    }
    
    
    // ==============================================
    // Update positions thread loop running in core 0
    // ==============================================
    void TaskUpdatePositions(void * parameter)
    {
      while (true)
      {
        for (int n = 0; n < NUMBERACTUATORS; n++)
        { 
            updateCurrentPosition(n);
        }
      }
    }
    Already has 1 actuator.
    And please verify which pin is set for pwm.
    Are you both using the ESP32 DEVKIT v1?
    There's some pins variations around
  19. benmax

    benmax Active Member Gold Contributor

    Joined:
    Oct 15, 2013
    Messages:
    188
    Balance:
    1,552Coins
    Ratings:
    +59 / 0 / -0
    My Motion Simulator:
    2DOF
  20. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    2,158
    Location:
    Portugal
    Balance:
    15,264Coins
    Ratings:
    +2,532 / 17 / -0
    My Motion Simulator:
    6DOF