intel's mcs-51 family of microcontrollers and its derivatives … ·  · 2016-08-24the...

23
STEPPER MOTOR INTERFACE 1 CONTENTS PAGE NO 1.0 Introduction & Theory 3 1.1 Permanent Magnet (PM) Stepper Motors 3 1.2 Variable Reluctance (VR) Stepper Motors 4 2.0 Applications of Stepper Motors 5 3.0 Circuit Description 5 3.1 Specifications of the Stepper Motor Used 6 4.0 Installation 6 5.0 Demonstration Examples 7 5.1 Demonstration Program for MPS 85-3 Trainer 7 5.2 Demonstration Program for ESA 85-2 Trainer 8 5.3 Demonstration Program for ESA-80 Trainer 9 5.4 Demonstration Program for ESA-65 Trainer 10 5.5 Demonstration Program for ESA-31 Trainer 11 5.6 Demonstration Program for ESA-68K Trainer 12 5.7 Demonstration Program for ESA-196 Trainer 13 5.8 Demonstration Program for ESA 86/88-2 Trainer 14 5.9 Demonstration Program for ESA 68-2 Trainer 14 5.10 Demonstration Program for ESA-51 Trainer 15 5.11 Demonstration Program for ESA 86/88-3 Trainer 17

Upload: dangminh

Post on 05-May-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

STEPPER MOTOR INTERFACE

1

CONTENTS

PAGE NO

1.0 Introduction & Theory 3

1.1 Permanent Magnet (PM) Stepper Motors 3

1.2 Variable Reluctance (VR) Stepper Motors 4

2.0 Applications of Stepper Motors 5

3.0 Circuit Description 5

3.1 Specifications of the Stepper Motor Used 6

4.0 Installation 6

5.0 Demonstration Examples 7

5.1 Demonstration Program for MPS 85-3 Trainer 7

5.2 Demonstration Program for ESA 85-2 Trainer 8

5.3 Demonstration Program for ESA-80 Trainer 9

5.4 Demonstration Program for ESA-65 Trainer 10

5.5 Demonstration Program for ESA-31 Trainer 11

5.6 Demonstration Program for ESA-68K Trainer 12

5.7 Demonstration Program for ESA-196 Trainer 13

5.8 Demonstration Program for ESA 86/88-2 Trainer 14

5.9 Demonstration Program for ESA 68-2 Trainer 14

5.10 Demonstration Program for ESA-51 Trainer 15

5.11 Demonstration Program for ESA 86/88-3 Trainer 17

STEPPER MOTOR INTERFACE

2

5.12 Demonstration Program for ESA 51E Trainer 19

5.13 Demonstration Program for ESA 86/88E Trainer 21

6.0 Exercises 23

Appendix A : Component Layout Diagram

Appendix B : Schematic Diagram

Appendix C : Illustration of Stepper Motor Operating Principle

STEPPER MOTOR INTERFACE

3

STEPPER MOTOR INTERFACE

1.0 INTRODUCTION & THEORY

Electro Systems Associates Private Limited (ESA) manufacturers trainers for most of the

popular microcomputers viz 8085, Z-80, 6502, 8031, 8086/8088 and 68000. ESA offers a

variety of modules which can be interfaced to these trainers. These modules can be

effectively used for teaching/training in the laboratories.

Data acquisition and control represent the most popular applications of microprocessors. Stepper

Motor control is a very popular application of microprocessors in control area, as stepper motors

are capable of accepting pulses directly from the microprocessor and move accordingly.

There are two types of stepper motors:

(a) Permanent magnet (PM)

(b) Variable reluctance (VR).

The principle and operation of these motors are explained below.

1.1 PERMANENT MAGNET STEPPER MOTORS

Fig (in Appendix B) shows a PM stepper motor in its simplest form. It consists of two stator

windings A, B and a motor having two magnetic poles N and S. When a voltage +V is applied

to stator winding A, a magnetic field Fa is generated as shown in Fig (a). The rotor positions

itself such that its poles lock with corresponding stator poles.

With the winding `A' excited as before , winding `B' is now switched on to a voltage +V as shown

in Fig (b). This produces a magnetic field Fb in addition to Fa. The resulting magnetic field F

makes an angle of 45 degrees as shown in Fig (b). The rotor consequently moves through 45 in

anti-clock-wise direction , again to cause locking of rotor poles with corresponding stator poles.

While winding `B' has voltage +V applied to it, winding `A' is switched off in Fig(c). The rotor

then moves through a further 45 degrees in anti-clockwise direction to align itself with stator

field Fb. With voltage +V on winding B, a voltage -V is applied to winding A as shown in Fig

(d). Then the stator magnetic field has two components: Fa , Fb and their resultant F makes an

angle of 135 degrees position .

In this way it can be seen that, as the pattern of excitation of the state of windings is changed, the

rotor moves successively through 45 degrees steps through Figs (e) to (h), and completes one full

revolution in anti-clock-wise direction. The figures are meant only to illustrate the principle of

STEPPER MOTOR INTERFACE

4

operation of PM stepper motor. A practical PM stepper motor will have 1.8 degrees step angle

and 50 tooth on its rotor; there are eight main poles on the stator, each having five tooth in the

pole face. The step angle is given by

A = 360 / (N*K) degrees

where N = number of rotor tooth

K = excitation sequence factor

PM stepper motors have three modes of excitation i.e.,

Single phase mode

Two phase mode

Hybrid mode.

Single Phase Mode: Figs (a,c,e,g) illustrate the single phase mode in which only one of the motor

windings is excited at a time. There are four steps in the sequence, the excitation sequence factor

K=2, so that step angle is 90 degrees.

Two Phase Mode: Here both the stator phases are excited at a time as shown in figs (b,d,f,h). There

are four steps in the excitation sequence, K=2 and step angle is 90 degrees. However, the rotor

positions in the two-phase mode are 45 degrees away from those in single phase mode.

Hybrid Mode: This is a combination of single phase and two phase modes as shown in Figs (a-

h). There are eight steps in excitation sequence; K=2 and step angle = 45 degrees.

From Figs (a-h), it can be observed that a voltage +V is applied to a stator winding during some

steps, while voltage -V is applied during certain other steps. This requires a bipolar regulated

power supply capable of yielding +V, -V and zero outputs and a pair of SPDT switches, which is

quite cumbersome. Consequently each of the two stator windings is split into two sections A1-A2,

B1-B2. These sections are wound differentially as shown by the polarity dots in Fig (j). These

winding sections can now be excited from a unipolar regulated power supply through switches S1

to S4 as shown in Fig (j). This type of construction is called bipolar winding construction.

Bipolar winding results in reduced winding inductance and consequently improved torque

stepping rate characteristics.

1.2 VARIABLE RELUCTANCE (VR) STEPPER MOTORS

The schematic diagram of a simple Variable Reluctance (VR) stepper motor is shown in fig (K).

There are twelve tooth on the stator and eight on the rotor. The rotor does not carry either a

permanent magnet or winding; it is assembled from soft iron punchings. The stator is also

assembled from soft iron punchings, and carries stator windings A,B and C as shown in Fig (k).

When stator winding A is excited, it creates a patterns of N and S poles as shown in Fig (i). The

rotor then positions itself as shown in Fig (i), so as to minimize the reluctance of the magnetic

circuit. When phase B is excited next, the rotor will move through 15 degrees to again seek

STEPPER MOTOR INTERFACE

5

minimum reluctance position. VR stepper motors are available as 3-5 phase motors with step angle

given by

B = 360 ( N1-N2)

N1*N2

Where N1 = number of stator tooth

N2 = number of rotor tooth

N1 and N2 are related by

N1 = N2+n = p*n

Where n = number of stator tooth per phase

p = number of phases

2.0 APPLICATIONS OF STEPPER MOTORS

There are several areas of stepper motor applications like instrumentation, computer peripherals, and

machine tool drives. Tiny stepper motors are used in quartz analog electronic watches for driving

the second, minute and hour hands. These motors operate directly with the button cells used in

these electronic watches. Bigger stepper motors are used for driving the hands of slave clocks on

railway platforms, bus stations, offices, factories etc. Computer peripherals form an important

area of stepper motor applications. Card readers/punches, paper tape readers/punchers, teleprinters

and teletypes represent the first applications area of stepper motors. Digital X-Y plotters and dot

matrix printers use stepper motors for driving the arm and pen, and the paper respectively. Stepper

motors find application in line printers to drive the paper advance mechanism. Floppy disks and

hard/winchester disks have their magnetic reading/writing heads positioned by stepper motors.

The main application area of stepper motors is in numerical control (NC) systems for machine

tools. Here they are employed for driving the cutting tool along x,y,z directions. Another application

in this area is the coordinate table. Indexing mechanisms used in multistation machine tools employ

stepper motors for moving either work piece or cutting tools.

Stepper motors find application in positioning the spraying gun in spray painting machines. In

the medical field, positioning servos for X-ray machines or Radio-isotope heads employ stepper

motor drives. The latest application of stepper motors is in industrial robots for actuating the

robot joints.

3.0 CIRCUIT DESCRIPTION

The stepper motor interface uses four transistor pairs (SL100 & 2N3055) in a darlington pair

configuration. Each darlington pair is used to excite the particular winding of the motor connected to

STEPPER MOTOR INTERFACE

6

4 pin connector on the interface. T he inputs to these transistors are from the 8255 PPI I/O lines of

the Microprocessor Trainer kit or from Digital I/O card plugged in the PC. "Port A" lower nibble

PA0, PA1, PA2, PA3 are the four lines brought out to the 26 pin FRC male connector (J1) on the

interface module. The free-wheeling diodes across each winding protect transistors from switching

transients. Refer to appendix B for detailed schematic diagram.

3.1 SPECIFICATION OF THE STEPPER MOTOR USED

The stepper motor specification is available at the end of the manual. The motor is reversible on with

a torque of 3kgcm. The power requirement is +5V DC @ 1.2A current per winding at full torque.

The step angle is 1.8* i.e, for every single excitation, the motor shaft rotates by 1.8*. For the motor to

rotate one full revolution (360*), number of steps required is 200. The stepper motor used has four

stator windings which are brought out through coloured wires terminated at a 4 pin polarized female

connector. The remaining two wires ( usually White & Black wires) are shorted and terminated at 2

pin polarized female connector.

4.0 INSTALLATION

The interface is housed in a plastic enclosure which has a locking mechanism. To open the cover,

push in the locking mechanism with a finger and lift the cover to open.

The interface has two nos of 3 pin and one four pin connectors. Plug in four pin polarised

connector of the motor to interface and the 3 pin connector of the motor to the 3 pin connector of the

interface marked as "WHT BLK". Connect the 3 pin female connector of the stepper motor power

supply to the connector on the interface marked as "GND +5/12V". Connect the 26 core flat ribbon

cable to J1 connector on the interface module and the other end of the cable to Microprocessor trainer

kit as stated in Table 3.1. Now the installation is done. Switch on power to the trainer kit as well as

the stepper motor. Key-in the demo program for the appropriate trainer & execute the same. When

the program is executed, the motor shaft rotates in steps at the speed depending upon the delay

between successive steps, which is generated and can be controlled by the program. The direction of

rotation can also be controlled through software.

STEPPER MOTOR INTERFACE

7

5.0 DEMONSTRATION EXAMPLES

Table 3.1 shows the connectors on various trainers to which this interface can be connected. Some

trainers have two connectors to which this interface can be connected. The demonstration

programs presented in this manual assumes that the connectors shown in column A are used, then

user has to change the port addresses appropriately. User may refer to component layout diagrams

of respective ESA trainer to locate the connectors mentioned here.

TABLE-3.1

MICROPROCESSOR

TRAINER

A B

MPS 85-3 J2 J1

ESA 85-2 J2 J1

ESA-80 J2 J1

ESA-65 P4

ESA-68K P3 P4

ESA 68K-2 J2 J1

ESA 68-2 J1 J6

ESA 196 J1 J2

ESA-31 J2 J1

ESA-51 J10 J7

ESA-51E J5 J3

ESA 86/88-2 J4 J5

ESA 86/88-3 J8 J9

ESA-86/88E J4 J6

5.1 DEMONSTRATION PROGRAM FOR MPS 85-3 TRAINER

; Assume the interface is connected over J2 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

CMD55 EQU 43H

PORTA EQU 40H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

8C00 3E 80 MVI A,80H ;All ports are O/P

8C02 D3 43 OUT CMD55

8C04 3E 88 MVI A, 88H ;Initial bit

;pattern

8C06 D3 40 LOOP: OUT PORT A ;Bit PA0-PA3

;used to control

STEPPER MOTOR INTERFACE

8

;the motor

8C08 CD 20 8C CALL DELAY ;Delay between

;steps

8C0B 0F RRC ;change this

;to RLC to

;reverse the

;direction

8C0C C3 06 8C JMP LOOP

ORG 8C20H

8C20 F5 DELAY: PUSH PSW ;This routine

;gives an

8C21 21 01 00 LXI H,0001H ;approximate

;delay of 1.5secs

8C24 11 FF FF DELAY20: LXI D,0FFFFH

8C27 1B DELAY10: DCX D

8C28 7A MOV A,D

8C29 B3 ORA E

8C2A C2 27 8C JNZ DELAY10

8C2D 2B DCX H

8C2E 7C MOV A,H

8C2F B5 ORA L

8C30 C2 24 8C JNZ DELAY20

8C33 F1 POP PSW

8C34 C9 RET

5.2 DEMONSTRATION PROGRAM FOR ESA 85-2 TRAINER

; Assume the interface is connected over J2 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

CMD55 EQU 43H

PORT A EQU 40H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

8000 3E 80 MVI A,80H ;All Ports are

8002 D3 43 OUT CMD55 ;output Ports

8004 3E 88 MVI A,88H ;Initial bit

;pattern

8006 D3 40 LOOP: OUT PORT A ;Bit PA0-PA3

;used to control

;the motor

8008 CD 20 80 CALL DELAY ;Delay between

;steps

STEPPER MOTOR INTERFACE

9

800B 0F/07 RRC ;Instruction RLC

;is used to

;reverse the

;direction of

;Motor rotation

800C C3 06 80 JMP LOOP

ORG 8020H

8020 F5 DELAY: PUSH PSW ;This routine

8021 21 01 00 LXI H,0001H ;gives an

;approximate

;delay of 1.5secs

8024 11 FF FF DELAY20: LXI D,0FFFFH ;approximate

8027 1B DELAY10: DCX D

8028 7A MOV A,D

8029 B3 ORA E

802A C2 27 80 JNZ DELAY10

802D 2B DCX H

802E 7C MOV A,H

802F B5 ORA L

8030 C2 24 80 JNZ DELAY20

8033 F1 POP PSW

8034 C9 RET

5.3 DEMONSTRATION PROGRAM FOR ESA-80 TRAINER

; Assume the interface is connected over J2 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

8000 3E 80 LD A,80H ;Initialize 8255

8002 D3 43 OUT (43H),A ;for all ports

;Output

8004 06 88 LD B,88H ;Initial bit

;pattern

8006 0E 40 LD C,40H ;To be sent to

;motor

8008 ED 41 LOOP: OUT (C),B ;Pattern sent

;on PA0-PA3

800A CD 11 80 CALL DELAY ;Delay between

;Successive steps

800D CB 08 RRC B ;Next Pattern

;to be sent.

800F 18 F7 JR LOOP ;Go back to

STEPPER MOTOR INTERFACE

10

;send the next

;pattern

8011 16 01 DELAY: LD D,COUNT1 ;Subroutine

;generating the

8013 21 00 00 LD HL,COUNT2 ;delay between

8016 2B DEC HL ;successive

;steps =1.5secs

8017 7C LD A,H

8018 B5 OR L

8019 20 FB JR NZ,DELAY+5

801B 15 DEC D

801C 20 F5 JR NZ,DELAY+2

801E C9 RET

5.4 DEMONSTRATION PROGRAM FOR ESA-65 TRAINER

; Assume the interface is connected over P4 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

CMDPORT EQU A043H

PORTA EQU A040H

COUNT1 EQU 00H

COUNT2 EQU FFH

COUNTER1 EQU 1050H

COUNTER2 EQU 1051H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

1000 A9 80 LDA #80 ;Initialize

;8255 for all

;ports output

1002 8D 43 A0 STA CMDPORT

1005 A2 04 REPEAT: LDX #04

1007 A9 88 LDA #88 ;Bit pattern

;to be sent

1009 8D 40 A0 LOOP: STA PORTA ;Output the

;bit pattern

100C 20 16 10 JSR DELAY ;Generate a

;step delay of

;approximately

;0.6 sec

100F CA DEX

1010 F0 F3 BEQ REPEAT

1012 4A LSR A

STEPPER MOTOR INTERFACE

11

1013 4C 09 10 JMP LOOP ;Go back to send

;the next pattern

1016 A0 00 DELAY: LDY #COUNT1 ;delay routine

1018 8C 50 10 STY COUNTER1

101B A0 FF DELAY10: LDY #COUNT2

101D 8C 51 10 STY COUNTER2

1020 CE 51 10 DELAY20: DEC COUNTER1

1023 D0 FB BNE DELAY20

1025 CE 50 10 DEC COUNTER1

1028 D0 F4 BNE DELAY10

102A 60 RTS

5.5 DEMONSTRATION PROGRAM FOR ESA-31 TRAINER

; Assume the interface is connected over J2 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

SEG EQU 0E8H

P2 EQU 0A0H

DPL EQU 82H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

8000 75 A0 E8 MOV P2,#SEG ;Configure

8003 78 03 MOV R0,#03H ;8255 for all

8005 74 80 MOV A,#80H ;ports output

8007 F2 MOVX @R0,A

8008 74 88 MOV A,#88H ;Initialise

;bit pattern

;Bit PA0-PA3

;used to

800A 78 00 LOOP: MOV R0,#00H ;control

800C F2 MOVX @R0,A ;motor Out at

;Port A

800D 12 80 13 LCALL DELAY

8010 03 RR A ;Rotate right

8011 80 F7 SJMP LOOP

8013 F9 DELAY: MOV R1,A ;Delay Routine

8014 7A 03 MOV R2,#03H

8016 90 00 00 DELAY2: MOV DPTR,#0000H

8019 A3 DELAY1: INC DPTR

801A E5 82 MOV A,DPL

801C 45 82 ORL A,DPL

STEPPER MOTOR INTERFACE

12

801E 70 F9 JNZ DELAY1

8020 DA F4 DJNZ R2,DELAY2

8022 E9 MOV A,R1

8023 22 RET

5.6 DEMONSTRATION PROGRAM FOR ESA-68K TRAINER

; Assume the interface is connected over P3 of the trainer.

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

040600 20 7C 00 MOVE.L #$80306,A0

08 03 06

040606 10 BC 00 MOVE.B #$80,(A0) ;Initialise

80 ;8255 for

;all ports

04061A 12 3C 00 MOVE.B #$88,D1 ;Bit pattern

88 ;sent to motor

04060E 22 7C 00 MOVE.L #$80300,A1

08 03 00

040614 12 81 MOVE.B D1,(A1) ;Pattern sent

;to PA0-PA3

040616 4E B9 00 JSR.L $00040624 ;Delay

04 06 24 ;between

;successive

;steps

04061C E2 19 ROR.B #$1,D1 ;Next pattern

;to be sent

04061E 4E F9 00 JMP.L $00040614 ;Go back to

04 06 14 ;send the

;next pattern

040624 24 3C 00 DELAY: MOVE.L #$0FFFF,D2 ;Subroutine

00 FF FF ;generating

04062A 04 82 00 SUB.L #$1,D2 ;the delay

00 00 01 ;between

040630 66 F8 BNE #$04062A ;successive

040632 4E 75 RTS ;steps

5.7 DEMONSTRATION PROGRAM FOR ESA 196 TRAINER

;Assume the trainer is connected over J1 of the trainer.

;The trainer can be in KEYBOARD MODE or SERIAL mode.

STEPPER MOTOR INTERFACE

13

REG1 EQU 52H

REG2 EQU 60H

REG3 EQU 56H

REG4 EQU 64H

PORT_A EQU 200H

PORT_B EQU 202H

CMD_PORT EQU 206H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

8000 B1 80 52 LDB REG1,#80H ;Initialise

8003 C7 01 06 02 STB REG1,CMD_PORT ;8255 for

8007 52 ;all O/P Ports.

8008 B1 88 52 LDB REG1,#88H ;Initial bit

;pattern.

800B C7 01 00 02 LOOP: STB REG1,PORT_A ;Bit PA0-PA3

800F 52 ;used to control

;the motor.

8010 EF 07 00 LCALL DELAY

8013 19 01 52 SHLB REG1,#01H ;Use

;'SHRB REG1,#01H'

8016 DB 15 JC ADDR ;Instruction to

;change the

;direction of

;the motor.

8018 27 F1 BACK: SJMP LOOP ;Loop back.

801A F2 DELAY: PUSHF ;Delay

801B A1 05 00 60 LD REG2,#0005H ;Routine.

801F A1 FF DF 56 DEL20: LD REG3,#0DFFFH

8023 05 56 DEL10: DEC REG3

8025 D7 FC JNE DEL10

8027 05 60 DEC REG2

8029 D7 F4 JNE DEL20

802B F3 POPF

802C F0 RET

802D 91 01 52 ADDR: ORB REG1,#01H ;Use 'ORB REG1,

;#080H'

8030 27 E6 SJMP BACK ;Instruction

;instead of 'SHRB

;REG1,#01H'is

;used to change

;the direction

5.8 DEMONSTRATION PROGRAM FOR ESA 86/88-2 TRAINER

STEPPER MOTOR INTERFACE

14

; Assume the interface is connected over J4 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

2000 B0 80 MOVB AL,#80. ;Initialize 8255

2002 BA E6 FF MOVW DX,#0FFE6 ;All ports output.

2005 EE OUTB DX

2006 B0 88 MOVB AL,#88 ;Initial bit

;pattern to be

;sent to motor

2008 BA E0 FF MOVW DX,#0FFE0 ;pattern sent on

200B EE OUTB DX ;PA0-PA3.

200C E8 11 00 CALL DELAY ;Delay between

200F 90 XCHGW AX,AX ;successive steps

2010 D0 C8 RORB AL,1 ;Next pattern

;to be sent

2012 EB F4 JMP 2008 ;Go back to send

;the next pattern

2020 9C DELAY: PUSHF

2021 50 PUSH AX ;Subroutine for

;the delay

;between

;successive Steps

2022 BB FF 0F MOVW BX,#0FFF

2025 4B LOOP: DECW BX

2026 75 FD JNZ LOOP

2028 58 POP AX

2029 9D POPF

202A C3 RET

5.9 DEMONSTRATION PROGRAM FOR ESA 68-2 TRAINER

; Assume the interface is connected over J1 of the trainer.

; The trainer can be in KEYBOARD MODE or SERIAL MODE.

CNTLA EQU 0C801H

CNTLB EQU 0C803H

DIRA EQU 0C800H

DIRB EQU 0C802H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

ORG 400H

STEPPER MOTOR INTERFACE

15

0400 4F CLRA ;INTIALISE 8255

0401 B7 C8 01 STA CNTLA ;ALL PORTS OUTPUT

0404 B7 C8 03 STA CNTLB ;INITIAL BIT PATTERN

0407 B6 04 47 LDA BREG

040A 43 COMA ;BIT PA0-PA3

040B B7 C8 00 STA DIRA ;USED TO CONTROL

040E B7 C8 02 STA DIRB ;THE MOTOR

0411 B7 C8 01 STA CNTLA

0414 B7 C8 03 STA CNTLB

0417 CC 05 50 LDD #$550

041A 1F 03 TFR D,U

041C 86 11 LOOP: LDA #11H ;ROTATES LEFT

041E B7 C8 00 STA DIRA

0421 8D 17 BSR DELAY ;DELAY BETWEEN STEPS

0423 86 22 LDA #22H ;IF DIRECTION OF

0425 B7 C8 00 STA DIRA ;ROTATION OF MOTOR

;HAS TO BE CHANGED

0428 8D 10 BSR DELAY ;THAT IS TO RIGHT

042A 86 44 LDA #44H ;LOAD PORT A WITH

042C B7 C8 00 STA DIRA ;PATTERN IN THE

042F 8D 09 BSR DELAY ;REVERSE ORDER WITH

;88H,44H,22H,11H.

0431 86 88 LDA #88H

0433 B7 C8 00 STA DIRA ;PRESS RESET KEY ON

0436 8D 02 BSR DELAY ;THE TRAINER TO COME

0438 20 E2 BRA LOOP ;OUT OF LOOP.

043A 36 02 DELAY: PSHU A ;DELAY ROUTINE

043C CC FF FF LDD #$0FFFF

043F 83 00 01 DELAY1: SUBD #1H

0442 26 FB BNE DELAY1

0444 37 02 PULU A

0446 39 RTS

0447 00 00 BREG: FDB 0

0449 00 00 CREG: FDB 0

5.10 DEMONSTRATION PROGRAM FOR ESA-51 TRAINER

;Assume the interface is connected over J10 of the trainer.

;The trainer can be in KEYBOARD MODE or in SERIAL MODE.

SEG EQU 0E8H

P2 EQU 0A0H

DPL EQU 82H

OUTPUT EQU 0404H

STEPPER MOTOR INTERFACE

16

GETCH EQU 12BBH

GETKB EQU 0161H

DSPCHR EQU 3E6H

ADDRESS OPCODE LABLE MNEMONIC COMMENT

8000 ORG 8000H

8000 90 80 75 MOV DPTR,#MSG ;To display

8003 12 04 04 LCALL OUTPUT ;the message.

8006 90 E9 04 MOV DPTR,#E904H ;check for serial

8009 E0 MOVX A,@DPTR ;or keyboard mode

800A 20 E3 05 CHK: JB ACC.3,KBD

800D 12 12 BB LCALL GETCH ;Get the key code

8010 80 03 SJMP L1

8012 12 01 61 KBD: LCALL GETKB ;Get the key code

8015 B4 41 05 L1: CJNE A,#41H,L2 ;Checking for 'A'

8018 12 03 E6 LCALL DSPCHR ;Display character

801B 80 1B SJMP L3 ;Jump to routine

801D B4 61 05 L2: CJNE A,#61H,L4 ;Checking for 'a'

8020 12 03 E6 LCALL DSPCHR ;Display character

8023 80 13 SJMP L3 ;Jump to routine

8025 B4 43 05 L4: CJNE A,#43H,L5 ;Checking for 'C'

8028 12 03 E6 LCALL DSPCHR ;Display character

802B 80 22 SJMP L6 ;Jump to routine

802D B4 63 05 L5: CJNE A,#63H,L7 ;Checking for 'c'

8030 12 03 E6 LCALL DSPCHR ;Display character

8033 80 1A SJMP L6 ;Jump to routine

8035 02 00 00 L7: LJMP 0

;Routine for clockwise rotation

8038 75 A0 E8 L3: MOV P2,#SEG ;Configure 8255

803B 78 03 MOV R0,#03H ;For all ports O/P

803D 74 80 MOV A,#80H

803F F2 MOVX @R0,A

8040 74 88 MOV A,#88H ;Initialise bit

;pattern. Bit PA0-

;PA3 used to control

;motor

8042 78 00 LOOP: MOV R0,#00H ;O/P the pattern

8044 F2 MOVX @R0,A ;to Port A

8045 C0 E0 PUSH A

8047 12 80 66 LCALL DELAY

804A D0 E0 POP A

804C 23 RL A

STEPPER MOTOR INTERFACE

17

804D 80 F3 SJMP LOOP

;Routine for anti-clockwise rotation

804F 75 A0 E8 L6: MOV P2,#SEG

8052 78 03 MOV R0,#03H

8054 74 80 MOV A,#80H

8056 F2 MOVX @R0,A

8057 74 88 MOV A,#88H

8059 78 00 LOOP1: MOV R0,#00H

805B F2 MOVX @R0,A

805C C0 E0 PUSH A

805E 12 80 66 LCALL DELAY

8061 D0 E0 POP A

8063 03 RR A

8064 80 F3 SJMP LOOP1

8066 7A 03 DELAY: MOV R2,#03H ;Delay routine

8068 90 05 00 DELAY2: MOV DPTR,#500H

806B A3 DELAY1: INC DPTR

806C E5 82 MOV A,DPL

806E 45 82 ORL A,DPL

8070 70 F9 JNZ DELAY1

8072 DA F4 DJNZ R2,DELAY2

8074 22 RET

8075 45 4E 54 45 52 MSG:DB 'ENTER OPTION(A/C):',00H

807A 20 4F 50 54 49

807F 4F 4E 28 41 2F

8084 43 29 3A 00

5.11 DEMONSTRATION PROGRAM FOR ESA 86/88-3 TRAINER.

; Assume the interface is connected over J8 of the trainer.

; This program illustrates the control of direction of

; rotation of the Stepper motor depending upon user choice.

; The program executes in a continuous loop.

; The program can be executed in STAND-ALONE MODE or SERIAL

; MODE of operation.

; The program starts at memory location 0:2000H

; Please refer ESA 86/88-3 user's manual for mnemonic

; syntax suitable to trainer

Code Segment :0000H

ADDRESS OPCODE LABEL MNEMONIC COMMENTS

STEPPER MOTOR INTERFACE

18

2000 B8 00 00 MOVW AX,0000H ;Initialise

;Segment

2003 8E C8 MOVW CS,AX ;Registers

2005 8E C0 MOVW ES,AX

2007 BA E6 FF MOVW DX,0FFE6H ;Initialise

200A B0 80 MOVB AL,80H ;all 8255

;Ports as o/p

200C EE OUTB DX,AL

200D EB 47 JMP START

; Display Message String

200F 0A 0D 53 54 45 50 MES: DB 0AH,0DH,'STEPPER MOTOR I/F'

2015 50 45 52 20 4D 4F

201B 54 4F 52 20 49 2F

2021 46

2022 0A 0D 45 4E 54 45 DB 0AH,0DH,'ENTER DIRECTION'

2028 52 20 44 49 52 45

202E 43 54 49 4F 4E

2033 0A 0D 41 20 2D 20 DB 0AH,0DH,'A - ANTICLOCKWISE'

2039 41 4E 54 49 43 4C

203F 4F 43 4B 57 49 53

2045 45

2046 0A 0D 43 20 2D 20 DB 0AH,0DH,'C - CLOCKWISE',00H

204C 43 4C 4F 43 4B 57

2052 49 53 45 00

2056 9A 31 00 00 FB START:CALLS 0FB00:0031H ;New line

;routine

205B 2E CS

205C 8D 16 0F 20 LEA DX,@MES ;Display message

2060 8B C2 MOVW AX,DX ;on LCD or Console

2062 9A 13 00 00 FB CALLS 0FB00:0013H ;Wait for

2067 9A A9 00 00 FB GET:CALLS 0FB00:00A9H ;user entry

206C 3C 41 CMPB AL,41H ;If key ='A',

206E 74 1D JE ANTI ;rotate anti-

;clockwise

2070 3C 43 CMPB AL,43H ;If key = 'C'

2072 74 02 JE CLO ;rotate clockwise

2074 EB F1 JMP GET ;Accept valid

;key only

; Routine for Clockwise rotation of motor

2076 9A 31 00 00 FB CLO:CALLS 0FB00:0031H

207B 9A 00 00 00 FB CALLS 0FB00:00H

2080 B0 11 MOVB AL,11H ;Output value

;to Port A

STEPPER MOTOR INTERFACE

19

2082 BA E0 FF MOVW DX,0FFE0H

2085 EE R1:OUTB DX,AL

2086 E8 1B 00 CALL DELAY ;Introduce

;delay

2089 D0 D8 RCRB AL,1 ;Rotate bits in

208B EB F8 JMP R1 ;data byte

;right & repeat

; Routine for Anti-clockwise rotation of motor

208D 9A 31 00 00 FB ANTI:CALLS 0FB00:0031H

2092 9A 00 00 00 FB CALLS 0FB00:00H

2097 B0 11 MOVB AL,11H ;Output value

;to Port A

2099 BA E0 FF MOVW DX,0FFE0H

209C EE R2:OUTB DX,AL

209D E8 05 00 CALL DELAY

20A0 D0 D0 RCLB AL,1 ;Rotate bits

20A2 EB F8 JMP R2 ;left & repeat

20A4 B9 00 08 DELAY:MOVW CX,800H ;Delay routine

20A7 E2 FE $ :LOOP $

20A9 C3 RET

5.12 DEMONSTRATION PROGRAM FOR ESA-51E

;Assume the interface is connected over J5 of the trainer.

;The trainer can be in KEYBOARD MODE or in SERIAL MODE.

;Press key "C" for clock wise rotation & "A" for anti-

;clockwise rotation

SEG EQU 0E8H

P2 EQU 0A0H

DPL EQU 82H

OUTPUT EQU 03FAH

GETCH EQU 12A5H

GETKB EQU 0142H

DSPCHR EQU 03DCH

STEPPER MOTOR INTERFACE

20

ADDRESS OPCODE LABLE MNEMONIC COMMENT

8000 ORG 8000H

8000 90 80 75 MOV DPTR,#MSG ;To display

8003 12 03 FA LCALL OUTPUT ;the message.

8006 90 E1 02 MOV DPTR,#E102H ;check for serial

8009 E0 MOVX A,@DPTR ;or keyboard mode

800A 20 E3 05 CHK: JB ACC.3,KBD

800D 12 12 A5 LCALL GETCH ;Get the key code

8010 80 03 SJMP L1

8012 12 01 42 KBD: LCALL GETKB ;Get the key code

8015 B4 41 05 L1: CJNE A,#41H,L2 ;Checking for 'A'

8018 12 03 DC LCALL DSPCHR ;Display character

801B 80 1B SJMP L3 ;Jump to routine

801D B4 61 05 L2 CJNE A,#61H,L4 ;Checking for 'a'

8020 12 03 DC LCALL DSPCHR ;Display character

8023 80 13 SJMP L3 ;Jump to routine

8025 B4 43 05 L4: CJNE A,#43H,L5 ;Checking for 'C'

8028 12 03 DC LCALL DSPCHR ;Display character

802B 80 22 SJMP L6 ;Jump to routine

802D B4 63 05 L5: CJNE A,#63H,L7 ;Checking for 'c'

8030 12 03 DC LCALL DSPCHR ;Display character

8033 80 1A SJMP L6 ;Jump to routine

8035 02 00 00 L7: LJMP 0

;Routine for clockwise rotation

8038 75 A0 E8 L3: MOV P2,#SEG ;Configure 8255

803B 78 03 MOV R0,#03H ;For all ports O/P

803D 74 80 MOV A,#80H

803F F2 MOVX @R0,A

8040 74 88 MOV A,#88H ;Initialise bit

;pattern. Bit PA0-

;PA3 used to

;control motor

8042 78 00 LOOP: MOV R0,#00H ;O/P the pattern

8044 F2 MOVX @R0,A ;to Port A

8045 C0 E0 PUSH A

8047 12 80 66 LCALL DELAY

804A D0 E0 POP A

804C 23 RL A

804D 80 F3 SJMP LOOP

;Routine for anticlockwise rotation

STEPPER MOTOR INTERFACE

21

804F 75 A0 E8 L6: MOV P2,#SEG

8052 78 03 MOV R0,#03H

8054 74 80 MOV A,#80H

8056 F2 MOVX @R0,A

8057 74 88 MOV A,#88H

8059 78 00 LOOP1: MOV R0,#00H

805B F2 MOVX @R0,A

805C C0 E0 PUSH A

805E 12 80 66 LCALL DELAY

8061 D0 E0 POP A

8063 03 RR A

8064 80 F3 SJMP LOOP1

8066 7A 03 DELAY: MOV R2,#03H ;Delay routine

8068 90 05 00 DELAY2: MOV DPTR,#500H

806B A3 DELAY1: INC DPTR

806C E5 82 MOV A,DPL

806E 45 82 ORL A,DPL

8070 70 F9 JNZ DELAY1

8072 DA F4 DJNZ R2,DELAY2

8074 22 RET

8075 45 4E 54 45 52 MSG: DB 'ENTER OPTION(A/C):',00H

807A 20 4F 50 54 49

807F 4F 4E 28 41 2F

8084 43 29 3A 00

5.13 DEMONSTRATION PROGRAM FOR ESA 86/88E TRAINER.

; Assume the interface is connected over J4 of the trainer.

; This program illustrates the control of direction of

; rotation of the Stepper motor depending upon user choice.

; The program executes in a continuous loop.

; The program can be executed in STAND-ALONE MODE or SERIAL

; MODE of operation.

; The program starts at memory location 0:2000H

; Please refer ESA 86/88E user's manual for mnemonic

; syntax suitable to trainer

Code Segment :0000H

ADDRESS OPCODE LABEL MNEMONIC COMMENTS

2000 B8 00 00 MOVW AX,0000H ;Initialise

;Segment

2003 8E C8 MOVW CS,AX ;Registers

STEPPER MOTOR INTERFACE

22

2005 8E C0 MOVW ES,AX

2007 BA E6 FF MOVW DX,0FFE6H ;Initialise

200A B0 80 MOVB AL,80H ;all 8255

;Ports as o/p

200C EE OUTB DX,AL

200D EB 47 JMP START

; Display Message String

200F 0A 0D 53 54 45 50 MES: DB 0AH,0DH,'STEPPER MOTOR I/F'

2015 50 45 52 20 4D 4F

201B 54 4F 52 20 49 2F

2021 46

2022 0A 0D 45 4E 54 45 DB 0AH,0DH,'ENTER DIRECTION'

2028 52 20 44 49 52 45

202E 43 54 49 4F 4E

2033 0A 0D 41 20 2D 20 DB 0AH,0DH,'A - ANTICLOCKWISE'

2039 41 4E 54 49 43 4C

203F 4F 43 4B 57 49 53

2045 45

2046 0A 0D 43 20 2D 20 DB 0AH,0DH,'C - CLOCKWISE',00H

204C 43 4C 4F 43 4B 57

2052 49 53 45 00

2056 9A 31 00 00 FB START:CALLS 0FB00:0031H;New line

;routine

205B 2E CS

205C 8D 16 10 20 LEA DX,@MES ;Display message

2060 8B C2 MOVW AX,DX ;on LCD or Console

2062 9A 13 00 00 FB CALLS 0FB00:0013H

2067 9A A9 00 00 FB GET:CALLS 0FB00:00A9H

;Wait for user entry

206C 3C 41 CMPB AL,41H ;If key ='A',

206E 74 1F JE ANTI ;rotate anti-

;clockwise

2070 3C 43 CMPB AL,43H ;If key = 'C'

2072 74 03 JE CLO ;rotate clockwise

2074 EB F1 JMP GET ;Accept valid

;key only

; Routine for Clockwise rotation of motor

2076 9A 31 00 00 FB CLO:CALLS 0FB00:0031H

207B 9A 00 00 00 FB CALLS 0FB00:00H

2080 B0 11 MOVB AL,11H ;Output value

2082 BA E0 FF MOVW DX,0FFE0H ;to Port A

2085 EE R1:OUTB DX,AL

2086 E8 1D 00 CALL DELAY ;Introduce delay

STEPPER MOTOR INTERFACE

23

2089 D0 D8 RCRB AL,1 ;Rotate bits in

208B EB F8 JMP R1 ;data byte

;right & repeat

; Routine for Anti-clockwise rotation of motor

208D 9A 31 00 00 FB ANTI:CALLS 0FB00:0031H

2092 9A 00 00 00 FB CALLS 0FB00:00H

2097 B0 11 MOVB AL,11H;Output value

;to Port A

2099 BA E0 FF MOVW DX,0FFE0H

209C EE R2:OUTB DX,AL

209D E8 05 00 CALL DELAY

20A0 D0 D0 RCLB AL,1 ;Rotate bits

20A2 E9 F7 FF JMP R2 ;left & repeat

20A4 B9 00 08 DELAY:MOVW CX,800H ;Delay routine

20A7 E2 FE $ :LOOP $

20A9 C3 RET

6.0 EXERCISES

The sample program presented in this manual demonstrated some specific applications of this

interface. A few exercises are presented below to enable the user to gain a better understanding of the

interface. Users are encouraged to visualize other applications and develop software accordingly.

Some of the suggested exercises are:

1) Write a program for the stepper motor for the 1800

rotation for full step sequence in

Clockwise direction.

2) Write a program for the stepper motor for the 2700

rotation for half step sequence in

Anti-Clockwise direction.

3) Write a program to run two motors, one in Clockwise direction and the other in Anti-

Clockwise direction

a) Simultaneously.

b) Alternatively.