Announcement

Collapse
No announcement yet.

DVD Bipolar StepperMotor

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • DVD Bipolar StepperMotor

    I like to control an old CDROM / DVD Stepper Motor with Blue and Expansion PES-2405R2.
    The example move-Code works with Nema17 and so it should be work also with other steppers.
    The wiring is easy and the circuit works with Arduino/TB6612 and Arduino sample code.
    I think it's related to the move properties. Would you be prepare me to map the Arduino code to the move command?

    If it works, I will write an article and compare both options Arduino / TB6612 vs Blue / Expansion Board.

    Arduino-Code--------------------

    #include <Stepper.h>

    const int stepsPerRevolution = 3400; // change this to fit the number of steps per revolution for your motor

    // initialize the stepper library on pins
    Stepper myStepper(stepsPerRevolution, 4, 5, 6, 7);

    void setup() {
    // set the speed at 2 rpm:
    myStepper.setSpeed(2);
    // initialize the serial port:
    Serial.begin(9600);
    }

    void loop() {
    // step one revolution in one direction:
    Serial.println("clockwise");
    myStepper.step(stepsPerRevolution);
    delay(500);

    // step one revolution in the other direction:
    Serial.println("counterclockwise");
    myStepper.step(-stepsPerRevolution);
    delay(500);
    }

    Blue-Code-----------------------------------

    <?php
    include_once "/lib/sd_spc.php";

    spc_reset();
    spc_sync_baud(115200);

    $sid = 1;
    spc_request_dev($sid, "set mode 4");
    spc_request_dev($sid, "set vref stop 2");
    spc_request_dev($sid, "set vref drive 8");
    spc_request_dev($sid, "set rsnc 120 250");

    spc_request_dev($sid, "move 200 2 200"); // 400 800 0 <<< here?
    while((int)spc_request_dev($sid, "get state"))
    usleep(1);

    //sleep(1);

    spc_request_dev($sid, "move -800 400 0 800");
    while((int)spc_request_dev($sid, "get state"))
    usleep(1);
    ?>
    Attached Files

  • #2
    Dear Postler,
    Of course, It works with PHPoC and Step Motor Controller PES-2405. With PES-2405, you have more options to make motor move smoothly.

    Firstly, let's compare two code you posted.

    Code:
    // set the speed at 2 rpm:
    myStepper.setSpeed(2);
    In Arduino, speed unit is rotations_per_minute.
    In PES-2405, speed unit is micro_step_per_second.
    Now let's convert speed from rotations per minute to step per second.
    - We need to find the "steps_per_revolution" parameter on specification of motor. Note that some motor specification provide "Step_Angle", which means "angle_per_step". In this case, we can calculate:
    steps_per_revolution = 360 / angle_per_step
    - Now we can convert speed from rotations per minute to step per second by using the following formula:
    step_per_second = rotations_per_minute * steps_per_revolution / 60
    - Since PES-2405 use the micro-stepping method to control motor, this method have two advantages: Make motor move more smoothly and control motor more precisely. Why?. Because one step on full-step control can be divided to a number of micro-steps. This increases resolution of step motor. A number of divided micro-steps can be specified via spc_request_dev($sid, "set mode $mode"); command. You can refer more here https://www.phpoc.com/support/manual...php?id=use_set
    - Now we need to calculate:
    micro_step_per_second = step_per_second * $mode
    in your code, you use $mode = 4.

    => now can set speed via command: spc_request_dev($sid, "set speed $micro_step_per_second");

    Since you already set speed in "set speed command", you do not need to set speed when you use "move" command, You just need: spc_request_dev($sid, "move $steps");

    Advanced control
    PES-2405 allows to set acceleration and acceleration via "set accel (accel) [decel]" command (see manual).
    This is one of the factors make motor move more smoothly.

    If you have any question, please feel free to commend here.

    Comment


    • #3
      In detail, the below is PHPoC code that mapped from Arduino code
      PHP Code:
      include_once "/lib/sd_spc.php";

      spc_reset();
      spc_sync_baud(115200);

      $sid 1;
      $mode 4;
      spc_request_dev($sid"set mode $mode");
      spc_request_dev($sid"set vref stop 2");
      spc_request_dev($sid"set vref drive 8");
      spc_request_dev($sid"set rsnc 120 250");

      $steps_per_revolution 3400;
      $micro_steps_per_revolution $steps_per_revolution $mode

      // myStepper.setSpeed(2);
      spc_request_dev($sid"set speed $micro_steps_per_revolution");

      while(
      1)
      {
          
      // myStepper.step(stepsPerRevolution);
          
      spc_request_dev($sid"move $micro_steps_per_revolution");
          while((int)
      spc_request_dev($sid"get state"))
              
      usleep(1);

          
      //sleep(1);

          // myStepper.step(-stepsPerRevolution);
          
      spc_request_dev($sid"move -$micro_steps_per_revolution");
          while((int)
      spc_request_dev($sid"get state"))
              
      usleep(1);

      Comment


      • #4
        I want to give the code a try and get timeouts in the log like:
        Do I have to adapt something else?
        Already thanks for the detailed description!

        http> PHP error: maximum execution time exceeded in file lib / sd_spc.php on line 209

        http> PHP error: maximum execution time exceeded in file lib / sd_spc.php on line 281

        http> PHP error: maximum execution time exceeded in file lib / sd_spc.php on line 209

        http> PHP error: maximum execution time exceeded in file lib / sd_spc.php on line 209

        Comment


      • #5
        The article with the Arduino / TB6612 is online; I would be happy if I could contrast the Alternative Blue / Expansion Board with the details.

        Comment


        • #6
          Hello @Postler,
          Could you please do the following steps:
          • Update the latest firmware for PHPoC and PES-2405
          • Use the latest library for PHPoC: https://github.com/phpoc/phpoc-psp/archive/v2.2.1.zip
          • Update new code (see below)
          • PHP Code:
            <?php

                
            if(_SERVER("REQUEST_METHOD"))
                    exit; 
            // avoid php execution via http request

                
            include_once "/lib/sd_spc.php";

                
            spc_reset();
                
            spc_sync_baud(115200);

                
            $sid 1;
                
            $mode 4;
                
            spc_request_dev($sid"set mode $mode");
                
            spc_request_dev($sid"set vref stop 2");
                
            spc_request_dev($sid"set vref drive 8");
                
            spc_request_dev($sid"set rsnc 120 250");

                
            $steps_per_revolution 3400;
                
            $micro_steps_per_revolution $steps_per_revolution $mode;

                
            // myStepper.setSpeed(2);
                
            $speed $micro_steps_per_revolution;
                
            spc_request_dev($sid"set speed $speed");

                while(
            1)
                {
                    
            // myStepper.step(stepsPerRevolution);
                    
            spc_request_dev($sid"move $micro_steps_per_revolution");
                    while((int)
            spc_request_dev($sid"get state"))
                        
            usleep(1);

                    
            //sleep(1);

                    // myStepper.step(-stepsPerRevolution);
                    
            spc_request_dev($sid"move -$micro_steps_per_revolution");
                    while((int)
            spc_request_dev($sid"get state"))
                        
            usleep(1);
                }  

                
            ?>
          • Note that: That code is not for running though HTTP. It is used for locally running only.
          After running code, please tell us the result.
          Last edited by support; 01-23-2019, 09:49 AM.

          Comment


          • #7
            Thx support for this useful information: I updated my article!

            Comment

            Working...
            X