This was purely an educational experiment i did for myself, but since it took me a while to research i tought i'd share it with the world.
Step 1: The PCB
In order to drive the stepper motor, i used a relay board i made a couple months earlier. It consists of 3 Relays forming an H-Bridge ( for the people who don't know what that is, it's a circuit that allows a motor, or multiple motors to turn in both directions )
This board is not the best way i could have done it but since i had it laying around, i decided to use it.
You could also run the motor using Mosfets for example or a Stepper driver.
The setup i have consists of 1 Relay with 2 switching contacts to change polarity
and 2 relays to turn each winding on/off
VERY IMPORTANT INFO IF USING RELAYS
make sure that if you are using relays, to ALWAYS use a freewheeling diode!
or you might end up destroying your microcontroller and also your circuit wil malfunction big time.
If you do not know what a freewheeling diode is, i suggest you google it.
Step 2: Measurements
Using a 9V battery to power the motor, it draws about 180mA of current.
So make sure that if you are using a stepper motor IC, that it can handle that amount of current and voltage.Publish
Step 3: Writing the Software
To make the stepper motor work, you have to follow a certain sequence.
The stepper i am using is a bipolar stepper, which means it has 2 coils.
Each coil has 2 connections
i will explain the phases you have to go through by it's polarity. Either +/- or -/+ :
Phase 1 :
+/- on winding 1
Phase 2 :
+/- on winding 2
Phase 3 :
-/+ on winding 1 ( reverse polarity )
Phase 4 :
-/+ on winding 2 ( again, reverse polarity )
Loop these phases and you'll have your stepper motor turning consistantly
To make the motor turn back, simply repeat your last phase but with reversed polarity.
I tried to explain this as good as i can with the little resources i have, this is also my first instructable ever so please be gentle on me :p
I hope you learned something