Working with stepper motors

Stepper Motor control through a H-Bridge

Stepper motors offer a high degree of positional control. They are rotated in a sequence of steps and offer a resolution of position of around 400 per revolution when 'half stepping' (explanation here). The rpm of the motor depends on a few things, the motor itself, the wieght it is under, the voltage supplied. It seems that mine should do about 185 rpm (this is at 12v for a 15v stepper), when I push it over a threshold (800 microsecond burst from arduino) it just goes a bit crazy - this is probably the motor but could also be the arduino struggling with microseconds.

I decided to write my own code to control the stepper as I wanted to know how it all was working. In the code I have got the control of the motors position through a potentiometer (could be anything). The motor is set to move at full tilt (800 microsecond delay) but the position conformity controls the speed, it responds really precisely. If you wanted to control speed through a pre-defined var you would have to ammend the code. To view the code click here

For a project I am undertaking I have been wanting to simulate or copy rotation and speed of one object with a stepper in the similar most time as possible. The code takes data from a rotary encoder, on one arduino and sends it out to another arduino via wire to another arduino which controls the stepper motor which aims to follow the movement in exactly the same way. View the code for the rotary encoder and for the stepper motor here