【正文】
should be done is to produce highlow alternating pulses from port of SCM. At the same time, to control the steering and mode, and ports are set to high level or lowlevel on request. Theoretically speaking and L297 can be connected directly, but actually the loads of microcontroller make the output voltage of P1 port low and unstable. The system could not identify the transition between the high and low voltages and thus can not output ideal pulses to the L297. In order to solve this problem, we use voltage followers to connect the output ports of SCM. They are to maintain and stabilize voltage. The voltage follower has 11 11 good interference immunity and can output stably so it can make the voltage achieve the standard which drives the following circuit. Connection Between L297 and Stepper Motor 7904 is a mon gate circuit chip, which is formed by four AND gates. IRLZ44N is enhanced NMOS. Connection Between SCM and Relay In principle the output ports of SCM can be connected to the relay directly. In the experiment the output of SCM is actually very unstable, and the output voltage of is pulled down low because of the loads, so it can not drive the relay. To solve the problem, we use optocoupler to drive the relay. The optocoupler has good antiinterference performance and can effectly solve the output problem, which makes the circuit more reliable. Then VCC of relay is 12V. when of SCM outputs highvoltage, the relay powers and thus the switch is open. When outputs lowvoltage, the switch is closed. 3 SOFTWARE DESIGN Program Flow When there is no object passing, the photoelectric switch outputs highvoltage. Once some object is detected, the output of the photoelectric switch generates a falling edge signal immediately, and input it to of SCM. Then SCM outputs desired signals to the three control ports of stepper motor driver chip: CLK (), CW (), HALF () to control the stepper motor to work. We can set specific packaging time through the SCM timer. After finishing packaging, a moment lowvoltage from is generated to the relay and makes the switch which is normally closed open immediately and then close again. That pletes the action of cutting packing tape. 12 Programming In this design the program is written in C language. C has the advantages of both the highlevel language and assemble language. It is flexible, convenient and pact in structure. What’s more it can be applied in a large of fields and has good portability. We choose Keil C language integrated development environment which shows Windows interface that generates object codes efficiently. The majority of assembly language codes generated are very pact and easy to understand. Then the program is burnt into SCM by ISP, a STC download programming software, which is easy to operate. The main program is shown as below. Void main () { ports()。 In main program this interruption subroutine is called for several times. That generates pulses to drive the stepper motor to work. In this experiment we set fullstep and reverse mode, which can be seen in the interruption subroutine. 4 TEST RESULTS After the hardware circuit is built pletely, the program is burnt into the SCM. In order to easy the experi