How Controlling a Stepper Motor With an Arduino in 5 step

 


Step 1: What Is a Stepper Motor?

A rotor and a stator are the two primary components of a stepper motor. The rotor is the component of the motor that spins and generates torque. The stator is the motor's stationary component that contains the rotor. The rotor of a stepper motor is a permanent magnet. When an electrical current is passed via many coils in the stator, they behave as electromagnets. When the electromagnetic coil is charged, it will cause the rotor to align with it. Alternating which coil has a current going through it propels the rotor.


Stepper motors have a lot of advantages. They are inexpensive and simple to use. The steppers securely keep their position when no electricity is sent to the motor. Stepper motors can also rotate freely and change direction depending on the polarity.


Step 2: Parts List


Needed Parts

  • Stepper Motor (This motor was salvaged from an old printer)
  • Arduino
  • Insulated Copper Wire
  • Wire Cutters/Strippers
  • Current Regulator
    • Transistor
    • H-bridge(What will be used in this tutorial)
    • Motor Shield

Optional Parts

  • Soldering Iron
  • Solder
  • Soldering Fan
  • 3rd Hand Tool
  • Safety Glasses

Step 3: Attach the Wires

Because most stepper motors have four leads, you'll need to cut four pieces of copper wire (notice that the color doesn't matter). The usage of different hues was just for the purpose of making it simpler to see). These wires will be used to control which coil in the motor is currently active. Soldering the wires on was the simplest option for this project because the motor was salvaged from an old printer. However, any method of making a secure connection (solder, plug, or clips) will suffice. 


Step 4: Arduino Sketch

Arduino already has a built in library for stepper motors. Simply go to File > Examples > Stepper > stepper_oneRevolution. Next you are going to want to change the stepsPerRevolution variable to fit your specific motor. After looking up the motors part number on the internet, this particular motor was designed for 48 steps to complete one revolution. What the Stepper library is actually doing is just alternating HIGH and LOW signals to each coil as shown in the GIF.




Step 5: What Is an H-Bridge?

An H-Bridge is a circuit comprised of 4 switches that can safely drive a DC motor or stepper motor. These switches can be relays or (most commonly) transistors. The transistor is a solid state switch that can be closed by sending a small current (signal) to one of its pins. Unlike a single transistor which only allow you to control the speed of a motor, H-bridges allow you to also control the direction in which the motor spins. It does this by opening different switches (the transistors) to allow the current to flow in different directions and thus changing the polarity on the motor. WARNING: Switches 1 and 2 or 3 and 4 should never be closed together. This will cause a short circuit and possible damage to the device.

H-Bridges can help prevent your Arduino from being fried by the motors you are using it drive. Motors are inductors, meaning that they store electrical energy in magnet fields. When current is no longer being sent to the motors, the magnetic energy turns back into electrical energy and can damage components. The H-Bridge helps isolate your Arduino better. You should never plug a motor directly into an Arduino.

Though H-Bridges can be fairly easily built, many opt to buy an H-Bridge (such as a L293NE/SN754410 chip) due to convenience. This is the chip that we will be using in this tutorial. The physical pin numbers and their purpose are listed below.

  • Pin 1 (1, 2EN) ---> Motor 1 Enable/Disable (HIGH/LOW)
  • Pin 2 (1A) ---> Motor 1 Logic Pin 1
  • Pin 3 (1Y) ---> Motor 1 Terminal 1
  • Pin 4 ---> Ground
  • Pin 5 ---> Ground
  • Pin 6 (2Y) ---> Motor 1 Terminal 2
  • Pin 7 (2A) ---> Motor 1 Logic Pin 2
  • Pin 8 (VCC2) ---> Power Supply for Motors
  • Pin 9 ---> Motor 2 Enable/Disable (HIGH/LOW)
  • Pin 10 ---> Motor 2 Logic Pin 1
  • Pin 11 ---> Motor 2 Terminal 1
  • Pin 12 ---> Ground
  • Pin 13 ---> Ground
  • Pin 14 ---> Motor 2 Terminal 2
  • Pin 15 ---> Motor 2 Logic Pin 2
  • Pin 16 (VCC1) ---> Power Supply for H Bridge (5V)






 


 


















































Post a Comment

Previous Post Next Post