I have an idea for a very simple power stage to drive stepper motors. I know there are ready-to-use ICs for this but as soon as you need more than 2A current or more than 36V they either become expensive or generate a lot of heat. Discrete MOSFETs are much better. A full bridge that can handle 50V and 4A without much cooling can be built for ~$1. Two full bridges are required to drive a stepper motor with 2 windings.
Since stepper motors are operated in current mode a feedback loop is required. For my servo project I use isolated current sensors which is handy when mains voltage is used directly. For small stepper motors this is overkill and would be far too expensive. Instead, current sensor shunt resistors are used. Theese have very little reistance (33 milli ohms for example) otherwise they would heat up too much at high currents. The low signal amplitude (100mV @ 3A) requires high resolution.
To avoid the need for external amplifiers my idea was to use the higher resolution modes of the built in ADCs of the P2. Their disadvantage is that they are not suited for auto calibration. Hence, they only work well if AC coupled and the DC offset can't be compensated easily. But I'm optimistic that this can be achieved with clever software.
Typical circuits use only one shunt resistor which is shared by both legs of the full bridge. However, this would cause problems in our case because at standstill and low speed the duty cycle is very low (only a few microseconds on time) and we wouldn't have enough time to measure current precisely. With two shunt resistors we always see more than 50% duty cycle because the current also flows through the resistors during the free-wheeling phase. One resistors costs less than $0.10 so this is no big problem.