Development of a Digital Sine Machine Based on a Microcontroller
2026-04-06 07:21:11··#1
During the debugging of servo systems, a sine wave machine capable of accurately transmitting various test signals is required. However, commonly used electromechanical sine waves suffer from insurmountable drawbacks such as mechanical transmission backlash, dead zones, waveform distortion and drift, and poor repeatability of binding parameters. To overcome these shortcomings, the authors developed the 8098 digital sine wave machine. 1 Hardware Composition The 8098 digital sine wave machine uses the MCS-96 series 8098 microcontroller [1,2] (a compatible 80C196 microcontroller can also be selected) and the 5VASZZ series DSC module to generate step, constant velocity, periodic constant velocity, and sine wave signals using software methods. These signals are directly output as 16-bit digital signals via an 8255, or divided into coarse and fine 12-bit digital values and sent to two DSCs to convert them into a three-phase analog voltage dual-channel output. During this process, the 8279 is used to display and control the operating status of the sine wave machine. The hardware composition block diagram of the 8098 digital sine wave machine is shown in Figure 1. Figure 1. Hardware Block Diagram of the 8098 Digital Sine Machine 2. Software Implementation Most functions of the 8098 digital sine machine are implemented using 8098 assembly language programming, and its software functional block diagram is shown in Figure 2. Figure 2. Software Functional Block Diagram of the 8098 Digital Sine Machine 2.1 Signal Generation The design concept of this part is illustrated below using the generation of a sine signal as an example. 2.1.1 Algorithm The implementation of sinusoidal motion is essentially to send a position offset y at a unit time according to the sine function value of a given period, and then add the base value y0 of the sine to obtain the position A0 that changes sinusoidally around the base value. Due to limited memory and to simplify the program, the design adopts the method of first calculating the sine curve of 1/4 period, and then obtaining the sine curve of the entire period through connection processing. The calculation of the position offset is based on the bound sine period value T, calculating the standard sine curve of unit amplitude, and then multiplying the bound sine amplitude M by the standard sine value x corresponding to each calculation point to obtain the position offset that changes sinusoidally. 2.1.2 Sine wave guidance To ensure that the servo system under test changes smoothly according to the sinusoidal amplitude, a sinusoidal amplitude guidance program is designed for both the beginning and end segments of the sinusoidal motion. The following is an example of the beginning guidance: The number of points N to be guided is calculated according to the bound sinusoidal period value T. Starting from the first point (n=0), the sinusoidal amplitude m increases linearly from 0 until the last point (n=N), which makes m equal to the bound sinusoidal amplitude M. This completes the guidance (the end guidance is the reverse, starting from M and decreasing linearly to 0). The 8098 digital sine wave machine specifies one cycle of guidance. The algorithm formula for sinusoidal guidance is N=400T, (1) m=Mn/N, (n changes from 0 to N), (2) y=mx, (3) A0=y0±y. (4) In the positive half cycle of guidance, the "+" sign in formula (4) is valid; in the negative half cycle, the "-" sign is valid. The schematic diagram of the sinusoidal guidance curve is shown in Figure 3. Figure 3. Schematic diagram of sine guide curve. 2.2 Limiting operation mode. Limiting operation mode can be used during step, constant speed (including periodic constant speed), and sine motion execution. Users can arbitrarily set two upper and lower limit values α and β within the range of 0 to 360°. The sine machine can only operate within the range from β counterclockwise to α. When the limit value is reached, the sine machine automatically stops transmitting data at the limit position. This limiting operation mode provides protection for the debugging of angle-limited servo systems. 3. Debugging . The debugging of the 8098 digital sine machine is divided into two stages: laboratory debugging and field system integration debugging. In laboratory debugging, two different methods were used to verify whether the sine machine was working properly: ① Using the drawing function of the ATD98D microcontroller development system. The ATD98D microcontroller development system has a drawing function, which can simply depict the data in memory 0 to FFFFH. During debugging, before the 16-bit digital output of the program, it is first stored in the unit starting from C000H. After each motion is completed, the output position curve can be plotted, allowing for a direct observation of whether the motion curve is correct. If errors are found, the program can be modified and executed again, and the curve re-plotted for observation until it is error-free. This method is very convenient in the early stages of debugging. ② Using an oscilloscope combined with graphical method. Using a Hitachi V-134 memory-type oscilloscope, the waveforms of the three-phase output voltage of the coarse and fine dual-channel DSC module changing with time can be easily observed when the sine machine performs various motions. Based on the set parameter values, the curves of the sine machine's position changing with time during various motions and the curves of the DSC module's three-phase output voltage changing with position can be obtained. Thus, the theoretical curve of the DSC module's three-phase output voltage value changing with time can be obtained graphically. By comparing the waveforms actually observed by the oscilloscope with the graphically derived theoretical curves, it can be determined whether the sine machine is working properly. Figure 4 shows the curves (phase A and phase B) of the output voltage of the coarse-channel DSC module as a function of time, obtained using the graphical method when the sinusoidal motion parameters are M=90° and T=6s. (a) Curve of DSC three-phase output voltage versus position (b) Curve of position versus time (c) Curve of DSC output versus time Figure 4: Curve diagram of sinusoidal coarse-channel DSC output versus time Principle 4 Conclusion After passing the tests using two experimental methods, the 8098 digital sine wave machine was successfully integrated into the Chongqing Wangjiang Machinery Plant in July 1996. The results show that all indicators of the 8098 digital sine wave machine meet the requirements, and the error of the transmitted signal is significantly smaller than that of the electromechanical sine wave machine. It overcomes many shortcomings of the original electromechanical sine wave machine, possessing complete functions, reliable operation, simple operation, strong versatility, small size, and light weight, making it an ideal tool for debugging and accepting the characteristics of servo systems.