Introduction: Raspberry Pi CNC Hat Controlled CDROM Stepper Motor

Purpose: Learn how simple it is to use the Raspberry Pi CNC Hat from Protoneer by testing it out on a CDROM stepper motor.

Why: Many of us dream of making our own CNC router / engraver but get bogged down in the details and unknowns. This is a simple and inexpensive way to test the waters using components you may already have laying around.

Time: ~2 hours including flashing the SD card & soldering.

Difficulty Level: Beginner

Parts / Tool List:

  • Raspberry Pi 2 Model B (other versions may work but I have not verified)
  • CNC Hat V2.51 (sold by Protoneer Here for $30 + shipping)(wiki located here)
  • A4988 StepStick stepper driver (I bought mine here for $6)
  • CDROM Drive with mechanical door (salvaged mine from old computers being recycled at work)
  • Power supply (24V gave me the best result)
  • Solder gun
  • Multi-meter (optional)
  • Basic wiring tools (Strippers, cutters, small screw drivers, crimpers, etc.)

Step 1: Remove Inner CDROM Tray With Stepper Motor

  1. Carefully take apart your CDROM drive and remove the inner tray leaving the stepper motor and laser assembly intact. Should only required a small phillips screw driver. (Hint: remove the front face first)
  2. Locate the four leads on the stepper motor, see red arrow in the above image. Don't try to remove the flexible wire circuit, this will pull out the four leads in the motor and make this much more difficult to complete.

Why are there four wires you might ask... it has to do with how the motor windings are engineered and how to get accurate step increments. Check out this awesome resource on stepper motors.

Step 2: Solder on Wires Leads to Stepper Motor

Use the existing solder on the stepper motor circuit and quickly heat and attach wires to each one being careful not to bridge solder between any of the connections.

New to soldering? Check out this fun comic strip soldering guide.

Step 3: Inspect Motor Leads

Use a multi-meter, set to measure resistance, to find which two stepper motor leads are paired together. If two leads are paired you will get a reading near zero. If they are not paired you will get a 1. The three pictures above show the left two leads are paired, right two leads are paired, and there is no connection between the two.

If you don't have a multi-meter, it's a pretty good bet that the first two and last two leads are in pairs. I tested 4 different makes of CDROM's and this was true for all four.

Step 4: Attached Stepper Motor Leads to CNC Hat

Install one pair of wires to the 'A' connection block on the CNC Hat and the other pair to the 'B' side. Since we don't care about direction you don't need to know the order of the pair. Make sure all wires are connected to the same Axis connection block. I used the 'Z' axis as shown in the picture above but could have used one of the others.

Step 5: Attach Power Supply to CNC Hat

Connect power source to CNC hat to drive the stepper motor. This is not power for the Raspberry Pi.

I couldn't find any markings on the stepper motor to determine brand for looking up power specs. I started with a 12V, 1 amp power supply and got irregular motor movement. I then used a 24V, 6 amp power supply and got nice control.

Step 6: Flash SD Card and Launch CNC.JS

  1. From another computer, download OS image from Protoneer Wiki page under "User Interfaces"
  2. Flash an SD card with this image using one of the methods suggested by the Raspberry Pi foundation here.
  3. Insert the SD card into the Raspberry Pi and power it up.
  4. Connect to your home network.
  5. 'Start CNC.JS' will be pre-loaded on the Raspberry Pi desktop. Run it once and leave the terminal window open.

Step 7: Launch Raspberry Pi CNC Web Interface

  1. Get Raspberry Pi IP address by opening a terminal window and typing: IP addr show
  2. From another computer on the same network, open an internet browser.
  3. Type the web address using your IP address. Example:
  4. CNC Web interface should load as shown in the picture above.

Step 8: Connect to the Raspberry Pi CNC Hat

From the web page loaded, click "Connect"

If successful, button should turn red and say "Close"

Step 9: Test It Out

If you connected your stepper motor to the Z axis control block on the CNC hat like I did, jog the Z axis by clicking either the Z+ or Z- button one time. Change the step size to something large enough to see it move. 16 was enough for mine to travel from one end to the other. Don't worry about it going too far. CDROM's are designed to just skip if the motor over runs and wont damage anything.

If you don't get any movement, make sure your separate power supply to the CNC Hat is connected correctly and has sufficient power.