0% found this document useful (0 votes)
51 views11 pages

Stepper Motor - Operation, Interfacing and Control

The document discusses stepper motor interfacing with an embedded system. It covers stepper motor control theory, the L298 motor driver component, a schematic layout, and C code implementation. Precise positioning and repeatability are advantages of stepper motors discussed.

Uploaded by

PAUL SATHIYAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views11 pages

Stepper Motor - Operation, Interfacing and Control

The document discusses stepper motor interfacing with an embedded system. It covers stepper motor control theory, the L298 motor driver component, a schematic layout, and C code implementation. Precise positioning and repeatability are advantages of stepper motors discussed.

Uploaded by

PAUL SATHIYAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Stepper Motor Interfacing

Embedded System Design 14EC2029


Dr. S. Paul Sathiyan

KITS | EEE | VER 1.1 | AY 2018 2019


Agenda
• Stepper Motor Control Theory
• L298 Motor Driver
• Schematic Layout
• C Code
Stepper Motor Control Theory
• A stepper motor is an electromechanical device it converts electrical power into
mechanical power. Also it is a brushless, synchronous electric motor that can
divide a full rotation into an expansive number of steps. The motor’s position
can be controlled accurately without any feedback mechanism, as long as the
motor is carefully sized to the application. Stepper motors are similar to
switched reluctance motors.

• The stepper motor uses the theory of operation for magnets to make the motor
shaft turn a precise distance when a pulse of electricity is provided. The stator
has eight poles, and the rotor has six poles. The rotor will require 24 pulses of
electricity to move the 24 steps to make one complete revolution. Another way
to say this is that the rotor will move precisely 15° for each pulse of electricity
that the motor receives.
Stepper Motor Control Theory
Advantages of Stepper Motor:

• The rotation angle of the motor is proportional to the input pulse.

• The motor has full torque at standstill.

• Precise positioning and repeatability of movement since good stepper motors have an accuracy of 3 – 5%
of a step and this error is non cumulative from one step to the next.

• Excellent response to starting, stopping and reversing.

• Very reliable since there are no contact brushes in the motor. Therefore the life of the motor is simply
dependent on the life of the bearing.

• The motors response to digital input pulses provides open-loop control, making the motor simpler and
less costly to control.

• It is possible to achieve very low speed synchronous rotation with a load that is directly coupled to the
shaft.

• A wide range of rotational speeds can be realized as the speed is proportional to the frequency of t
Stepper Motor Control Theory
• A bipolar stepper motor : the opposing coils are wired in parallel and therefore the device
has just four terminals.

• The motor must be driven using circuitry that can drive current through each pair of coils in
either direction.

• This is achieved using an H-Bridge driver for each coil – this can be most easily implemented
using bridge driver ICs such as the L298 or L6201/2/3 for which behavioral simulator
models are also provided.
L298 Driver for Motor
Parameters Value
Operating Voltage Upto 46 V
DC Current 4A

PIN No Pin Name Details Remarks


1 Gnd Ground -
2 +12v Power Supply Input Can go upto 46 V
3 IN1 Direction of Motor 1
Refer Direction Control Table
4 IN2 Direction of Motor 1
5 ENA Controlling Motor 1 IF 0, Disable, 1 – Enable the motor
6 ENB Controlling Motor 2 driver circuitry
7 IN3 Direction of Motor 2
Refer Direction Control Table
8 IN4 Direction of Motor2

IN1 / IN3 IN2 / IN4 Remarks


0 0 No Operation / Halt
0 1 Forward
1 0 Reverse
1 1 No Operation / Halt
H/W Configurations
• Direction Control Switch is connected to PortB DO and D1 bits

• Phase A of stepper motor is connected to OUT1 and OUT2 of L298

• Phase B of stepper motor is connected to OUT3 and OUT 4 of L298

• IN1 of L298 is connected to PORTA Bit 1 (D1)

• IN2 of L298 is connected to PORTA, Bit 2 (D2)

• IN3 of L298 is connected to PORTA, Bit 5 (D5)

• IN4 of L298 is connected to PORTA, Bit 6 (D6)

• ENA and ENB is connected to +5V


Schematic Layout
D2

LED-GREEN
FORWARD

D1 20 25
RESET PD0/SCL/INT0
26
PD1/SDA/INT1
24 27
XTAL1 PD2/RXD1/INT2
LED-BLUE 23 28
XTAL2 PD3/TXD1/INT3
REVERSE 29
PD4/ICP1
51 30
PA0/AD0 PD5/XCK1
50 31
PA1/AD1 PD6/T1
49 32
PA2/AD2 PD7/T2
48
PA3/AD3
47 2
PA4/AD4 PE0/RXD0/PDI
46 3
PA5/AD5 PE1/TXD0/PDO
45 4
PA6/AD6 PE2/XCK0/AIN0
44 5
PA7/AD7 PE3/OC3A/AIN1
6
PE4/OC3B/INT4
10 7
PB0/SS PE5/OC3C/INT5
11 8
PB1/SCK PE6/T3/INT6
12 9
PB2/MOSI PE7/ICP3/INT7
13
PB3/MISO
14 61
PB4/OC0 PF0/ADC0
15 60
PB5/OC1A PF1/ADC1
B1 16 59
PB6/OC1B PF2/ADC2
17 58
PB7/OC2/OC1C PF3/ADC3
57
PF4/ADC4/TCK
35 56
PC0/A8 PF5/ADC5/TMS
36 55
12V PC1/A9 PF6/ADC6/TDO
37 54
PC2/A10 PF7/ADC7/TDI
38
PC3/A11
39 33
PC4/A12 PG0/WR
40 34
PC5/A13 PG1/RD
41 43
PC6/A14 PG2/ALE
42 18
PC7/A15 PG3/TOSC2
19
PG4/TOSC1
62
AREF
64 1
AVCC PEN
ATMEGA128
9 4 U2
5
IN1 VCC VS
7 2 +88.8
IN2 OUT1 A
10
IN3
12 3
IN4 OUT2 B
6
ENA
11 13
ENB OUT3 C
1 14
SENSA OUT4 D
15
SENSB GND

8 L298
C Code – Stepper Motor Control
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <util/delay.h>
main()
{
// Write your code here
DDRA=255;
DDRB=0;
PORTB=255;
PORTA=0;
while (1)
{
C Code – Stepper Motor Control
if(PINB==0b11111110) / /Forward
{

PORTA|=(1<<1); // Set the First (D1) bit of Port A


_delay_ms(100);
PORTA&=~(1<<1); // Clear the First (D1) bit of Port A

PORTA|=(1<<2); // Set the Second (D2) bit of Port A


_delay_ms(100);
PORTA&=~(1<<2); // Clear the Second (D2) bit of Port A

PORTA=(1<<5); // Set the Fifth (D5) bit of Port A


_delay_ms(100);
PORTA&=~(1<<5); // Clear the Fifth (D5) bit of Port A

PORTA|=(1<<6); // Set the Sixth (D6) bit of Port A


_delay_ms(100);
PORTA&=~(1<<6); // Clear the Sixth (D6) bit of Port A

}
C Code – Stepper Motor Control
if(PINB==0b11111101) / /Reverse
{
// PORTA=0b11000100;
PORTA|=(1<<6); // Set the Sixth (D6) bit of Port A
_delay_ms(100);
PORTA&=~(1<<6); // Clear the Sixth (D6) bit of Port A

PORTA|=(1<<5); // Set the Fifth (D5) bit of Port A


_delay_ms(100);
PORTA&=~(1<<5); // Clear the Fifth (D5) bit of Port A

PORTA|=(1<<2); // Set the Second (D2) bit of Port A


_delay_ms(100);
PORTA&=~(1<<2); // Clear the Second (D2) bit of Port A

PORTA|=(1<<1); // Set the First (D1) bit of Port A


_delay_ms(100);
PORTA&=~(1<<1); // Clear the First (D1) bit of Port A
}
else
{
PORTA=0;
_delay_ms(1);
}
}
return 0;
}

You might also like