You are on page 1of 30
User’s Manual STEPPER MOTOR STUDY Model: SM-03 Manufactured by: TECHNO INSTRUMENTS e 261/16, Civil Lines, Roorkee-247 667 Ph.: 01332-272852, Fax: 274831 ISO 9001 Email: techno@sestechno.com Sno FE CERTRED > Website: www.sestechno.com STEPPER MOTOR STUDY (Using TTL/Microprocessor based Controller) ECT = To conduct an experimental study of the operating characteristies of a small stepper and its controller. Further, to study the control of the motor through a microprocessor kit. ODUCTION Stepper motor is a direct digital actuator that has become extremely important in the years. It is simple in operation and is capable of accurate angular positioning in the n loop configuration, which depends only on the number of control pulses. With the id growth of digital electronics and finally the microprocessor, it is now a simple matter velop sophisticated stepper motor controllers for various applications. Present day ications of stepper motors include quartz analog watches, camera shutter and auto s control, numerical control machine tools, spray-painting machines, actuators for t joints and computer peripherals like printers, X-Y plotters, floppy disc R/W head tioning etc. they do have some The purpose of this tics of Despite such widespread application of stepper motors. jitations, especially with respect to load inertia and stepping rat eriment is to expose the students to the basic operational features and charact motors, without excessive emphasis on controller design, for advanced applications. addition, the students can develop and test assembly language programs for icroprocessor control of the motors. EQUIPMENT DESCRIPTION ) Main Unit : The main unit houses all the nec ‘y electronic circuits required for the nntrol of the stepper motor. A controller using TTL ICs provides the necessary pulse sequence 1 continuous rotation in both directions, as well as for single stepping. A variable frequency uare wave generator with frequency range of 10-400 Hz (approx.) in two ranges has been orporated in the unit for varying the speed of the motor. Individual driver stages for the four ses and an IC regulated power supply complete the unit. )) Motor Unit : The motor unit having transparent panels, houses the stepper motor and may connected to the main unit through a 9-pin connector in the motor section of the front panel (main unit). A 360° calibrated dial fixed on the shaft provides a visual indication of the shaft sition. A servopotentiometer is also mounted on the motor shaft, which is used for sensi shaft position as required in the dynamics study. Provisions have also been made for inertial and frictional loading of the motor. (c) uP Interface : A microprocessor interface has been designed and incorporated to provide the user with a facility to study the microprocessor control of stepper motor. Using an 8085 based kit and the interface, the movement of the motor can be programmed to generate any desired profile of motion. A description of the necessary hardware and software follows: TECHNO INSTRUMENTS An {SO 9001:2008 Company 261/16, Civil Lines, Roorkee ON Pht Pht sTePt Pra pne a Pha pha] ON Pra Pho sTe4 step Pht Pht oN [ena Pha ere Pha| Phe Pro Pho ON FIG.1. Basic steps in a stepper motor Phi Common FIG. 2. Biflar winding of phases dware : There is a 9-pin interface connector on the controller section of the panel of the in unit. Four lines of this connector are used to receive phase signals for the motor from /O (8255) of the kit. Another two lines are used to power the kit from the main unit. Details of these connections can be seen in Appendix-Il, An interconnecting cable with appropriate connectors is supplied with the kit. The user is simply required to plug the cable to the main it to allow the use of the kit and interface. A green LED glows to indicate automatic angeover of motor control to the microprocessor. ‘oftware : Once the kit is plugged to the main unit, the TTL pulse sequence generator los ntrol and the motor is governed by microprocessor. Programs written for motor control can be loaded in the RAM and executed from there. Every application requires its own program, owever, some utility programs have been developed by us which may be called as subroutines ‘by the user. All these subroutines are available on an EPROM 2764 fitted in an expansion slot of the kit, A memory map and source listing of these routines are given in Appendix-ll. s its 4, BACKGROUND SUMMARY Stepper motors are available in a variety of forms, which differ, in their working principles, structures and number of phases. These are described briefly without going into a detailed mathematical treatment, Interested reader may refer to the books mentioned at the end for more details. 4.1 Permanent Magnet Stepper Motor The basic principle of working of these motors is that a freely suspended magnet aligns itself with the external field. If the external field changes its direction the magnet gets aligned with the new direction. In this type of motor, the rotor is a radially magnetized permanent magnet and the stator consists of two windings (phase) at right angles. Rotor motion, as the two phases are switched ON and OFF in a sequence, is shown in Fig. 1, The basic step angle in this example is seen to be 90° since only one phase is ON at any given time. This is termed as mode- A operation. In actual practice, the reversal of field required above is obtained more conveniently by split or bifilar winding as shown in Fig. 2, rather than by a reversal of power supply polarity. The motor is then called a 4-phase permanent magnet stepper motor. If two phases are ON at any given time, referred to as mode-B operation, the rotor would execute the same basic step of 90° but lock in the direction of the resultant field. This mode requires more © power and develops larger holding torque. It is also possible to operate the motor alternately in mode-A and mode-B operation and thus produce 45° shaft movements per step. This is called mode-AB operation. To decrease the step angle further, the number of magnetic poles and stator teeth must be increased. This naturally has a limit and therefore permanent magnet stepper motors are not available in small step sizes. The main features of permanent magnet stepper motors are : § (a) Detent Torque : Due to the permanent magnetic field, the rotor locks in some fixed positions even without the motor being energised. Detent torque is the maximum torque that may be applied on the shaft under this condition without causing continuous rotation. Presence of detent torque helps in saving power when the motor is intermittently operated and is required to maintain its shaft position during the gaps when no power is applied. TECHNO INSTRUMENTS An ISO 9001:2008 Company 261/16, Civil Lines, Roorkee STEP 1 —> One tooth | ONS pitch 45° | N \ Ep STEP 3 a 8 |a' on FIG. 3. 4- Phase VR Motor of 15° step angle oN STEP 1 =_ or 4, One tooth pitch \ Go°(7 steps) STEPS ON FIG. 4. Increased resolution through tooth structure )) Good Damping : It is caused by the force of attraction between magnetic poles and stator |, and it inhibits prolonged oscillations about the final position. :) High Rotor Inertia : Since the rotor is required to be magnetic, having a field strength which governed by torque requirements, its size cannot be small. The rotor inertia is consequently Aarge, restricting its speed of response. (@) Performance variation due to aging : This is caused by reduction of the magnetic field “strength with time. 4.2 Variable Reluctance Stepper Motor This type of stepper motor consists of a cylindrical rotor with radially projected teeth and a wound stator, which usually has a different number of teeth. Coils are placed around the stator teeth. The rotor is made of soft iron and therefore has no residual magnetism and hence no detent torque. In the unenergised condition, the rotor may move freely. When one of the phases is energised, pairs of rotor tooth align themselves with this phase so as to minimise the “reluctance of the magnetic circuit. Subsequent switchings of the remaining phases move the rotor in steps. Commercial variable-reluctance motors are available with 3 and 4 phases having basic step angle of 15°. The switching sequence of a 4-phase motor of this type is shown in Fig. _ 3. The motor may be operated in mode A, B or AB, as explained earlier. One of the important features in the operation of a variable reluctance stepper motor is the relationship between the number of teeth in the rotor (N,), steps per rotation (S), and number of phases (m). In such a motor, the rotor moves by one tooth pitch after a cycle of excitation of all the m phases is over. With N, rotor teeth pitch to be moved for one revolution. the number of steps per revolution is given by S = mN,, covering an angle of 360°. The basic step angle may than be seen to be 0 = 360/S = 360/mN, degrees...(1) This may be easily verified in the motor described in Fig.3. An interesting application of Eq.(1) is that the basic step angle may be reduced by increasing the number of rotor teeth and as a consequence the number of stator teeth, without altering the number of phases. The situation is clearly brought out in Fig. 4, which is a modification of the motor of Fig. 3 by simply doubling the value of N,. It is seen that after four pulses the rotor now moves by 7.5° only, The cross sectional view of a 4-phase motor having N, = 50, S = 200 and 0, = 1.8° is shown in Fig. 5. The main features of variable-reluctance stepper motor are : (a) High torque to inertia ratio : Due to low inertia of the rotor, this results in a fast response. (b) Capability of high stepping rates + Due to small inertia of the rotor, it may be accelerated quickly and therefore the motor may not fall out of step even for hi stepping rates. (c) No detent torque : Hence position of the shaft cannot be ensured, if the motor power is 0 (d) Subject to resonance : Since the effective damping is rather small. TECHNO INSTRUMENTS An ISO 9001:2008 Company 261/16, Civil Lines, Roorkee FIG. 5. 4 - Phase motor with 1.8° step angle Stator —>| FIG. 6. Hybird motor construction Pole cap with teeth structure Motor shaft Permanent magnet Hybrid Stepper Motor The construction and features of these motors are a combination of permanent magnet variable reluctance type stepper motors. These motors therefore have detent torque, are ble of high stepping rates and high resolution or small step angle. The disadvantages lude somewhat large rotor inertia and problems of resonance at certain speeds. The truction of a hybrid motor is illustrated in Fig. 6. An axially mounted magnet produces a ly magnetic field between the stator and rotor teeth. Another set of magnetic fields is iuced when the phases are energised. Torque is created by the interaction of these fields, the rotor aligns itself to specified position. For details of the constructional features like winding arrangement, deliberate mis- ent of the teeth structure, and for an explanation of the process of torque generation, the may consult the suggested reference books. The motor supplied with this unit is a hybrid stepper motor having the following teristics as per the manufacturer’s literature: © Step angle 1.8° + 5%, non-cumulative Steps per revolution200 Rotor Inertia0.1 Kg-em? Detent Torque0.3 Kg-em Holding Torque2.0 Kg-cm in Mode-A 2.8 Kg-cm in Mode-B Operating Voltage 12 volt DC * Current per phase0.5 amp. river System for Stepper Motors ‘As discussed earlier, there are three modes viz. A, B and AB in which a stepper motor be operated. Mode-B has been chosen in the present experiment because of its simplicity high torque. Further the basic step angle of 1,8° produced in this mode is adequate for the imental work. Fig. 7 shows the scheme adopted for the driver system. The pulse sequence a sequence of pulses for the four phases as shown in Table I. LET , Civil Lines, Roorkee Step Phase? | Phase3 | Phase2 | Phase oe 1 0 1 0 1 Motion 2 1 0 0 1 3 1 0 I 0 4 0 1 | 4 o | 5 0 1 oO ) Clockwise Motion INO INSTRUMENTS An ISO 9001:2008 Company weiBeip ojewayos soa Z ‘O14 —Df¥ Kt ib ayaa vt See, nC ZHOOP-OL ? Se -- 4028111980 anem ‘bs| see = 33 8 Bg pf¥—kt s& 3 ¢ atom 32 asa ae a8 = & Joyes0U0B $ ce} asind aj6uig 7 Df FS The clock frequency is adjustable in the range 10-400 Hz (approx.) and is used for a vatiable speed drive in either direction. Provisions are also there for ‘manual’ stepping through push button, and for the ‘wobble’ state in which the shaft executes one step alternately in the clockwise and counterclockwise directions. The phase windings of the stepper motor usually have a large L/R ratio. The motor current therefore cannot be switched ON and OFF instantaneously. Also for higher stepping rates, the current may not rise to the rated value and thus the torque generated may be too small. Further, transient voltage developed during switch OFF may damage the driver circuit. Various techniques have been used to solve these problems and force a current step to the phase winding. In the present unit, a constant current source with zener diode transient suppressor has been incorporated which is found to be satisfactory. 4.5 Dynamic Response In the ideal case, a stepper motor executes one basic step angle for each input pulse. However due to the low damping factor inherent in the system, the response is somewhat oscillatory. The nature of this damped oscillation further depends on a number of factors like motor load, driving circuit and mode of operation. For a motor without external loading and operating from a perfect constant-current source in mode-A, the transfer function may be represented in the standard second order form as om a) 8? 4260,8 +0," A measurement of the peak overshoot and peak-time may be used to calculate the settling time and thus evaluate the dynamic response under this condition. If the motor is operated in mode-B a larger amount of damping is involved and the oscillations die out quickly. This is because torque generated by oscillating components of the currents in the two phases oppose each other. The transfer function in this case is of third order with a small value of settling time. In the above it is assumed that the motion is essentially caused by single step i.e. after every applied step the shaft comes to rest at the new position before the next pulse-is applied. Necessary feature of this operation is that the loaded motor can start or stop without losing step. The maximum rate upto which this is possible is called the pull-in rate, If the stepping rate is increased beyond pull-in rate, the motor does not stop at every step but may be still maintain synchronism. In this range of operation the motor will not stop instantaneously when the input pulses are discontinued. This is known as the s/ew range. If the stepping rate is increased still further synchronism is lost at pull-our rate. These ranges of operation are illustrated in Fig. 8 Fig. 9 shows the general nature of the torque-speed curves of a typical stepper motor, the characteristics, however, depend on a large number of factors external to the motor. 5. EXPERIMENTAL WORK The present experiment attempts to expose the students to the basic operating principles, and characteristics of a hybrid motor. Following laboratory work is suggested. Unless mentioned specifically, no inertial or frictional loading should be applied to the motor. TECHNO INSTRUMENTS An ISO 9001:2000 Company 261/16, Civil Lines, Roorkee Angular position Single step region Slew region Time Pulses Time FIG. 8 Dynamic response for different stepping rates Max. pull-in rate (X,) Max. pull-ouy rate (X,) 2 $ g 6 e Stepping rate ———> FIG. 9 Torque speed characteristics Basic Step Angle Measurement « Keep switch $; to manual stepping (Fig. 7). © Select clockwise (CW) rotation. © Connect all phases to the corresponding drives. «Press the manual stepping push-button in multiples of 10 pulses and note the change in angular position from the dial. Observe the pulse sequence also and match it with that in table I. Calculate the average basic step angle. ‘© Repeat the above steps selecting counter-clockwise (CCW) rotation. .2 Speed and Direction Control © Keep switch S, to free run position. © Set the pulse frequency to about 10 Hz, and measure its value accurately with a CRO. Connect all phases to the corresponding driver. © The motor starts rotating in the selected direction (CW or CCW). Measure the shaft rotation speed with a stop watch and record it. Calculate steps per revolution. * Repeat the above steps at other frequencies and find an average value of steps per revolution. © Repeat above with the direction of rotation reversed. With the motor running at a high speed, observe on the CRO and trace the waveforms of all phases. To ensure proper timing relationship, use TRIG signal for external triggering. Change the direction of rotation and repeat. © Observe and record the maximum speed upto which the direction of rotation of the motor can be switched between CW and CCW with success. 5.3 Low Frequency Resonance (a) Motor without load Conduct this part near the lowest frequency to avoid excessive vibrations, Keep the friction close to minimum so as to cause very small frictional loading. * Keep switch $; to ‘wobble’ position. (Fig. 7) * Connect phase 2 to driver | and phase 4 to driver 4 © Connect the CRO (¥ channel) through the terminals provided on the panel, External triggering with TRIG signal will be found to be very convenient for proper viewing. «The motor now wobbles in mode-A and its dynamic response is displayed on the CRO screen. Verify the mode by single stepping. Trace the figure on a tracing paper and from it calculate Mp, 8, tp, t, and t, (for + 5% tolerance band) see Ref.[3]. Calculate fins from above assuming that the motor must come to rest after each pulse. ~ TECHNO INSTRUMENTS An ISO 9001:2000 Company 261/16, Civil Lines, Roorkee © Connect all phases to corresponding drivers. The motor now wobbles in mode-B. Repeat the preceding step and compare the results. ¢ Connect Phase 1 to driver 1 and Phase 4 to driver 4. The motor now wobbles in mode-AB. Verify by single stepping. Repeat the preceding steps and compare the results. (b) Loaded Motor The general effect of applying inertial load to the motor is to delay the settling of the transient response and to cause an increase in overshoot. This effect may be seen by loading the motor with different inertial disks provided for the purpose and observing the motor response in wobble mode. * Keep switch S; to ‘wobble’ position. © Connect phase 2 to driver | and phase 4 to driver 4. * Connect the CRO (Y channel) through the terminals provided on the panel. External triggering with TRIG signal will be found to be very convenient for proper viewing. ¢ Introduce frictional loading by turning the friction screw (on top of the motor unit) clockwise. Adjust the amount of frictional loading so as to result ina slightly under damped response (2 or 3 peaks noticable). * Mount an inertial disk on the motor shaft and record the change in response (Mp. ty). © — Repeat the above steps for different disks (or combinations) and tabulate the results | 5.4 Microprocessor Control In this part of the experimental work, the aim is to program the stepper motor motion according to a requirement using the microprocessor interface. © Connect the interface cable to the main unit and switch ON power. A green LED on the panel will glow indicating motor under microprocessor control. Display on the kit will show the usual *- UP85’ sign. Reset the kit if nece: « — Connect all phases to the corresponding drivers. None of the active-phase-indicator- LED’s would be glowing. « Before executing any application program, the system needs to be initialised. To do : that, run the INITIALISE program available at 4000h by following this key pressing sequence: Key Display GO. Xxxxxx 4000... 4000 sow E TECHNO INSTRUMENTS An ISO 9001:2008 Company 261/16, Civil Lines, Roorkee At this stage, two phase will become active and the motor will align itself to the corresponding position. ‘As the INITIALISE program is running, use the hex keys C (for clockwise) and D (for anticlockwise) to adjust the motor to a convenient scale position. Afier this adjustment, terminate the program by pressing the hex key E. The system will return to monitor. Do not press RESET now otherwise initialisation done will be lost. The above steps are common to any program testing. Now load the application program in RAM starting at address 2000h (two sample programs are given here). Execute the loaded program using the GO command. It may become necessary to run the INITIALISE program again if during the loading of application program the RESET key had to be pressed (refer to up kit manual for program loading procedure). iple Program I Aim : To rotate the motor by 1.5 revolution in clockwise direction at 30 rpm. Code Label Mnemonic Comments 31FF212 LXI SP, 21FFH ;stack initialisation OE01 MVIC,O1 sone revolution 1600 MVID,00 sclockwise direction 1EIE MVIE,IE :30rpm speed CD 4040 CALL FREERUNI8. stake one revolution 01B400 LXI B,00B4 :180° for ¥% revolution more CDF040 CALL ANGLERUNI8 _ :rotate by 180° EF RST 5S return to monitor E Note the angular position after executing this program and check that the motor made 1.5 revolution in clockwise direction from the starting position. - Sample Program II Aim : To program the motor for making 10 cycles of to and fro motion with a span of 36° and a time period of 1 second Address Code Label Mnemonic Comments 2000 31FF21 LXI SP, 21FFH :stack initialisation 2003 012400 LXI B,0024H :36° span. 2006 1600 MYID,00 :start clockwise 2008 1E18 MVIE,18 :speed for 1 sec period TECHNO INSTRUMENTS An ISO 9001:2008 Company 261/16, Civil Lines, Roorkee 200A 2E0A MVIL,OA scounter for 10 cycles 200C CDF040 CYCLE: — CALL ANGLERUNI8 200F 16FF MVID, sreverse direction 2011 CDF040 CALL ANGLERUNI8. 2014 1600 MVID,00 sreverse direction 2016 2D DCRL ;decrement cycle count 2017 €20C20 JNZ CYCLE sif over 201A EF RSTS sreturn to monitor In addition to the above programs, the students may develop software for more complex movements of the motor. In particular, programs may be developed for half-stepping (0.9°) operation on lines similar to utility programs given in Appendix-III, The necessary phase sequence for half-stepping is available in ROM location 4150-4157 as CODE9. Another program of practical significance is to gradually speed up the motor from rest to a speed beyond the ‘single stepping region’ into the ‘slew region’ and run at a constant speed there. Note that the motor cannot be directly switched on at this speed. 6. TYPICAL RESULTS (a) it) (©) Low frequency dynamic response : From the waveform in the ‘wobble’ condition in mode- M,= 66%; = 0.131 tp = 7 msec.; t; (from measurements) = 30 msec. approx. Step angle : 1.8° per step Steps per revolution : 200 A Max. single stepping rate = 33 Hz ince these depend heavily on external ittached., The above figures are for general information only load conditions like friction screw setting and inertia dis (a) Resonance and instability : These occur in stepper motors at certain stepping speeds which disturb the normal operation of the motor. Low frequency resonance occurs at the natural resonance frequency and its subharmonics. In the present unit, a strong resonance effec may be observed around 90 Hz. In most practical applications, however, these resonane do not restrict the performance of the stepping motor since the motor and load can be instantaneously started and stopped at stepping rates well above the natural frequency 7, REFERENCES [1] ‘Stepping Motors and their Microprocessor Controls’, Takashi Kenjo, Clarendon Press. Oxford, 1984. [2] “Theory and Applications of Step Motors’ B.C. Kuo, West Pub, Co. astern Limited, 1988. [3] ‘Digital Control Engineering’, M. Gopal, Wile} TECHNO INSTRUMENTS An ISO 9001;2008 Company 261/16, Civil Lines, Roorkee APPENDIX - 1 f 5 Large Friction. fata t + Bn oe y [TDSZ10}.CHt mv 50m DYNAMIC RESPONSE FOR VARYING FRICTION (Tektronics, TDS-210 Storage CRO Traces) ‘TECHNO INSTRUMENTS ‘An ISO 9001:2008 Company ‘261/16, Civil Lines, Roorkee APPENDIX - Il CONNECTION DIAGRAM OF THE uP KIT (a) For kit supplied by us 9 Pin connector (male) 8085 kit with utility software Connecting cable provided with the unit {a) For user's kit 9 Pin connector (male) Owner's _ Gnd ‘own an 8085 Kit ——-—2l}, 4 aaa ° ee Lo Orange Bt Ground and four port lines to be connected by the user POWER SUPPLY HNO INSTRUMENTS ‘An ISO 9001:2008 Company 1/16, Civil Lines, Roorkee Memory Map and Software Listing : (The details given below concer the step} Other details about the kit are contained in the manufacturer's operating control programs only. manual.) Memory Map ROM 4000-5FFF | 4000-31 4040-68 4070-86 4090-98 40A0-D5 40E0-EF 40F0-4104 4110-4132 4140-43 4150-57 4160-79 4180-99 41A0-C2 RAM 2000-3FFF 2000- 2700-03 21FF 10 Map 8255 00-03 HNO INSTRUMENTS 116, Civil Lines, Roorkee APPENDIX - Ill per motor Total Area (8K) INITIALISE FREERUNI8 DIVIDE DLY PHASE18 MULTS ANGLERUNI8 STEPRUNI8 CODE18 CODE9 CW_STEP cCW_STEP Sample Programs Total Area (8K) User Programs RAM locations used by the Subroutines Stack base Port A Port B Port C Command/Status register ‘An ISO 9001:2008 Company urce program for stepper motor study using Vinytics Kit 8501 21FF STACK EQU 21FFh 0080 CWORD EQU 80h 0003 CREG EQU 03 0000 PORTA EQU 00 0005 START EQU 05 2700 SAVE EQU 2700h 0629 RDKBD EQU 0629h 93A8 DEL_CONS EQU 93A8h gram INITIALISE en power is switched on, the motor could be in any position and its corresponding phase is known. This program aligns the motor to a known starting phase and initialises an index ariable (at SAVE + 3) to its position in an array of phase codes. This information is used by -positioning procedures (CW_STEP and CCW_STEP) to put the motor in any desired ition. The program must be run before executing any application program. ;CALLS ; CW_STEP, CCW_STEP. ss Code Label Mnemonic Comments 31FF21 LXI SP.21FF sinitialise stack pointer 3E80 MVIA.CWORD define port A as output D303 OUT CREG 3E05 MVIASTART cload starting phase D300 OUT PORTA zalign motor to it. 210327 LXIH,SAVE+3 spoint to indexing variable 3600 MVIM,00 sinitialise index to 0 3E08 MVIA.08 cunmask RST 5.5 30 SIM :so as to read keyboard CD2906 SCAN: — CALL RDKBD sread keyboard FEOC cPloc Sif C is not pressed 22140 JNZ CCW go to check for CCW cD6041 CALL CW_STEP —_:otherwise make a CW step 31340 JMP SCAN sand scan keyboard again FEOD ccw: — CPIOD sif D is not pressed {0 INSTRUMENTS An ISO 9001:2008 Company Civil Lines, Roorkee 4023 €22C40 4026 CD8041 4029 31340 402C FEOE FIN 402E 21340 4031 EF jprocedure FREERUNI8 JNZ FIN CALL CCW_STEP JMP SCAN CPIOE JINZ SCAN RST 5S INPUTS: — C register — no. of revolutions D register — direction ;CALLS, DIVIDE, PHASE18, DLY, Address Code Label 4040 cS 4041 DS 4042 ES 4043 3E80 4045 D303 4047 210027 404A, 73 4043, 23 404C 71 404D 23 404E 72 404F 21A893 4052 CD7040 4055 06C8 RUN: 4057 CDA040, STEP: A0SA CD9040 05D 05 TECHNO INSTRUMENTS 1/16, Civil Lines, Roorkee Mnemonic PUSH B PUSH D. PUSH H MVIA, CWORD OUT CREG LXI H, SAVE MOV ME INXH MOV M,C INXH MOV M,D LXTH,93A8 CALL DIVIDE MVIB,C8 CALL PHASE18 CALL DLY DCRB go to check for finish sotherwise make a CCW step sand scan keyboard again sif E is not pressed :go to scan keyboard again :otherwise return monitor The procedure allows a complete number of revolutions from the current position in the given sdirection at a given speed in steps of 1.8° each (00 for CW, FF for CCW) E register — speed in rpm (1-255) Comments sdefine port a as output :HL points to save area (RAM) ssave speed sdirection and no. of srevolutions in RAM for future sreference :93A8H divided by speed gives scount for delay routine ;set counter for 200 steps smove by one step ;wait for next ;decrease step counter ‘An 1$0 9001:2008 Company 405E 25740 JINZ STEP 4061 0D DCRC sdecrease revolution counter 4062 25540 JNZ RUN 4065 El POP H 4066 DI POP D 4067 cl POPB 4068 co RET procedure DIVIDE st divides a 16-bit unsigned number by a 8-bit unsigned number and returns quotient. The squotient is used by DLY routine to produce a delay between steps corresponding to the stequired speed. The calculation is based on the assumption of 3 MHz system clock rate. SINPUT: HL pair — 16 bit numerator ; E register ~ 8 bit denominator ; OUTPUT DE pair — 16 bit quotient Address Code Label Mnemonic Comments 4070 cs DIVIDE: PUSHB 4071 4B MOV CE 072 110000 LXID,0000 ;clear space for quotient 075 0600 MVIB, 00 7 7D DIV: MOV AL 78 91 SUB C sHL points to save area (RAM) 79 OF MOV L,A ssave speed ° A 7c MOV AH direction and no. of 7B 98 SBBB revolutions in RAM for future 7c 67 MOV HA sreference 7D DA8540 JC DONE 180 AF XRA A :938H divided by speed gives 81 13 INXD scount for delay routine 82 37740 DONE: — JMP DIV :set counter for 200 steps 85 cl POP B smove by one step 6 co RET wait for next ;CHNO INSTRUMENTS An ISO 9001:2008 Company 1/16, Civil Lines, Roorkee sprocedure DLY iThe procedure is used to produces a delay between steps corresponding to the required speed. 33 MHz clock rate is assumed. sINPUT: DE pair ~ delay count lddress — Code Label Mnemonic Comments 090 DS DLY: PUSH D ssave delay count 4091 1B LOOP: DCX D 2 7B MOV AE 193 B2 ORA D 4 €29140 JNZ LOOP 7 DI POP D co RET rocedure PHASE18 {The procedure provides one step movement of the motor from current position. The step size is .8. Direction for movement is picked up from a location in RAM. INPUT: RAM location SAVE#2 — direction RAM location SAVE+3 ~ index value for current position ress Code Label cs PHASEI8: DS ES 210227 TE 3C CACI40 23 34 3E04 BE CACC40 4E MOVE: HNO INSTRUMENTS. V/16, Civil Lines, Roorkee Mnemonic PUSH B PUSH D. PUSH H LXI H.SAVE+2 MOV A.M INRA IZMCCW INXH INRM MVIA,04 CMP M JZ CWRSET MOV CM Comments sHL points to save area sget direction information scheck it and jump accordingly sHL points to index variable sincrement current index scheck if index outside array sjump to reset index if so else prepare to move one step An ISO 9001:2008 Company 214041 LXIH, CODE18 spoint to start of code array 0600 MVIB,00 09 DADB HL points to next code 7E MOV A.M sget it and D300 OUT PORTA output on port A El POP H DI PoP D cl POP B co RET 2B Mccw: — INXH sHL points to index 3E00 MVIA,00 BE CMP M CAD140 JZ CCWRSET 35 DCR M 38340 JMP MOVE 3600 CWRSET: MVIM,00 sset index to start of array 38340 JMP MOVE 3603 CCWRSET: MVIM,03 ; set index to end of array 38340 JMP MOVE edure MULTS tiplies a given unsigned 16-bit number by 5. The procedure is useful in finding the number ps for a given angle --a process which involves dividing the angle by 1.8 SINPUT: HL pair ~ 16 bit number OUTPUT HL pair ~ the 16 bit result of multiplying by 5 ress; Code Label Mnemonic Comments Ds MULTS: PUSH D C3 PUSH B EB XCHG 0E05 MVIC, 05 210000 LXT H,0000 19 AGAIN: DADD HNO INSTRUMENTS An ISO 9001:2008 Company 116, Civil Lines, Roorkee 0D DCRC C2E840 JNZ AGAIN ED cl POPB WEE DI POP D IEF co RET rocedure ANGLERUNI18 is used to make the motor rotate by a given angle in the given direction and at a given speed. e step size is 1.8°. INPUTS: BC pair — angle in degrees (0-360) D register ~ direction (00 for CW, FF for CCW) E register — speed in rpm (1-255) ;CALLS: MULTS, DIVIDE, STEPRUNI8 Code Label Mnemonic Comments cs ANGELRUNI8: PUSH B ES PUSH H Ds PUSH D :save direction and speed 69 »MOV LC 60 MOV HB sput angle in HL CDE040 CALL MULTS multiply by 5 1E09 MVIE,09 :prepare for divide by 9 p7040 CALL DIVIDE divide 4B MOV CE :put no. of steps in C DI POP D get direction and speed CD1041 CALL STEPRUNI8 El POP H cl POP B ae RET INSTRUMENTS An ISO 9001:2008 Company il Lines, Roorkee sprocedure STEPRUNI8 :The procedure allows a given number of steps from the current position in the given direction sand at a given speed, in steps of 1.8° each SINPUT: —C register ~ no. of steps (0-255) ; D register — direction (00 for CW, FF for CCW), 5 E register — speed in rpm (1-255) sCALLS: DIVIDE, PHASE18, DLY Address Code Label Mnemonic Comments ail0y = (C5 STEPRUNI8: PUSH B 4lll Ds PUSH D 4112 ES PUSH H 4113 3E80 MVIA,CWORD define port A as output 4115 D303 OUT CREG 4117210027 LXIH, SAVE SHL points to save area ait 2 73) MOV ME save speed, MIB 3 INXH :direction and no. of 4c 71 - MOVMC ;steps in RAM for future 4D 23 INXH sreference 4uE 72 MOV MD 4IIF 214893 LXIH,DEL_CONS _ divide del_cons by speed 4122. CD7040 CALL DIVIDE decide count for delay 4125. CDA040.—- MSTEP: CALL PHASEI8 move by one step 4128 cD9040 CALL DLY delay the next 4128 0D DCRC decrease step counter 412C 22541 JNZ MSTEP smove a step if not over 412F EI POP H 4130 DI POP D aisle | (cl POP B 41329 RET 4140 05090A06 CODEI8& DB OSH,O9H,0OAH.06H 4150 05010908 +CODE9 DB 05H,01H,09H,08H,0AH,02H.06H.04H 04020604 TECHNO INSTRUMENTS An ISO 9001:2008 Company 261/16, Civil Lines, Roorkee ;procedure CW_STEP :This procedure makes the motor rotate one step in clockwise direction from the current :position. It is called by the program INIT whenever user presses the hex key C in that program. :Each depression of the key rotates the motor by one step. Address Code Label Mnemonic Comments 4160 210327» CW_STEP: ~— LXIH,SAVE+3 HL points to index variable 416334 INRM sinerement current index 4164 3E04 MVIA.04 4166 BE CMP M scheck if index outside array 4167 CA7441 JZ FIRST sif so go to begin of array 416A TE MOV A.M sget index 416B 214041. «= CWSTEP: == LXIH,CODEI8.—_—_:HL. points to start of array 416E 85 ADDL sadd index to array address 4160F OF MOV L,A ‘HL points to required code 4170 7E MOV A.M :get the code and 4171 D300. + OUT PORTA output it on port A Oley = RET 4174-3600 FIRST: MVIM,00 sreset index to start of array 4176 7E MOV A.M :get starting code and 4177 C36B41 JMP CWSTEP jump to output it sprocedure CCW_STEP :This procedure makes the motor rotate one step in anti-clockwise direction from the current :position. It is called by the program INIT whenever user presses the hex key D in that program ;Each depression of the key rotates the motor by one step. Address Code Label Mnemonic Comments 4180 210327.» CCW_STEP: LXIHSAVE#3. ——:HL points to index variable 4183 300 MVIA,00 4185 BE CMP M check if index=0 4186 CA9441 JZLASI sif'so go to set to end of array 418935 DCR M selse decrement index 4184 7E MOV A.M sget index TECHNO INSTRUMENTS An ISO 9001:2008 Company 261/16, Civil Lines, Roorkee 418B 214041 CCWSTEP: 418E 85 418F 6F 4190 TE 4191 D300 4193 co 4194 3603 LAST: 4196 TE 4197 C38B41 TECHNO INSTRUMENTS 261/16, Civil Lines, Roorkee LXIH,CODE18 ADDL MOV L.A MOV AM OUT PORTA RET MVIM,03 MOV AM JMP CWSTEP END sHL points to start of array ;add index to array address :HL points to required code sget the code and soutput it on port A ;set index to end of array :get ending code and ;jump to output the end code An ISO 9001:2008 Company SNIMVYC TANVd 5 = 22v0ed 'SLNFWNYLSNI onnoa Tt Ny | © 6 -—@—© » 6) bay ©—O© « soeyaqul grt Jenug somo souanbag asing A © oY © tL-©—© «© ©] weiousg /-—-©—®© oF aiagonn uny aaly @—© - aseug dais abu £0-WS I9POW “ACN.LS YOLOW YAdda1S moo © mo sewoou ‘SINJMNULSNI ONHOIL. old 3 ok ° Toss vB TT aT 2 s woion GE iS wh aus O29 & | O—Q = QJ wvsiniet | sara J T | 4 wsmoa [7—O—Q § 9 wo.vwanao | O Q19 ‘3SN3ND3S asia 3evia ; T300W ” Smo dais 6 co-Ws : NOLOWNAddzIs =O SHONIS (aG0W Nn 3344) €0-WS ‘19POW ‘YOLOW Ydddals WVYSVIG NOILIANNOD soveou sinannuism onvoat i} 108s Ss 7 aS o 8 a | woiow Ga) sus a | rw O—Q 2: 9— BOVANaLNI dt | | uaaria = 4 € a amod Ce yoLveana9 | ona -O Q 19 3SN3ND3S asind aSvHd eee eee) » mo das | @ co-ws : FOO" NOLO YaddaLS — 99 sons (aqow 31880M) €0-WS ‘1@POW ‘YOLOW YaddaLs WVUDVIG NOILDSNNOD

You might also like