ST AN3208 Application note

AN3208

Application note

Microstepping motor drive with STM8A and STM8S microcontrollers

Introduction

Stepper motors are electrically powered motors that create rotation from electrical current driven into the motor.

They are used in a wide variety of applications such as printers, automated machine tools, disk drives, automotive dashboard instrument clusters, and other applications requiring precise motion control. They are well-suited for positioning applications since they can achieve very good positional accuracy without complicated feedback loops associated with servomechanism (servo) systems. However, their resolution, when driven in the conventional full or half step modes of operation, is limited by the configuration of the motor.

Many designers today seek methods to increase the resolution of stepper motor drives. Dedicated stepper motor controllers/ICs are available on the market. These controllers contain the special logic and high-current drive circuits necessary to operate the stepper motors. In some applications, for example in automotive dashboards, stepper motors with a lower current rating (20 mA) are used to power the needles or pointers that display parameters such as vehicle speed or the engine RPM.

Stepper motors need to be driven in microstepping mode (see Section 4: Driving stepper motors using STM8A and STM8S microcontrollers). However, in this case, the use of dedicated stepper motor controllers may increase the system cost and complexity. As an alternative, the motors can be driven easily using the resources located within a microcontroller (example, pulse-width modulation timers and I/O pins), thus reducing the hardware cost and complexity. CPU load is very low when using internal resources and the microcontroller is not precluded from performing other control activities or driving other external peripherals. For example, the STM8 is able to drive two stepper motors together with an LCD glass containing a high number of segments such as a motorcycle dashboard application.

The application described in this document is a software/low cost solution to drive stepper motors in microstepping mode using the STM8 microcontroller. The main focus of this application note is to explain how to drive the microstepping motor with STM8A and STM8S devices. An overview of the various stepper motor types is given in Section 2: Types of stepper motor. Stepper motor basics are explained inSection 4: Driving stepper motors using STM8A and STM8S microcontrollers. Section 5 summarizes stepper motor software.

Reference documents

STM8A reference manual (RM0009)

STM8S reference manual (RM0016)

STM8A/S datasheets

Reference firmware

STM8A/S firmware library

July 2010

Doc ID 17411 Rev 1

1/19

www.st.com

Contents

AN3208

 

 

Contents

1

Winding arrangement in two-phase stepper motors . . . . . . . . . . . . . .

. 5

2

Types of stepper motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. 6

 

2.1

Variable-reluctance (VR) motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6

 

2.2

Permanent magnet (PM) motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7

 

2.3

Hybrid synchronous motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7

3

Microstepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8

4

Driving stepper motors using STM8A and

 

 

STM8S microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

9

5

Software . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13

 

5.1

Preliminary information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13

 

5.2

Software description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13

 

 

5.2.1

Main program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13

 

 

5.2.2

TIM1 interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15

6

Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

18

2/19

Doc ID 17411 Rev 1

AN3208

List of tables

 

 

List of tables

Table 1. PWM duty cycles for an M-S motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Table 2. Specific duty cycles of the TIM1 registers and I/O values . . . . . . . . . . . . . . . . . . . . . . . . . 15 Table 3. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Doc ID 17411 Rev 1

3/19

List of figures

AN3208

 

 

List of figures

Figure 1. Unipolar winding arrangement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Figure 2. Bipolar winding arrangement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Figure 3. Variable-reluctance motor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Figure 4. Permanent magnet motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Figure 5. Hybrid synchronous motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Figure 6. Current waveforms with 90 ° phase difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Figure 7. Functional block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Figure 8. Stepper motor schematic layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Figure 9. Stepper motor pin configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Figure 10. Current waveforms (Switec M-S motor) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Figure 11. Stepper motor configuration pin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Figure 12. Main program flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Figure 13. TIM1 interrupt (microstep output) flow chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4/19

Doc ID 17411 Rev 1

AN3208

Winding arrangement in two-phase stepper motors

 

 

1 Winding arrangement in two-phase stepper motors

There are two basic winding arrangements for the electromagnetic coils in a two-phase stepper motor: bipolar and unipolar.

The unipolar stepper motor has two identical coils which are not connected electrically and each coil has a centre tap.

Figure 1. Unipolar winding arrangement

The bipolar stepper motor is the same as the unipolar stepper except the motor coils do not have the center taps. Bipolar motor can produce higher torque in comparison to the unipolar motor as the entire coil is energized and not just half-coils.

Figure 2. Bipolar winding arrangement

Doc ID 17411 Rev 1

5/19

ST AN3208 Application note

Types of stepper motor

AN3208

 

 

2 Types of stepper motor

There are three main types of stepper motors:

1.Variable-reluctance stepper motor

2.Permanent magnet stepper motor

3.Hybrid synchronous stepper motor

2.1Variable-reluctance (VR) motor

This type of motor contains a soft iron multi-toothed rotor and a wound stator. When the stator windings are energized with DC current, it magnetizes the stator poles. Rotor teeth are attracted towards the energized stator poles and the rotation occurs. The variablereluctance motor does not use permanent magnets, so the field strength can be varied. The VR motor generates less torque so it is generally used for small positioning loads. Figure 3 shows a cross section of a typical VR stepper motor.

Figure 3. Variable-reluctance motor

6/19

Doc ID 17411 Rev 1

Loading...
+ 13 hidden pages