Stepper motors are also a small multi-pole alternator, but being more modern they have four phases while the old Dynohub had only one. In use, the computer puts a pulse of current into each phase coil in turn, moving the shaft on one step. As with a DC permanent magnet motor, turning the motor's shaft makes it work backwards, causing pulses of current to come out of the windings. However, the current is AC, going plus as a magnet pole approaches a coil and then minus as it goes away again. Usually there are four phases at 90 degree intervals so when one comes down to zero, the next one has reached maximum. This is a benefit as it means the output can be rectified to produce much smoother DC with hardly any gaps, but it means they have a scarily large number of wires coming out. Luckily it's quite easy to figure out which way around they are using a resistance meter (preferably digital), and getting them the wrong way around won't do any damage. The most common type of stepper has six wires coming out. (There are also five, four and eight wire versions; I'll come to those later - they are easy to understand once you've sussed the six wire one) The six wire stepper is actually two motors on one shaft, so the six wires can immediately be separated into two groups of three. Each group will have some connection to each other, but no connection to any of the other group. In each group, one wire is the common and the other two are the opposite ends of a winding which will give out oppositely phased AC.
In terms of resistance, the reading from the common to either end will be half the reading across the two ends. Having found the common on one set, you can use the same process to find the common in the other one. All four windings will have almost exactly the same resistance.
The majority of steppers are six wire, but there are other varieties. Five wire ones are easy; the two commons on the six wire have already been connected together for you which makes things easier. Eight wire ones are just like a six wire but with all the windings separate, and four wire ones are half of an eight wire one (or half a six wire one with the two windings separate).
There's more than one way to wire up the stepper to get a DC output. Unlike the dynohub, you can't wire it up to a bulb and run it off AC as it's got four separate phases and connecting any two directly will cause a short and stall it. On the other hand, if you're bursting to generate some power, connecting a small light bulb, say 6V 100 mA from ONE of the live phases to the common and turning the spindle with your fingers should get a result. It's quite a good way to find out if you're going to get a useful amount of power out of it, but you'll only get a quarter of the possible power that way. The simplest way to wire it up is to link the two commons to the minus terminal and then connect each of the four live phases through a small diode to the plus one as shown. Here's what it looks like.
The four lives will each go positive (and then negative) one after the other like the cylinders of a car firing and the diodes collect together all the positive pulses and feed them out. Because of the overlapping phases, the rectified AC never goes down to zero like it would from a normal bridge rectifier. Putting the bulb across the output should give a stronger result than before and a DC voltmeter will show that the output voltage is more or less proportional to the rotation speed. This is normal for a permanent magnet alternator and you will need to use a regulator limit the voltage. Because the stepper is acting as an AC generator, it doesn't matter which way you turn it so designs in which it is turned alternately forward and back by a treadle or foot pedal are possible.
If the motor you've got is rated at 5V but you want to generate enough voltage to charge a 12V battery, you can often get away with just spinning it a bit faster. If that doesn't work, you may be better off using this voltage doubler circuit with two bridge rectifiers. I've built a pedal generator which can be switched between the two configurations, and there's less difference between them than you'd expect. The double voltage configuration gives a good voltage at lower speeds but has less current capability as there's twice the winding resistance. The normal four diode setup gives more current when driven faster, but not twice as much as the AC impedance of the windings has an effect due to the higher frequency.
Generating Electricity With Stepper Motors