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

Anybody familiar with this servomotor?

Discussion in 'Motor actuators and drivers' started by superwhitewish, Mar 22, 2020.

  1. superwhitewish

    superwhitewish Member

    Joined:
    Jul 3, 2016
    Messages:
    60
    Occupation:
    Avionic Engineer
    Location:
    Malaysia
    Balance:
    225Coins
    Ratings:
    +49 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino, Motion platform
    Hello,

    While browsing in Aliexpress, I found this integrated drive servomotor that are quite low price.

    https://www.aliexpress.com/item/329...earchweb0_0,searchweb201602_,searchweb201603_

    Voltage is 36v dc
    Power is 180w
    Rated speed is 3000rpm
    Rated torque is 0.6nm

    I did some calculation at https://www.fxsolver.com/browse/formulas/Ball+Screw+-+Driving+Torque
    The motor paired with 5mm lead ball screw could lift around 50-60 kg of load. Combined 4 motors like the Dbox layout could lift around 200 - 240 kg of load if well balanced.

    So I write an Arduino code to see if I can run 4 of these motor on a single Uno. The code will regulate the speed of each servo while tracking the position and output pulses to the controller. I still dont have the PID routine but I just simulate the PID process with 250 microseconds delay. PID process is called every 500microseconds (2000 per sec).

    Code:
    #define MAX_SPEED 24000               // target is 150mm/s = 30rev/s(5mm lead) = 24000pulse/sec (based on servomotor with 800ppr)
    #define PID_PERIOD_uS 500
    
    int motorPulsePin[4];                 
    int motorDirectionPin[4];
    unsigned int motorPosition[4] = {0};  // target is 100mm travel = 20rev x 5mm screw lead
                                          // pulses = 20rev x 800ppr = 16000 pulses for 100mm travel.
    int motorSpeed[4] = {0};              // pulses per second
    int motorDirection[4] = {1,1,1,1};    // values are 1 or -1
    int motorAcceleration[4] = {0};       // pulse/s^2
    int motorPulse[4] = {1,1,1,1};        // 1 or 0
    
    unsigned long motorHalfPulseTime[4] = {0};
    unsigned long motorTimesUp[4];
    
    unsigned long PIDTimesUp;
    
    //======================================
    unsigned int pps[4] = {0};   //to calculate
    unsigned long ppsTimer = 0;  //actual pulse per sec
    
    void setup() {
      Serial.begin(115200);
    
      // wait until serial port opens for native USB devices
      while (! Serial)delay(1);
    
    }
    
    
    void PIDRun(){
     
      if(micros() - PIDTimesUp < PID_PERIOD_uS)
        return;
        
      PIDTimesUp += PID_PERIOD_uS;
     
      //simulate time for PID calculation
      delayMicroseconds(250);
    }
    
    
    void motorRun(int i){
     
      if(motorSpeed[i] <= 0)
        return;
     
      motorHalfPulseTime[i] = 500000 / motorSpeed[i]; //time in microsec.
    
      if(micros() - motorTimesUp[i] < motorHalfPulseTime[i])
        return;
    
      motorTimesUp[i] += motorHalfPulseTime[i];
    
      if(motorSpeed[i] > MAX_SPEED)
        motorSpeed[i] = MAX_SPEED;
    
      //send pulse to controller
      //digitalWrite(motorDirectionPin[i], motorDirection < 0 ? 0:1);//motorDirection is 1 or -1
      //digitalWrite(motorPulsePin[i], motorPulse);
     
      motorPulse[i] = 1 - motorPulse[i]; //toggle pulse signal
    
      //update motor position every time pulse is logic 1
      if(motorPulse[i]){
        motorPosition[i] += motorDirection[i];
    
        //calculate actual pulse per sec
        pps[i]++;
      }
    }
    
    void loop() {
     
      for(int i = 0; i < 4; i++)
        motorTimesUp[i] = micros();
        
      PIDTimesUp = micros();
        
      ppsTimer = millis();
    
      motorSpeed[0] = 2000;
      motorSpeed[1] = 2000;
      motorSpeed[2] = 2000;
      motorSpeed[3] = 2000;
     
      while(1){
    
        PIDRun();
        
        for(int i = 0; i<4; i++)
          motorRun(i);
        
    
    
        //print pulse per sec every 5 secs
        if(millis() - ppsTimer > 5000){
          ppsTimer = millis();
    
          for(int i = 0; i < 4; i ++){
            Serial.print(i+1);
            Serial.print(" Speed : ");
            Serial.print(motorSpeed[i]);
            Serial.print("   ");
            Serial.print("PPS Created : ");
            Serial.print(pps[i]/5);
            Serial.print("   ");
            Serial.print("Pos(5secs): ");
            Serial.println(motorPosition[i]);
            pps[i] = 0;
          }
          Serial.println();
        }
    
        
      }
    }
    The code manage to give a maximum of about 1200 pulse per sec for each motor. But looking at the motor manual, the lowest PPR setting via dip switches is 800PPR. If I aim for 100mm/s actuator movement, that would need around 16000 pulse per second.

    However I found out that there is a setting in the manual that you can adjust for 'electronic gear ratio'.

    Here is the manual
    https://www.cnc-technics.de/ihsv servomotor.pdf

    What I understand from the manual is that, by adjusting the ratio, I can set how many pulse needed for a revolution . If I set the ratio to 13, I can move the actuator at 100mm/s with just 1200 pulses per sec. But I am not entirely sure and I don't want waste money buying things that I cannot use.

    Anyone here familiar with these motors? Am I correct about the 'electronic gear ratio'? Do you think it is doable with just Arduino Uno..?