Home

USING A ZILOG MCU

image

Contents

1. Figure 3 LMD18200 Functional Diagram AN006001 Z8X0400 2000 ZILOG INC 5 A DC Motor Controller Using A ZiLOG MCU lt De Output pins POO P01 and P02 of the MCU provide the direction brake and PWM signals to the LMD18200 refer to the Z86E04 schematic diagram in the Appendix A resistor from Pin 8 of the LMD18200 to ground provides the current sensing circuit utilized by the Z8 s comparator The current output from the current sensing pin is typically 377 mA A If the motor is rated at 1A a resistor value is chosen so that the voltage developed across the resistor does not exceed 3 3V the reference pin for the comparators P33 is biased at 3 3 V through a voltage divider The resister value works out to be 3 3V 377mA 8 8KQ For the circuit in this Application Note the motor is rated at 12V 1 6A The resistor value works out to be 3 3V 377mA x 1 6A 5 5KQ Any significant load on the motor increases the motor current thereby increasing the voltage across the current sensing resistor If the voltage across the sensing resistor exceeds 3 3V a comparator interrupt is generated and the BRAKE line to the LMD18200 is activated stopping the motor When the load condition of the motor is removed pressing the START STOP push button reactivates the motor The temperature flag Pin 9 of the LMD18200 is connected to P31 of the Z8 the other comparator The temperature pin is an open collector output so the circui
2. AN006001 Z8X0400 2000 ZILOG INC 3 A DC Motor Controller Using A ZiLOG MCU lt Se Q1 Q2 Mere MOSFET DC Motor O4 MOSFET Q3 MOSFET Figure 1 H Pattern Motor Driver Configuration DISCUSSION Theory of Operation Hardware Description The heart of the motor controller is the ZiLOG Z86E0408PSC an 18 pin one time programmable OTP MCU The Z86E04 features 1KB of ROM 128 Bytes of RAM 14 I O lines two timers counters and two on board comparators A block diagram of the chip is illustrated in Figure 2 An 8 MHz crystal clocks the Z8 MCU but designs using an RC LC or ceramic resonator are possible depending upon the requirement for precision timing The National Semiconductor LMD 18200 controls the motor The LMD 18200 is a 3A H bridge driver IC with direction and braking logic in addition the device features current and temperature sensing output drivers The block diagram for the LMD 18200 is illustrated in Figure 3 AN006001 Z8X0400 2000 ZILOG INC 4 A DC Motor Controller Using A ZiLOG MCU E Input Vec GND Machine Timing amp Inst Control WDT POR Register Pointer E Registers 128 x 8 Input Output Input Output Figure 2 Z86E04 Block Diagram Thermal Flag Output 1 Bootstrap 1 Vss Output 2 Bootstrap 2 Output Thermal Sensing Under Voltage Lockout Current Sense Current Sense Direction 3 e Brake 4 PWM 5 e Ground
3. Application Note A DC MOTOR CONTROLLER UsING A ZILOG MCU AN006001 Z8X0400 2000 ZILOG INC 1 A DC Motor Controller Using A ZiLOG MCU S TABLE OF CONTENTS Abstract nitent eS en a ae oe eee 3 General Overview eese eene nnn nennen nennen nan nnns 3 BIG e EE A Zeen 4 Software Description 6 Remote Control eese nnne nnne nnn rne nnne rares 7 Results of Operation saiia aea e paa a a EEE aa Ea a Spaa Nap aeres 7 SUMM A PEE 7 Reaffirmation of Results 7 Technical SUpPOTL qa 8 Source Codes EE 8 Flow Chart osani A ins nn 16 Technical Drawings ii ii ri eee eee eee nenene nenene 19 Test Procedure EE 19 General Test Setup and Execution sse 19 References iiie dei nec heilen e ede tace did ceva idvisadavetocss 20 AD DONG IX tes veri I eer 21 Schematics eseseeseeeeeee nennen nnne nene nnns nene annie nnns 21 NOTOS SR LUUD LIII eegen 22 Information IDEO nn cec Inda eaten way cod ie 22 Document Disclaimer cccecccecececeeececeeeeeceeeeeeeeeeeeeueeeueeeneeeuenenenenees 22 Acknowledgments Project Lead Engineer Jim Gersbacher Application and Support Engineer Bob Bongiorno Mark Thissen System and Code Development Jim Gersbacher AN006001 Z8X0400 2000 ZILOG INC A DC Motor Controller Using A ZiLOG MCU lt De ABSTRACT General Overview Introduction Many applications such as printers ATM machines
4. 0A PWM pulse width of 50 and single pass ld T1 PWM Reg ld IPR 18 Priority overcurrent err gt overtemperatur err gt TO end ld TMR 203 load and go for TO When motor must run TO starts T1 ld Key temp reg 4 FF no keys are stored ld State_Reg stopped_state ld delay_reg 3 allow motor current and speed to reach steady state subtitle Main routine page pRRRER ER EKER EK Main KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK ko ko ko kokockockokok ei main_loop Wait for interrupts jr main_loop PRR RR RRR RRR KKK KKK KR KKK KEK KR RK KR KKK KKK KK KK KKK KEK KKK KR KKK KER KKK KK KKK RRR KKK KKK EE KA KEK KEK kk Application Motor Controller AN006001 Z8X0400 2000 ZILOG INC 10 A DC Motor Controller Using A ZiLOG MCU Date August 07 1999 Created by J D Gersbacher for Motor Controller Application Note Description Sample ISR is the main portion of the software It handles three items direction test state operation and push button check The motor operation is based on a state machine There are thr states in the state machine STOPPED STARTUP and RUNNING In the STOPPED state the motor is off brake is set and the STOPPED LED is lit All other LEDs are off The STOPPED state is the only state the direction switch is active The start stop push button transitions to the STARTUP state In the STARTUP state after the de
5. LED is turned off and the appropriate When Timer 1 exits out of initialization the time is set for 250 microseconds direction LED is lit The linker settings must be set accordingly To setup the linker options correctly in ZDS version 2 12 EK PROJECT SETTINGS LINKER KE RANGES NEW then add it takes 3 entries to enter all information below ee regfile 0010h to 001fh o regfile Motor 0020n to 002fh o regfile sample ISR 0030h to 003fh KKK KKK ck ck ck ck ck ck KK KKK KKK ck kk KKK KK KKK KKK ck ck KKK KKK A AAA KA KKK KKK ko ck ck ko ck ck kk ko kk ck kk KKK KK KKK ko ko subtitle Motor Controller include motorhead inc globals pk e ke ke e e ke ke ke e x Interrupt Vectors RK RK KK KK kk kk kck ck kc kk EEK EEK ck ckck X k ck ck XX vector irq0 overtemperature_ISR vector irgl1 IRQl vector irq2 overcurrent ISR vector irq3 IRQ3 vector irg4 sample ISR vector irq5 pwmlow ISR pK CK ek ke ek d ke e x Global Variables RRR KKK kk kk k kk kk KE EEK KKK ckckck kk ko segment regfile set in linker to start at 10 public State Reg PWM Reg Key temp reg State Regds 1 define regfile_Motor space RFILE segment regfile_Motor set in linker to start at 20 oo H PWM_Reg ds Key_temp_regds 1 subtitle Global Functions page pk ek ee ke denke ke ke x Global Functions N N XX X X kk kk kk EEK k ck ck ckckckck ck ck ck
6. equ 01 running_state equ 02 motor_stop equ 07 PWM_Half_value equ 80 tmr0_value equ 250 tmr0_irq equ 04 OCE equ 04 OverCurrent Enable OTE equ 08 OverTemperature Enable falling edge OE equ 10 Timer 0 Enable 1E equ 20 Timer 1 Enable Flow Chart Initialization 1 Set PWM for 50 2 Set Brake bit 3 Turn on STOP LED 4 Load and enables timers 5 Setup and enable interrupts Main 1 Loop 2 Wait for interrupts Figure 4 Main Routine AN006001 Z8X0400 2000 ZILOG INC 16 A DC Motor Controller Using A ZiLOG MCU Other Buttons Decrease Button No No Brake Button 1 Toggle Brake Bit 2 Toggle Stop LED Debounce Count reached No Save Button Status 1 Decrement PWM 2 Load T1 with PWM count Figure 5 TO Interrupt Other Button Routine AN006001 Z8X0400 2000 ZILOG INC 17 A DC Motor Controller Using A ZiLOG MCU TO Interrupt 1 Set P02 High 2 Reload and enable controls Any buttons pressed Debounce count Save button reached status Other buttons 1 Increment PWM count 2 Load T1 Figure 6 TO Interrupt AN006001 Z8X0400 2000 ZILOG INC A DC Motor Controller Using A ZiLOG MCU a 2 Over Temperature Over Current Interrupt Routine Set Brake Bit Interrupt Return Figure 7 Error Routine TECHNICAL DRAWINGS Test Procedure Equipment Used Z86CCP01ZEM ZiLOG e
7. ld RP Working_ISRRs working registers 30 3f cp State_Reg stopped_state J ne test_startup_state_label Know the motor is stopped therefore check for a change in direction tm P2 dir_switch AN006001 Z8X0400 2000 ZILOG INC 11 A DC Motor Controller Using A ZiLOG MCU jr Z Cccw direction label or PO forward direction ld temp2 reg sff forward_LED JE continue_label ccw_direction_label and PO reverse_direction ld temp2_reg ff reverse LED JE continue_label test_startup_state_label cp State_Reg startup_state jr ne continue_label ld temp 1 reg P0 or temp 1 reg 504 ld PO temp 1 reg dec delay reg reaches jr nz continue label ld IMR TOE OTE OCE TIE ISR ld State Reg frunning state continue label cp State Reg frunning state jr ne keyscan label ld temp 1 reg DU or temp 1 reg 504 ld PO temp 1 reg nop nop ld TMR 30E Store the forward LED for use later The register temp2 reg does not change even if there is another routine if the other routine uses a different set of working registers The changing of the working registers is necessary for proper operation of this routine Start the motor Leave the system running until current normal operating level Start the PWM and allow overcurrent keep the systems PWM running with PWM High and Tl timer starting Enable TO T1 load Tl for co
8. xor PO brake bit ld make reg ff tom PO brake_bit JE z test dir label ld P2 temp2 reg ld State Reg startup_state J normal_exit_label test_dir_label ld State_Reg stopped_state ld IMR TOE ld delay_reg 3 ld P2 Sff stopped_LED jr normal_exit_label make_exit_label Cle make_reg normal_exit_label cle bounce reg ld Key temp reg 4 FF cle count reg exit label AN006001 Z8X0400 2000 ZILOG INC 13 A DC Motor Controller Using A ZiLOG MCU pop RP iret end ok ck ck ck ck ck KKK KA KKK KKK KA XK AA KA AX KA KA KKK KKK KA KKK KKK KKK KKK KKK KKK ck ck ck KKK ck ck ck ck ok ck ck ck kk ko Sk kv Mk KKK K Application Motor Controller Date August 07 1999 Created by J D Gersbacher for Motor Controller Application Note Description When the motor is running The sample ISR causes the PWM cycle to go High Tl ISR causes the PWM signal to go Low kk xx PWM XXX SC sample T1 ISR KKEKK KKK KKK KKK A KA KA KKK KKK KA KKK KKK KA KK KKK AX KA KK AKA AX KA KK KKK KKK KA KKK AAA KA KKK KKK KKK ko subtitle T1 Interrupt Service Routine Values page EREEREER REER A Low PWM routine KKK KK KKK KK KKK KKK KKK KKK KKK KKK KKK ck kk subtitle Global Functions page pk e ke ke ke denke ke ke x Global Functions RRR KKK kk kk kc kc kck ck k ck ck ckckckck ck ck ck kk k K public pwmlow ISR segment code pK CK ek ke ek d e e kk ISR Routine
9. ETs Varying the duty cycle of the output by changing the register value of the counter in the Z8 changes the average DC voltage which is used to drive the power MOSFETs The necessary steering logic is incorporated inside the LMD18200 The PWM does not require an external low pass filter unlike conventional designs which require an external low pass filter circuit to produce a constant DC voltage Because the voltage drop across the collector and emitter can reach more than 1V during saturation high heat dissipation is encountered using BJT devices MOSFETs which are intrinsically characterized by low drain to source turn on resistance orRps are better suited for motor driven applications Typically power MOSFETs require a gate voltage of least 8V to turn on which is a problem when using an MCU whose outputs swing from OV 5V Special logic MOSFETs are developed that exhibit gate turn on voltages of 5V The 5V gate turn on works well for the lower legs of the H bridge motor drive but what about the upper legs The upper legs of the bridge circuit require a higher gate voltage due to the fact that the motor s winding resistance raises the MOSFETs source reference above the ground potential A separate DC to DC converter chip can be used to overcome the higher voltage turn on however the extra converter adds more cost and complexity to the design The LMD18200 solves the higher voltage turn on problem with its built in DC to DC converter
10. bounce count a delay is inserted and the STOPPED LED is de energized and the appropriate direction light is lit The delay is to allow the motor time to build up speed and dissipate its start up current When STEADY state is reached Tl is activated and the state changes to RUNNING In the RUNNING state Tl is restarted every time through the ISR In all states the push buttons are checked for activity The increase and decrease buttons affect the PWM timer register The next time th timer is loaded is when the new count takes effect KEK KK KKK KK KKK A AZ A KA X ZA X A AX KA XK AZ KKK AX KA KA AXA X AZ A KA A AA X KKK KKK A K AKA KA ck ko ck A A ck ck AA k Mk sk k kx subtitle Sample Interrupt Service Routine Values page include motorhead inc include sampleISR inc public bounce reg count reg key cnt reg make reg delay reg temp 1 reg temp2 reg extern State Reg PWM Reg Key temp reg segment regfile sample ISR set in the Linker to start at 30 bounce reg ds 1 count_reg ds 1 key_cnt_reg ds 1 make_reg ds 1 delay reg ds 1 temp 1 reg ds 1 temp2_reg ds 1 subtitle Global Functions page pK ek ke ek ke e e kk Global Functions N XXX XX kk kk k kck ck k ck k ck ckckckck kckckck XX K segment code public sample ISR subtitle Motor Control page sample ISR push RP
11. by the direction bit Timer T1 controls the High time of the PWM Timer T1 is configured to stop when reaching the zero count When the terminal count is reached an interrupt occurs and in the ISR it sets port pin P02 Low Pressing the INCREASE push button increases the duty cycle of the PWM conversely pressing the DECREASE push button decreases the duty cycle of the PWM The maximum limits for this application are 90 and 28 respectively due to no change in the DC motor speed on the high end and stopping on the low end AN006001 Z8X0400 2000 ZILOG INC 6 A DC Motor Controller Using A ZiLOG MCU lt De Pressing the STOP START button toggles the BRAKE output to the LMD18200 and either brakes or enables the motor depending on the current state In the STOPPED state the Z8 sets the BRAKE bit to put the motor in the STOP condition in addition the STOP LED illuminates The BRAKE condition effectively shorts the motor via the associated direction drivers Caution Changing the direction of a DC motor while it is running can cause a very large surge of current Therefore the STOPPED state is the only time at which the motor is allowed to change direction The STARTUP state allows the motor to begin movement and to run for a duration prior to activating the overcurrent ISR or the PWM low ISR This time delay allows the motor to reach its normal operating condition When the time delay is complete the overcurrent overte
12. ck ck k kk extern overtemperature ISR overcurrent ISR sample ISR pwmlow ISR extern delay reg segment code subtitle Main Control page pK CK ek ke ek d e e x Main Control eR KKK KKK kk kk kk kk kckck kckckckckck ck ckckck ck K AN006001 Z8X0400 2000 ZILOG INC 9 A DC Motor Controller Using A ZiLOG MCU IRO1 IRQ3 main subtitle Initialization Newpage page zk ek EKER HK Initialization ck ck ck ck ck Ck ck kk AKA AAA KA AAA Ck ck AKA KA ck Sk Sk A kx ko ok srp Working_Regs ld PO motor_stop A High on the Brake pin and PWM stops the mtr ld PO1M 04 P00 P02 outputs controlling Direction Brake PWM respectively ld P3M 03 push pull outputs port 0 amp 2 analog inputs port 3 ld P2 ff stopped_LED Stop the motor and show it ld P2M 0 Four input switches 3 output LED s 1 unused P20 Direction P21 P23 Increase Decrease Stop respectively ld SP1 80 Maximize the stack ld PREO 309 Restart at end of count Must set up the period for 2000hz ld TO ftmrO value i pxtxv where t is 8MHz 2 4 1MHz lus where p is the prescaler with a value of 2 where v is the interval count value of 250 clock is 8HMz 2 4 1MHz gt lps Must do the period or 500us gt 7 500 ps 250xpxlpus ld IMR TOE setup for timer 0 to start the sampling Now setup the High time 50 default value ld PWM_Reg PWM_Half_value Time should be 2501s 250xpxlus ld PRE1
13. cycle to the motor As the INCREASE button is pushed the motor speeds up until a maximum speed is attained The duty cycle is 570ms of 630ms As the DECREASE button is pushed the motor slows until a minimum speed is reached The duty cycle is 180ms of 630ms For an overtemperature condition a short to ground on the P32 port pin causes the motor to stop running and the STOP LED to illuminate For the OVERCURRENT condition placing a very large load on the shaft causes the motor to stop running and the STOP LED to illuminate REFERENCES Chuck McManis A PIC Based Motor Speed Controller Circuit Cellar Ink July 1995 Jeff Bachiacchi Creating the Smart MD Circuit Cellar Ink September October 1995 National Semiconductor LMD18200 data sheet ZiLOG ZiLOG Discrete Z8 Microcontroller Product Specifications Databooks DB97Z8X0200 5 ZiLOG ZiLOG Z8 Microcontroller User s Manual AP96DZ80500 a eg AN006001 Z8X0400 2000 ZILOG INC 20 A DC Motor Controller Using A ZiLOG MCU APPENDIX Schematics ucc Ar TREK EU Lk Direction Sach EN Figure 8 Z86E04 Schematic Diagram AN006001 Z8X0400 2000 ZILOG INC 21 A DC Motor Controller Using A ZiLOG MCU 2 NOTES Information Integrity The information contained within this document has been verified according to the general principles of electrical and mechanical engineering Any applicable source code illustrated in the document was eit
14. e ISR overcurrent ISR id PO 4motor stop A High on the Brake pin and PWM stops the mtr ld State Reg stopped state ld P2 ff stopped_LED Stop the motor and show it ld IMR ftmr0 irq iret PEBRERERERERERERERER ERE RK e e ee ee ee e e e ee e e e ee ee e e e ko e e e e e e e e ee e e ek e ee de he ER oko KEK p P FILE sampleISR inc DATE August 7 1999 Author J D Gersbacher Description define regfile sample ISR space RFILE KKK KK KKK KKK KKK KK KKK KKK KKK AX X A KKK KK KKK KKK KKK KK KKK KKK KKK A KA KKK KK KKK KKK KKK KKK Ak kk k x 7 FILE Motorhead inc DATE August 7 1999 Author J D Gersbacher Description Motorhead inc contains the variables used in the Motor Controller per Application Note title 28 Motor Controller Application Note Di define regfile space RFIL Working_Regs equ 20 Working_ISRRs equ 30 working Interrupt Status Routine Registers bounce count equ ff nd increase equ decrease equ 02 start stop equ 503 dir switch equ 01 d oe jo switches egu SOE minimum equ 13 maximum equ D5 brake bit equ 02 forward_direction equ 01 reverse direction equ SFE AN006001 Z8X0400 2000 ZILOG INC 15 A DC Motor Controller Using A ZiLOG MCU stopped_LED equ 40 reverse LED equ 20 forward_LED equ 10 stopped_state equ 00 startup_state
15. g an overtemperature condition Remove the short remove the break point and reset the software 6 To test the overcurrent condition place a break point in the overcurrent_ISR routine Start the emulator running and start the motor Increase the motor to its maximum speed Stop the motor When the motor winds to a stop grasp the end of the motor shaft and start the motor The emulator should stop in the overcurrent_ISR Remove the load from the shaft remove the breakpoint and reset the software 7 Upon completion of the above checks program a Z86E0408PSC using the Z86CCP01ZEM To program the Z86E04 from the CCP emulator remove the UUT from the CCP emulator and download the code into the CCP emulator Place the Z86E04 in the 18 pin ZIF socket From the toolbar on the top of the ZDS environment select the OTP icon Select the programming option icon and begin programming When the part is programmed put the new part into the UUT and repeat test steps 4 7 After the part is programmed the steps that require setting breakpoints no longer apply Instead of looking for the breakpoint to be reached the motor stops operating and the STOP LED illuminates Test Results The motor controller controls a 12Vpc motor When power is applied and the power switch moved to the ON position the motor controller places the motor into a STOPPED condition and illuminates the RED LED When the START STOP button is pushed the motor applies a 50 duty
16. g the PWM output the H pattern motor controller can control the speed of a DC motor By controlling the direction pin the direction of the motor can be controlled Finally a safety measure is added that stops the motor when an overcurrent condition occurs All operations are controlled by the ZiLOG MCU AN006001 Z8X0400 2000 ZILOG INC 7 A DC Motor Controller Using A ZiLOG MCU TECHNICAL SUPPORT Source Code s Ck ck ck ck ck ck ck ck ck KKK KK KKK KKK KKK KKK KK KKK KKK KKK KKK KK A AAA KA KKK KKK KK KKK KKK KKK KKK KKK KK KKK KKK kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk kk Application Motor Controller Date August 07 1999 Created by J D Gersbacher for Motor Controller Application Note Description The motor controller code is developed to control a LMD18200 National Semiconductor part which in turn controls the operation of a DC motor Through three control lines and two feedback lines the MCU and motor controller can increase decrease and stop a motor The stopping of the motor can occur through normal operation or through two real time interrupts The two real time interrupts become active if an overcurrent condition or on an overtemperature condition exist The two interrup
17. her written by an authorized ZiLOG employee or licensed consultant Permission to use these codes in any form besides the intended application must be approved through a license agreement between both parties ZiLOG will not be responsible for any code s used beyond the intended application Contact your local ZiLOG Sales Office to obtain necessary license agreements Document Disclaimer 2000 by ZiLOG Inc All rights reserved Information in this publication concerning the devices applications or technology described is intended to suggest possible uses and may be superseded ZiLOG INC DOES NOT ASSUME LIABILITY FOR OR PROVIDES A REPRESENTATION OF ACCURACY OF THE INFORMATION DEVICES OR TECHNOLOGY DESCRIBED IN THIS DOCUMENT ZiLOG ALSO DOES NOT ASSUME LIABILITY FOR INTELLECTUAL PROPERTY INFRINGEMENT RELATED IN ANY MANNER TO USE OF INFORMATION DEVICES OR TECHNOLOGY DESCRIBED HEREIN OR OTHERWISE Except with the express written approval of ZiLOG use of information devices or technology as critical components of life support systems is not authorized No licenses are conveyed implicitly or otherwise by this document under any intellectual property rights AN006001 Z8X0400 2000 ZILOG INC 22
18. kk ck Ck Sk ck Ck Sk ck Ck ck ck kk ck A ck kk kk Sk kk kk kc KKK KKK KKK pwmlow ISR and PO FB 71111_1011 which clears the PWM bit iret KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KK KKK KKK KKK A X AX KKK KKK KK KKK KKK KKK AZ X A KKK KKK KKK KEK Application Motor Controller Date August 07 1999 Created by J D Gersbacher for Motor Controller Application Note Description When an error condition exist ither the overcurrent or the overtemperature the motor must stop Stopping the motor allows the error condition to correct itself and the system continues normally from a stop state The most recent Timer 1 value is the starting value for the PWM KKK KKK ck ck ck KKK A KKK KKK KKK KKK KK KKK KKK KKK KKK A A AAA KA KKK KKK KKK KKK AA KEK ko kk kA KKK KK KKK subtitle ERROR Interrupt Service Routine Values page include motorhead inc pK CK ek ke ek d e e x Over current routine KKKKKKKK KKK XX ER XXE EEK XX ck ckckck ck kk kk extern State Reg subtitle Global Functions AN006001 Z8X0400 2000 ZILOG INC 14 A DC Motor Controller Using A ZiLOG MCU page pk ek eee eee ke x Global Functions N NF X X X KK kk ck ck ck ck k ck ck EEK KE kckckck ck K public overtemperature ISR overcurrent ISR segment code pK e ke ke ek ke e e x x ISR Routines ck ck ck ck ck ck ck Ck ck k A Ck Sk ck Ck kk kk ck kk kk Sk kk kc KKK KK KKK overtemperatur
19. mperature and timer T1 ISR are all enabled The state is changed to the RUNNING state In the RUNNING state timer T1 is continually restarted and the PWM signal operates normally Timer TO causes the PWM to go High and timer T1 causes the PWM to go Low By modifying the time value of T1 the High time of the PWM is modified Timer T1 time is changed by the increase and decrease push buttons The initialization routine sets up the hardware ports the timers and the interrupts necessary for proper motor controller operation The I O ports P20 P23 are arranged as inputs Port pins P24 P27 are arranged as push pull outputs Port pins PO0 P02 are configured for outputs The BRAKE bit is set and the STOP LED is illuminated The PWM is set up for a 5096 duty cycle The interrupts are set so that TO is the only interrupt available Remote Control Instead of push button switches to control the functions and speed of the motor an I C or asynchronous communications protocol can be added for remote control RESULTS OF OPERATION Completing the schematic layout as shown in the Appendix and programming the Z86E04 with the system software allows the system to run with no errors A 12Vpc bidirectional motor is controlled from a minimal speed to a maximum speed in both the forward and reverse directions All of the LEDs illuminate at the appropriate time and the overcurrent routine tests correctly SUMMARY Reaffirmation of Results By controllin
20. mulator or equivalent s ZDS version 2 12 or later ZiLOG assembler linker debug environment S Tektronix 2230 digital storage oscilloscope S PC running Windows 95 General Test Setup and Execution 1 Follow the ZiLOG Developer Studio ZDS setup procedures for installation onto the PC Follow the Z86CCP01ZEM connection directions for proper operation 2 When ZDS is running and the emulators are operating assemble and link the code for debug operation Use the default settings for assembly and linking In addition to the default settings use the toolbar icon for Project Settings gt Linker Select the Ranges category Enter a regfile address 0010h 001Fh b regfile_Motor address 0020h 002Fh C regfile sample ISR address 0030h 003Fh 3 Use an oscilloscope to ensure the proper operation of the PWM stop bits and the LED output pins AN006001 Z8X0400 2000 ZILOG INC 19 A DC Motor Controller Using A ZiLOG MCU a 2 4 When the signals are verified connect the emulator to the system board Run the software and verify that the LEDs illuminate the push buttons control the motor and the motor rotates in the forward and reverse directions 5 Place a brake point in the overtemperature_ISR On the unit under test UUT momentarily place a ground level at the temperature input P31 Pin 8 The grounded pin should cause the emulator to stop at the break point The grounded pin represents LMD18200 operation durin
21. robotics CD players disk drivers fans and toys require DC motor control Additionally the demand for smaller packaging and higher reliability creates a demand for more integrated motor driver solutions In the past a DC motor controller was comprised of a microcontroller MCU supported by many discrete components Presently advanced IC technology reduces the drive electronics to just two chips an MCU and an integrated motor driver This Application Note references the ZiLOG Z86E0408PSC and the National Semiconductor LMD18200 to produce the low part count DC motor driver Motor Control Basics Several DC motor design topologies exist however the most widely used method is the H bridge configuration The H bridge method employs four Bipolar Junction Transistors BJT or four Metal Oxide Silicon Field Effect Transistors MOSFET devices configured in an H pattern Figure 1 To drive the motor in the forward direction current flows through O1 and O4 while O2 and O3 are turned off path 1 in Figure 1 Drive the motor in the reverse direction with O2 and O3 turned on and Q1 and O4 turned off path 2 in Figure 1 The LMD18200 allows operating frequencies up to 1KHz with no external components For faster operating frequencies up to 500KHz use an external 10 nF capacitor across the bootstrap pins The average current of the H bridge controls motor speed The Z8 creates a Pulse Width Modulated PWM signal which is used to control the MOSF
22. t includes a 10 KQ pull up resistor When the junction temperature of the LMD18200 exceeds 145 C the temperature pin goes Low causing the Z8 to interrupt to the temperature interrupt handler routine There are three push button switches and one single pole double throw SPDT switch The push button switches are the START STOP DECREASE and INCREASE push buttons By holding down either of the INCREASE or DECREASE push buttons one can increase or decrease the motor speed to a rate in the limit range of 28 to 90 The SPDT switch determines the FORWARD or REVERSE direction The switches are connected to P20 P23 LEDs are associated with each of the switches The STOP LED is red and is connected to P26 The FORWARD LED is yellow and is connected to P25 The REVERSE LED is green and is connected to P24 The debounce time for the switches is managed in the interrupt service routine ISR The switches must be held down for at least two passes into the ISR Software Description The software for the motor controller is a state machine There are three states produced by the motor controller code The three states are STOPPED STARTUP and RUNNING The initial PWM is set for a 50 duty cycle The initial state is the STOPPED state as indicated by the red LED The motor may be started by momentarily pressing the STOP START push button The motor spins until it reaches the speed set by the PWM value in a clockwise or counter clockwise direction as set
23. t service routines handle the error condition exactly the same Both immediately stop the motor and change the condition of the software to the STOPPED state The overall flow of the software is based on an interrupt from timer 0 The main loop does not execute in this example code the software merely waits for the time out of Timer 0 Timer 0 interval between interrupts is 500 microseconds Timer 0 s ISR is a three condition state machine The three states associated with the ISR are STOPPED STARTUP and RUNNING In the STOPPED state the system checks for a change in direction then store the direction Storing of the direction occurs whether the direction changes When the direction is determined the STOPPED STATE checks for push button activity If any of the push buttons are active the appropriate routine is run When the push button routine is completed the ISR exits using the IRET command There are thr push buttons increase decreas and start stop The start stop bush button is a toggle button When the motor is in the STOPPED condition as it is at reset the pressing of the start stop button initiates the debounce time When the debounce routine is complete and the start stop button is still active the motor starts the brake pin is released and the pulse width modulation pin PWM is set High The ISR condition is changed to the STARTUP state During the STARTUP state there is a time delay used to get the motor started The sys
24. tem exits again using the IRET When the time delay expires Timer 1 interrupt is enabled and Timer 1 is started and the ISR condition is changed to the RUNNING state In the RUNNING state the motor is running at 50 of its maximum speed provided the increase or decrease button had not been pushed The increase and decrease buttons change the speed of the motor By holding one of the push buttons down the motor speeds up or slows down depending on which button is pushed In the sample_ISR routine the change of speed is accomplished by modifying the Timer 1 s count value Timer 1 interrupts when the count value reaches zero In Timer 1 s ISR the PWM signal is brought Low Timer 1 s count value decreases until the minimum value defined in motorhead h is reached Timer 1 s count value increases until the maximum value defined in motorhead h is reached The third switch is the direction switch Associated with the direction switch are three LED s Stop LED clockwise direction LED and counter clockwise direction LED When the motor is in the STOPPED state the Red LED is lit As described above th STOPPED state is the only time the direction switch is active When the motor is in AN006001 Z8X0400 2000 ZILOG INC A DC Motor Controller Using A ZiLOG MCU any other state other than the STOPPED state the Red
25. unting TO is always counting so keep the same time for TO PRR RRR KERR RK RK RK KER KK KKK KK kc kk KR KKK ke kk KEK ko KKK KKK kk ko KKK ke kk ke ERK kk ke kk KEK kk ke ke e ke ke ko ke e ke ke subtitle Key Scan Operation page keyscan label CE key cnt reg ld temp 1 reg P2 and temp 1 reg ffswitches cp temp 1 reg ff50E jp eg make exit label Or temp_l_reg F1 rr temp_l_reg ld count_reg 03 keyloop_label inc key_cnt_reg tra temp 1 reg jp c NotThisKey label check for any activity on push buttons find out which one AN006001 Z8X0400 2000 ZILOG INC 12 A DC Motor Controller Using A ZiLOG MCU cp Key temp reg key cnt reg first time delay for debounce jr ne store key label inc bounce reg cp bounce reg fbounce count jr ult store key label pxxx xx Increase check cp key_cnt_reg increase SES ne try decrease label inc PWM Reg cp PWM Reg maximum JE ult do_load_label ld PWM_Reg maximum do_load_label ld T1 PWM Reg JE make_exit_label try_decrease_label cp key_cnt_reg decrease jr ne try_brake_label dec PWM_Reg cp PWM_Reg minimum jr ugt do_load_label ld PWM_Reg minimum jr do_load_label store_key_label ld Key temp reg key cnt reg CL key_cnt_reg jr exit label NotThisKey label djnz rl keyloop label try brake label cp key cnt reg fstart stop jr ne make exit label cp make_reg ff jr eg normal exit label

Download Pdf Manuals

image

Related Search

Related Contents

USER MANUAL INSTRUCTION  User Manual - Mower Magic  Les 3èmes passent le grand oral  Dicota College Action  English Leather 240R Brush Cutter User Manual  HP25 SERIES UNITS  Lanier R1  Manuel de montage en francais    Whistler XTR-430  

Copyright © All rights reserved.
Failed to retrieve file