2. Experimental equipment. Single chip microcomputer measurement and control experiment, system stepping motor control experiment module, Keil development environment, STC-ISP program download tool.
3. Experimental content. MCS-5 1 is programmed to make the stepping motor rotate at the specified speed and direction, and the number of rotated steps is displayed on the digital tube. The speed of stepping motor is divided into two steps. When the switch S 1 is pressed, it is accelerated, and the rotational speed is accelerated from 10 rpm to 60 rpm. When the switch is released, the rotation speed slows down and the speed returns to 10 rpm. When the S2 switch is pressed, it rotates counterclockwise; After loosening, turn it clockwise. This program requires timer interrupt, and the method of program delay is not allowed.
4. Experimental steps. Preview: Refer to auxiliary materials to learn the use of C5 1 programming language and the principle of stepping motor. Simple program entry and debugging: regarding the interrupt of C5 1, this program needs to use a timer to time and synchronize the interrupt. A typical example of an interrupt program is as follows: Format: void function name () Use workgroup for interrupt number {Interrupt service program content} Note: Interrupt cannot return a value, so void is followed by the function name, which can be named by itself, but it cannot be the same as the keyword in C language; The interrupt function does not take any parameters, so the () after the function name is empty, and the interrupt number refers to the serial numbers of several interrupt sources of the single chip microcomputer. This serial number is the only sign that the single chip microcomputer recognizes different interrupts. So be sure to write it correctly. Using the workgroup refers to which of the four working registers in the memory of the single chip microcomputer is used for this interrupt. C5 1 will automatically assign working groups after compilation, so we usually omit the last sentence. Examples of interrupted writing of c5 1: void t1-time () interrupt 3 {th1= (65536-50000)/256; TL 1 =(65536-50000)% 6; } The above refers to the interrupt service program of timer 1. The interrupt service sequence number of timer 1 is, so we write it as interrupt3. The content of the service program is to load new values into two initial value registers.
5. Experimental principle. The frequency of the single chip microcomputer system used is12m; ; It takes 24 steps for the stepper motor to rotate once. FAN8200 is used as the driving chip in the experimental board of stepping motor. CPU is connected with FAN8200 through pins.