Exercise-3: Drive a 4-wire stepper motor

  • In this exercise you should build a project for driving a 4-wire stepper motor with STM32F4 Discovery board, in Keil uVision.
  • We want from you to define four key for control the rotating of motor
    • key1 & key2: to determine speed of motor rotating
      • key2=0 & key1=0: delay between steps of driving = 10ms
      • key2=0 & key1=1: delay between steps of driving = 50ms
      • key2=1 & key1=0: delay between steps of driving = 200ms
      • key2=1 & key1=1: delay between steps of driving = 1000ms
    • key3: to determine direction of motor rotating
      • key3=0: clockwise (CW)
      • key3=1: counterclockwise (CCW)
    • key4: drive mode
      • key4=0 ==> full step mode
      • key4=1 ==> half step mode
  • In the below you can see the hardware for this simple example:

    First time Keil uVision

  • We use L293D for our drive. (L293D is a push-pull four channel driver with diodes).

  • The below schematic, demonstrate our driving circuit:

    First time Keil uVision

  •   Note:
    1. Since in the above we connect keys to HIGH, the input pins should define in pull down mode.  (In the above, we connect keys to PC[6:9])
    2. Since PD[12:15] is connected to LEDs, If you define PD[12:15] as your output, debugging of your code is easier.
    3. Pins of L293D emphasized with green boxes.
    4. Pin8 of L293D is Supply Voltage which should set based on the nominal voltage of the motor. (nominal voltage of our motor is 4.5V, so we connect Pin8 of L293D to available 5V on the STM32F4 Discovery board.)
    5. Pin16 of L293D is Logic Supply Voltage which we connect this Pin of L293D to 5V.
  •  

  • Our Stepper Motor Characteristics
    • Angle step: 1.8 Degree
    • Voltage: 5V
    • Current: 1A
  •  

  • Question: How many pulses needed for one complete rotation of our motor?

Wave Drive

Step Number

Step Position

Coil 1

Coil 2

Coil 3

Coil 4

1

0

OFF

OFF

OFF

ON

2

1

OFF

OFF

ON

OFF

3

2

OFF

ON

OFF

OFF

4

3

ON

OFF

OFF

OFF

Stepper Motor Single Coil Excitation Animation

Full Step

Step Number

Step Position

Coil 1

Coil 2

Coil 3

Coil 4

1

0

ON

ON

OFF

OFF

2

2

OFF

ON

ON

OFF

3

4

OFF

OFF

ON

ON

4

6

ON

OFF

OFF

ON

Stepper Motor Two Coil Excitation Animation

Half Step

Step Number

Step Position

Coil 1

Coil 2

Coil 3

Coil 4

1

0.0

ON

OFF

OFF

OFF

2

0.5

ON

ON

OFF

OFF

3

1.0

OFF

ON

OFF

OFF

4

1.5

OFF

ON

ON

OFF

5

2.0

OFF

OFF

ON

OFF

6

2.5

OFF

OFF

ON

ON

7

3.0

OFF

OFF

OFF

ON

8

3.5

ON

OFF

OFF

ON

Stepper Motor Half Step Animation

Wave Drive: More realistic picture

First time Keil uVision

Sharif University of Technology, Tehran, Iran