Stepper Motor Control: L298 Motor Driver & AVR Microcontroller, Slides of Embedded Systems

Information on interfacing a stepper motor with an l298 motor driver and an avr microcontroller. It covers the theory of stepper motor operation, advantages, and control using the l298 driver. The document also includes a schematic layout and c code for controlling the motor.

Typology: Slides

2018/2019

Uploaded on 10/14/2019

sathiyanme
sathiyanme 🇮🇳

1 document

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Stepper Motor Interfacing
Embedded System Design 14EC2029
Dr. S. Paul Sathiyan
KITS | EEE | VER 1.1 | AY 2018 2019
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Stepper Motor Control: L298 Motor Driver & AVR Microcontroller and more Slides Embedded Systems in PDF only on Docsity!

Stepper Motor Interfacing

Embedded System Design 14EC

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

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 L 298 or L 6201 / 2 / 3 for which behavioral simulator

models are also provided.

H/W Configurations

  • Direction Control Switch is connected to PortB DO and D 1 bits
  • Phase A of stepper motor is connected to OUT 1 and OUT 2 of L 298
  • Phase B of stepper motor is connected to OUT 3 and OUT 4 of L 298
  • IN 1 of L 298 is connected to PORTA Bit 1 (D 1 )
  • IN 2 of L 298 is connected to PORTA, Bit 2 (D 2 )
  • IN 3 of L 298 is connected to PORTA, Bit 5 (D 5 )
  • IN 4 of L 298 is connected to PORTA, Bit 6 (D 6 )
  • ENA and ENB is connected to + 5 V

Schematic Layout

PE0/RXD0/PDI

2

PE1/TXD0/PDO

3

PE2/XCK0/AIN

4

PE3/OC3A/AIN

5

PE4/OC3B/INT

6

PE5/OC3C/INT

7

PE6/T3/INT

8

PE7/ICP3/INT

9

PB0/SS

10

PB1/SCK

11

PB2/MOSI

12

PB3/MISO

13

PB4/OC

14

PB5/OC1A

15

PB6/OC1B

16

PB7/OC2/OC1C

17

PG3/TOSC

18

PG4/TOSC

19

RESET

20

XTAL

23

XTAL

24

PD0/SCL/INT

25

PD1/SDA/INT

26

PD2/RXD1/INT

27

PD3/TXD1/INT

28

PD4/ICP

29

PD5/XCK

30

PD6/T

31

PD7/T

32

PG0/WR

33

PG1/RD

34

PC0/A

35

PC1/A

36

PC2/A

37

PC3/A

38

PC4/A

39

PC5/A

40

PC6/A

41

PC7/A

42

PG2/ALE

43

PA7/AD

44

PA6/AD

45

PA5/AD

46

PA4/AD

47

PA3/AD

48

PA2/AD

49

PA1/AD

50

PA0/AD

51

PF7/ADC7/TDI

54

PF6/ADC6/TDO

55

PF5/ADC5/TMS

56

PF4/ADC4/TCK

57

PF3/ADC

58

PF2/ADC

59

PF1/ADC

60

PF0/ADC

61

AREF

62

AVCC

64 PEN

1

ATMEGA

IN

5

IN

7

ENA

6

OUT

2

OUT

3

ENB

11 OUT

13

OUT

14

IN

10

IN

12

SENSA

1

SENSB

15 GND

8

VS

4

VCC

9 U

L

D

LED-BLUE

REVERSE

D

LED-GREEN

FORWARD

B

12V

A

B

C

D

+88.

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;