Before you make use of a stepper motor, it is important to understand some basic terms like DC motor, CNC, servo, control, controller, driver, driver IC, bipolar and steppers. You also need to know how to read and understand stepper motor diagrams to better understand how stepper motors work.
Take note that normal DC motors and stepper motors differ in operation. Voltage applied to the terminals of DC motors causes it to immediately rotate, while stepper motors have a four-phase, gear-shaped, piece of iron with multiple electromagnets attached to its center.
Four wire coils are found inside a stepper motor, positioned 90 degrees apart, like a clock at 12, 3, 6, and 9. It has a spinning rotor at the middle fitted with permanent magnets around its circumference. In each turn that the rotor spins, the magnets pass, approach, and move away from the four coils. As each magnet passes a wire coil, it causes the flow of electricity through the coil. Alternate electrical currents then flow through the coils in various amounts.
As a multi-phase motor, the stepper motor is ideal for electricity generation projects. Its four-phase motor and allows electricity to continuously flow to its maximum capacity to the next coil, even if electricity fails to flow in one coil. The total electricity generated from the four-phases merged and is rectified to produce a near constant voltage and direct current (DC).
The wiring for stepper motors mostly come in 6 wires, but there are available stepper motors with 8, 5 or 4 wires. A wire with two ends of the same length, one end live and the other end, common, make up each of the four coils. A 6-wire stepper motor has 2 pairs of common wires joined together. For a 5-wire stepper motor, all 4 commons are joined together, while in an 8-wire stepper motor all 4 common wires are separate from each other.
Schematic diagrams usually come with new stepper motors, but if you only have an old salvaged diagram, it is still easy to understand and identify the wires in a stepper motor.
Use a multi-meter between the different pairs of wires, to measure resistance. The motor will only function properly if all the four stepper motor coils have nearly identical resistances. A common and a live wire together will just have one coil between them, while two live wires will have two coils between, as illustrated in this diagram:
Therefore, if the resistance measured from a pair of wires is double that of another pair of wires, the pair with the double amount measured for resistance is both live. The other pair has one common and one live. Once the common wires are identified, label them accordingly.
Visit http://www.doc.ic.ac.uk/~ih/doc/stepper/control2/connect.html for detailed descriptions and diagrams for various stepper motor connections.
For home built CNC projects, there are axis micro-stepping bipolar PWM current regulated stepper motor drivers, or controllers and driver ICs available with more complicated stepper motor diagrams to study.