Ingo Lohs
Published © LGPL

Check a Stepper Motor From the DVD-ROM

The older members among you can still remember DVD-ROM drives well: let's take another look at the inner values of a past technology.

BeginnerProtip2 hours11,206

Things used in this project

Hardware components

DVD-ROM
maybe an old model from Desktop PC or Laptop or CD-ROM - what is lying around right now
×1
Adafruit TB6612
×1
Breadboard (generic)
Breadboard (generic)
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
or equivalent
×1
9V 1A Switching Wall Power Supply
9V 1A Switching Wall Power Supply
for separate power for the Stepper Motor
×1
5V DC Power Adapter
1x - optional if you have the right Wall Power Supply
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Stepper Example TB6612 and Arduino

C/C++
fast version
#include <Stepper.h>

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

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

void setup() {
  // set the speed at x rpm:
  myStepper.setSpeed(100);
  // 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);
}

Stepper Example with PHPoC Blue & PES-2405 R2 Expansion Board

PHP
<?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 = 200;
    $micro_steps_per_revolution = $steps_per_revolution * $mode;

    // myStepper.setSpeed(2);
    $speed = 2 * $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);
    }  

    ?> 

Credits

Ingo Lohs

Ingo Lohs

81 projects • 110 followers
I am well over 40 years and come from the middle of Germany.

Comments