In this post, I am gonna show you how to control 2 Unipolar Stepper Motor using Joystick in Arduino. I am working on this project for a manual controlled Camera slider. In future, I will also update this code for Manual camera slider but this is very simple for everyone which everyone can make their joystick control stepper for creative projects.
So in this blog, we take a look on these steps are:-
>>
How Unipolar Stepper Motor Works
>>Component
Required
>>Schematic
>>Arduino
Code
>>Final
How Unipolar Stepper Motor Works
If
we look into Steppers, there are two types stepper motor which one is Unipolar and second one is Bipolar. The Bipolar Stepper motor is 2 phase brushless dc motor which has two copper winding (coils) each coil
has 2 wires other the main is Unipolar
stepper motor, It has 4 phase brushless dc motor which has 5 to 6 wires (in my
case I am using 5 wire stepper motor which is most popular Unipolar one). It can be controlled with two most common modes,
first one is Full Step, and Second one is Half step and also an another type
which is Microstepping mode.
In
Full Step mode the driver power the two coils at same time which this
mode provides the powerful torque.
Where
Half Step mode is a complete combination of the two Full Step mode which
this mode provide more accuracy using dividing each steps by 2.
The
last one is Microstepping which this
mode more accurate than the half step mode.
Component Required:-
1x
Arduino Nano
2x
ULN2003 Stepper Motor Driver IC (Unipolar Stepper Motor can be drive by lots of
motor driver but the most popular and cheap one is this ULN2003 IC)
2x
Stepper Motor (5 pin)
1x
Joystick
Some
Jumper Wires
Schematic:-
This
one is super simple schematic where you can build into your breadboard.
First
of all place the all required components in breadboard.
Then
connect Arduino Digital Pin D2 to IC1 pin 1.
After
then connect the Digital Pin D3 to IC1 pin 2.
After
then connect the Digital Pin D4 to IC1 pin 3.
After
then connect the Digital Pin D5 to IC1 pin 4.
Connect
the ULN2003 Pin 9 to 12V Positive pin and Pin 8 to main GND (Negative) Pin.
Then
connect Arduino Digital Pin D8 to IC2 pin 1.
After
then connect the Digital Pin D9 to IC2 pin 2.
After
then connect the Digital Pin D10 to IC2 pin 3.
After then connect the
Digital Pin D11 to IC2 pin 4.
Same
again connect the ULN2003 Pin 9 to 12V Positive pin and Pin 8 to main GND
(Negative) Pin.
Now
Connect the joystick Pins, First one is GND which always connect to main ground
pin then second one is 5V+ which connect Arduino 5V(VCC) then the third one is
VRx which is connect with A2 and the last one is VRy which is connect with A1
Analog pin.
Arduino Code:-
Here
is the simple Arduino code for this project, now you can copy this code and
paste into your Arduino IDE.
#include <Stepper.h>
#define STEPS 2038
Stepper stepper(STEPS, 8, 10, 9, 11);
Stepper stepper1(2038, 2, 4, 3, 5);
int potState = 0;
int pot1State = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
potState = analogRead(A1); //reads the values from the Joystick
pot1State = analogRead(A2);
Serial.println(pot1State); // Serial Data Reading
Serial.println("\t");
Serial.println(potState);
stepper.setSpeed(5);
stepper1.setSpeed(5);
if (potState > 600) { // main code here
stepper.step(10);
}
if (potState < 400) {
stepper.step(-10);
}
if (pot1State < 400) {
stepper1.step(-10);
delay(5);
}
if (pot1State > 600) {
stepper1.step(10);
}
}
Final
In my opinion, this project can be modify for 2-3 more stepper motor and 1-2 more joystick where we can create a Robotic Arm but the less pins in Arduino Uno or Nano it can be a subject for another post which we can use pin expender.
Comments
Post a Comment