Frontiers in Computing and Intelligent Systems ISSN: 2832-6024 | Vol. 12, No. 1, 2025 150 STM32‐Based Piezoelectric Ceramic Control System Yingdong Dai 1, Meng Jie 2, * and Yiming Zhang 1 1 School of Information and Control Engineering, Jilin of Chemical Technology University, Jilin Jilin 132022, China 2 School of Mechanical and Electrical Engineering, Jilin of Chemical Technology University, Jilin Jilin 132022, China * Corresponding author. Meng Jie Abstract: To address the high-frequency vibration driving requirements of piezoelec-tric ceramics, this paper proposes a novel control system based on an STM32 microcontroller, aiming to simplify circuit architecture while enhancing anti-interference capability and driving efficiency. The system employs the STM32F407 as the main controller, achieving high-precision digital- to-analog conversion through SPI communication with an external DAC8311 module, and integrates a TPA3106 power amplifier and transformer to drive the piezoelectric ceramic. Waveforms are generated using DSP instructions to optimize computational resource utilization, and a soft-start function is implemented to enable a gradual voltage ramp-up, effectively suppressing inrush current during power-on. Collaborative control via timer interrupts and external interrupts facilitates smooth switching and stable adjustment of frequency (100–250 Hz) and amplitude (0–3.3 V). Experimental results demonstrate optimal vibration intensity at 213 Hz. The system supports flexible parameter tuning for frequency and amplitude, exhibiting high versatility and reliability. This design provides a compact and efficient solution for high-frequency vibration driving, with significant application potential in industrial feeding, ultrasonic devices, and related fields. Keywords: Piezoelectric Ceramics; STM32; DAC; Drive Control. 1. Introduction Piezoelectric ceramics is a new type of smart material which has piezoelectric effect and can realize the conversion between electrical energy and mechanical energy. According to this characteristic, piezoelectric ceramics are used in the fields of piezoelectric transducers, piezoelectric actuators, piezoelectric sensors and so on. Among them, piezoelectric ceramics are widely used in the field of optics and acoustics due to their advantages of small size, easy control, high resolution, high dynamic response, no heat, no noise, etc., such as nondestructive flaw detection, ultrasonic devices, sonar, and oscillators utilize the vibrational properties of piezoelectric ceramics [1]. Currently in the industrial application of more feeder, vibration plate is the use of material vibration to achieve the delivery of small components such as chip resistors, but also can be set to different frequencies to achieve the screening of unqualified products. Piezoelectric ceramic drive needs to drive the power supply and drive circuit to achieve high- precision control, high frequency and fast dynamic response[2][3]. Early drive power using analog circuit control, affected by temperature, low control accuracy, slow dynamic response, does not meet the characteristics of piezoelectric ceramic drive. Now more use of digital circuit design of the drive power supply[4], the use of scale integrated components to achieve filtering, power amplification and other functions, the use of programmable logic controllers such as microcontrollers to achieve automatic control, which can greatly simplify the hardware circuit, improve the control accuracy and anti-interference ability[5][6]. The use of microcontroller main controller and other scale integrated components to design the drive circuit can achieve fast and stable control and high degree of automation, with automatic fault detection function to increase the anti- interference ability to achieve high power, low power consumption of high dynamic response output [7][8]. In this paper, based on STM32 microcontroller, design a system to drive piezoelectric ceramics. According to the inverse piezoelectric effect, piezoelectric ceramics can realize the conversion of electrical energy to mechanical energy, and the controller delivers a voltage to the piezoelectric ceramics to realize the drive of piezoelectric ceramics [9], when the PWM pulse width modulation technique is used to deliver a stable and variable voltage, the quantitative deformation of piezoelectric ceramics can be realized to produce a fixed displacement; when a sinusoidal voltage is delivered by using the DSP library, the piezoelectric ceramics produce a deformation with the change of waveforms to realize fixed frequency vibration. This design uses an external DAC module to realize high-resolution and high-precision digital- to-analog conversion, adopts the TPA power amplifier module to output a good and stable high-power voltage to drive the piezoelectric ceramic chip, and joins multiple timer interrupts, external interrupts and limiting variables to realize the stable adjustment of the amplitude and frequency of the output voltage, and selects the appropriate amplitude and frequency according to different application scenarios. 2. System Design The system as a whole includes the design of hardware circuits and software programming, with the STM32F407 microcontroller as the controller MCU of the system, according to the piezoelectric ceramic control requirements to be realized, build the control circuit of the whole system, including the key input control module, DAC conversion module, TPA power amplifier module, power supply, transformer and other circuits. Through the software program to achieve the SPI communication output of the STM32F407 controller, through the DAC digital-to-analog conversion module to achieve the transformation of digital signals to analog signals, through the TPA power amplifier module to output a good and stable high-power voltage, through the transformer boost to drive the piezoelectric sheet, resulting in vibration effects. The key input module has two keys to 151 control the frequency and amplitude of the output voltage, and a key to control the start and stop of the TPA conversion, which is directly related to the signal output of the whole circuit. The power supply module has two power supplies, 3.3V connected to the STM32F407 and DAC conversion module, and 24V connected to the TPA power amplifier module. The overall design of the system is shown in Figure 1. Figure 1. Overall System Block Diagram 3. Hardware Architecture Design The hardware of the piezoelectric ceramic control system mainly consists of STM32 main controller, DAC digital-to- analog converter, TPA power amplifier and other keys, LEDs and transformers. 3.1. Hardware Design of STM32 Main Controller STM main controller consists of MCU chip, power supply circuit, backup power supply, external crystal. As shown in Figure 2, the main controller chip is selected STM32F407ZET6 this main frequency 168Mhz Cortex M4 core, which comes with a DSP instruction set, which can realize the basic mathematical function function and Fast Fourier Transform function call [10]. The power supply circuit is powered by 24V and 3.3V, and the backup power supply area is powered by a mixture of CR1220 coin cell and VCC3.3V. The STM chip comes with its own internal RC oscillator, but with low precision, and is connected to two external crystals, 8M and 32.768k, which are more than ten times more accurate than the internal crystal. The main chip pins are labeled on behalf of the design of this system to use, including SPI communication pins, TPA amplifier connection pins, and con interface connected to the transmit and receive ports, and ports connected to the keypad and so on. Figure 2. STM32 Main Controller Hardware Circuit 3.2. Hardware Design of DAC Digital-to- analog Conversion In the digital-to-analog conversion module, the DAC8311 chip is used. As shown in Figure 3, the STM32F407ZET6 chip comes with a DAC digital-to-analog conversion channel, but the internal DAC supports up to 12-bit mode, which is directly controlled by the DORx register. Therefore, the fastest conversion speed is about 333K, the resolution is only 10bit in most cases, and the distortion can be up to 3% and above when outputting a sine wave. The DAC8311 supports 14-bit mode with a resolution of 14bit, and can realize data 152 transmission through SPI communication, with a sampling rate of 225Khz, a gain error of 0.15% FSR, and a power consumption of only 0.14mW, which compares favorably with the DAC channel included in the chip. DAC8311 has 6 pins, SYNC is the level-triggered control input port, which is the frame synchronization signal for the input data, when the level goes low, DAC8311 is updated according to the clock cycle, so that the input shift register and the data are transferred to the edge of the falling edge, and it acts as an interrupt when it is on the edge of the rising edge, and the write data is ignored by DAC8311. data is ignored by the DAC8311. That is, chip select pin, falling edge from high level to low level, trigger signal, DAC8311 start to transmit write data, from low level to high level in the rising edge, do not carry out the chip select, DAC8311 interrupt write data. SCLK is the serial clock input, the data transfer rate of up to 50MHz. DIN is the serial data input port, when the chip select signal is low level, data AVDD/VREF is the power input, +2V~+5.5V. GND is the ground port. VOUT is the analog output voltage of the DAC, the output amplifier has “rail to rail”, the output voltage of the op-amp is “rail to rail”, the output voltage of the op-amp is “rail to rail”, the output voltage of the op-amp is “rail to rail”, the output voltage of the op-amp is “rail to rail”, the output voltage of the op-amp is “rail to rail”. VOUT is the analog output voltage of the DAC, the output amplifier has “rail to rail”, the amplitude of the output voltage of the op-amp can reach the power supply voltage. Figure 3. DAC Hardware Circuit 3.3. Hardware Design of the TPA Power Amplifier Figure 4. TPA Power Amplifier Hardware Circuit In the TPA power amplifier module, the TPA3106 chip is used, which is a 40W class d audio power amplifier that eliminates the need for a heat sink. The amplifier has four selectable gains of 20, 26, 32, and 36 dB and an efficiency of 92%. As shown in Figure 4, the TPA3106 chip has a total of 32 pins, INP and INN pins are the positive audio input and negative audio input, connecting to the analog voltage output from the DAC8311.GAIN0 and GAIN1 pins are the least significant bit and the highest significant bit of the gain selection, which both follow the TTL logic level. The MSTR/SLV pins are used to determine the master-slave selection of SYNC terminal direction, high for master mode where the terminal is an output, low for slave mode where the SYNC terminal accepts a clock input. ROSC is the IO port for the resistor that currently sets the ramp generator. VREG is the regulated 4V output of the internal power supply only. VBYP is the preamplifier reference, which can be controlled for startup time by the size of an external capacitor. PVCC is 153 the power supply left-channel h-bridge, which is not internally connected to the AVCC. BSN and BSP are the negative high side and positive high side of the left channel bootstrap IO port. OUTN and OUTP are the negative and positive outputs of the class d 1/2-h bridge. SHUTDOWN is the on/off signal of the chip, disabling the chip when low and working normally when high. MUTE is the output fast disable or enable mute signal, connected to the STM32 chip port, received high level MUTE is the output fast disable or enable mute signal, connected to the STM32 chip port, when receiving a high level, do not enable, the audio is output normally, when receiving a low level, enable, realize the mute. FAULT is the port to report the short-circuit fault signal, from TPA3106 to the STM32 chip output signals, when detecting a short-circuit fault, the TPA outputs a high level, sends the fault signal to the main chip and carries out the troubleshooting. 3.4. Other Hardware Design In addition to the three main modules, the system also has hardware such as power supply, keys and terminal wires [11]. As shown in Figure. 5 and Figure. 6, the power supply is divided into two 24V and 3.3V, which supply power to the main STM chip and the power amplifier respectively. Two switches are connected externally from the STM32 chip to control the frequency and amplitude of the output sine wave respectively. The terminal wires realize the ST-LINK communication with the host computer, the connection of the transformer and the connection of the external power supply. Figure 5. 3.3V Voltage Hardware Circuit Design Figure 6. 24V Voltage Hardware Circuit Design 4. Software Implementation Piezoelectric ceramic control system software design is shown in Figure 7. control system started by the external interrupt system, through the generation of waveform program to generate the specified waveform, through the SPI communication to the DAC transmission of digital signals, the DAC digital-to-analog conversion after the generation of analog signals output to the TPA, after the power amplification and transformer output to the piezoelectric ceramic chip. Figure 7. Software Design Flowchart 154 4.1. Waveform Generation The simplest way to generate the desired waveform through the program is to directly give a data table, take the number of points in a cycle to determine the size, and trigger different intervals according to the timer to realize the output of the waveform. However, STM32F4 series chip with DSP instruction set, can realize the basic math function and fast Fourier transform function call, can be completed in a single cycle of a 32×32+64→64 operation or two 16×16 operation, can release a large portion of the arithmetic resources, so in this design directly use arm_sin_f32 function to realize the waveform of automatic Calculation. In the waveform initialization function, a slow start parameter is added to realize the voltage increase in the shape of a horn when the system switch is turned on, giving the system and piezoelectric ceramics a buffer time. Set the cycle and num parameters to generate the waveform table; by changing these two parameters, the size of the waveform output frequency is changed. 4.2. SPI Communication SPI is a high-speed full-duplex communication method, which only occupies four pins, saving space in the use and layout, so it is widely used. The SPI of the STM32 chip also provides a DMA function, which opens up a direct data transfer path between the RAM and the I/O devices through the hardware and improves the efficiency of the CPU greatly. The STM32F407 chip has three SPI channels, and when the chip's SPI channel is not enough, it is possible to use the SPI channel to transfer data directly. When the SPI channel of the chip is not enough, it can be set to simulate SPI communication through the GPIO port, and after the initialization of port multiplexing, it can be used to output data through a for loop. 4.3. External Interrupt Design This design adopts four external interrupt functions, namely, LINE6, LINE9, LINE10 and LINE11. LINE6 is connected to the MUTE interface of TPA to decide whether to enable mute or not, i.e., the on/off function of this system. LINE9 is connected to the FAULT interface of TPA to generate an interrupt request from the short line LINE9 when there is a short-circuit fault and the program executes the fault processing to stop the waveform. The program executes the fault processing and stops the waveform output. LINE10 and LINE11 are connected to the keys to control the output voltage amplitude and frequency. 4.4. Timer Interrupt Design This design uses two timer interrupt functions, the first interrupt function realizes the transmission of the waveform array value to the DAC, and the second interrupt function realizes the switching of the output array after the frequency or amplitude is changed. Two arrays are added, one is the array that is currently outputting waveforms and the other is the array that is about to output waveforms. In this design, the timer interrupt function and the external interrupt function cooperate with each other, and the variable ZD is added inside the external interrupt to determine whether the output voltage amplitude or frequency changed by pressing the key has completed the change, and the changed value has been input to the next array. When the key is pressed, ZD=1, and when the timer controlling the waveform output array generates an interrupt, ZD=0. Add the zh variable to the timer interrupt function to determine which array is currently being output by the parity of zh. Continue to add the variable ha, when the voltage amplitude or frequency changed by pressing the key in the newly generated array values are all updated ha=1, when the timer controlling the waveform output array generates an interrupt ha=0. When the first timer interrupt occurs, determine whether the value of the array transferred to the DAC and the update of the array is complete, when both are complete, then enter the timer interrupt function. In the interrupt function through the zh judgment to distinguish the next output of the array, and in turn to the DAC to transfer the value of the array. 4.5. DAC8311 Signal Acquisition DAC8311 chip chip selection signals, clock pulses, data transmission bits are controlled by the main chip STM32, in this module program design, add a section of the program, when the MUTE port generates an interrupt, the digital voltage transmitted to the DAC8311 via SPI communication is set to half the current amplitude. 4.6. TPA Mute and Fault Design In the TPA power amplifier module, MUTE is set to be the output pin and FAULT to be the input pin, and no pull-ups or pull-downs are generated during initialization. The MUTE signal is set to be a switch and is applied in conjunction with the program of the DAC8311. When the FAULT pin goes high, it represents a short-circuit fault in the system circuit and the SPI stops the communication transmission. 4.7. Keypad and LED Design This system designs two external buttons to control the frequency and amplitude of the output waveform respectively, and calls an LED light, which blinks once when the first interrupt function transmits the waveform array value to the DAC and completes this output. 5. Experimental Validation Figure 8. Button and Power Connection Diagram First of all, according to the circuit diagram for the selection of components to buy, and then according to the circuit diagram for the physical welding, as shown in Figure 8, including the main chip STM32F407 module, DAC module, TPA module, transformer module, keys, piezoelectric ceramics and so on. The operating temperature of the piezoelectric ceramic is -10℃~+60℃, and the single-side capacitance is 7.5±0.3nF. As can be seen from the circuit 155 board in kind, the system is very streamlined in terms of structure, and its anti-jamming ability has been greatly improved. Afterwards, the power module is connected and powered up to test its circuit and function. First, the overall operation of the system is verified, from the main chip using the DSP library to generate an array of sinusoidal functions, through the SPI communi-cation protocol, the array is output to the DAC chip, the DAC after digital-to-analog conversion, the digital signals transmitted by the main chip are converted to analog voltage signals, and continue to be output through the circuit to the TPA power amplifier place. As shown in Figure 9, the power-up process is carried out by pressing the key to verify whether the added slow-start variable plays a role. Verified by an oscilloscope, at each power-up, the output voltage can be flared from 0 to the specified voltage amplitude, which can reduce the inrush current during power-up and play a role in protecting the circuit. Figure 9. Soft-Start Waveform Diagram After power-on verification, STM32F407 chip output digital signal is normal, DAC chip can complete the digital- to-analog conversion output analog voltage, TPA power amplifier output is normal, the circuit can be normal output voltage waveform. As shown in Table 1, the verification of the key, the key can realize the frequency and amplitude adjustment and according to the program design to achieve periodic adjustment and smooth switching function, but also through the timer parameters and the number of array elements to adjust, change the amplitude and frequency of the adjustable range. Table 1. Button Validation Key Press Count (times) Voltage Amplitude (V) Voltage Frequency (Hz) 0 3.36 102.6 4 1.42 128.7 8 1.79 156.8 12 2.11 183.5 15 2.41 203.2 18 2.89 225.3 20 3.13 242.7 21 3.25 248.7 22 1.38 98.4 As shown in Figure 10, the final oscilloscope acquisition probe was placed at the inductor after the VOUT port of the DAC to measure the voltage amplitude and frequency of the STM32F407 chip output in real time. Through the materials placed on the piezoelectric vibrator and by directly touching the vibration disk, after constantly adjusting the frequency and amplitude of the waveform output, it was concluded that the piezoelectric ceramic vibration was the strongest at 213Hz. Figure 10. System Output Waveform 6. Conclusion Small component feeders commonly used in industry use vibration at different frequencies to achieve transportation and screening. In order to drive the piezoelectric ceramics to generate high-frequency vibration, this paper chooses STM32F407 chip as the main controller, combined with DAC digital-to-analog converter module and TPA power amplifier module, to design a piezoelectric drive control system that can adjust the frequency and amplitude of the output voltage. After experimental verification, the following conclusions are obtained. (1) The circuit, signal and function of this design are realized normally, including key slow start, waveform output, smooth switching of frequency and amplitude of waveform and short circuit fault processing. The use of three chips greatly simplifies the hardware circuit and improves the control accuracy and anti-interference ability. Due to the characteristics of the main chip and the drive object, the output voltage range of the main chip is 0-3.3V, and the output frequency is 100-250Hz. (2) The program uses the DSP library to generate waveforms, releasing chip computing resources, and adding slow start variables, which can realize the voltage waveform in the shape of a trumpet with a slow start, preventing power supply oscillations or inrush currents caused by too much damage to the system after power-up. Use two arrays to switch the output waveform, so that the key to change the waveform is smooth and the switching point is in the 0V position. (3) This system piezoelectric ceramic optimal vibration 213Hz, the program design is universal, the piezoelectric ceramic single-sided capacitance used in this system is 7.5 ± 0.3nF, when applied to other places, can be set up by the timer in the program and the waveform generating function of the variables, to achieve a different range of frequency and voltage amplitude range of the adjustment, and at the same time through the change of the key parameter, to get a different step interval , which has high practical application value in driving piezoelectric ceramic vibration. 156 Acknowledgments This research was funded by Jilin Provincial Department of Education of China (JJKH20240306KJ). References [1] SHAO Yifei, KONG Fanxing, HE Tengfei, et al. Application and development of piezoelectric ceramics in precision and ultra-precision fields [J]. Chemical Automation and Instrumenta-tion, 2023,50(02):125-130+180. [2] SUN Lishu, LIN Zhiqi. Design of a new piezoelectric ceramic microdrive circuit[J]. Instrumentation User,2006(01):62-64. [3] CHENG Jixing, LIU Xia. Design of driving circuit for a microcontroller-controlled piezoelectric ceramic microdisplacer [J]. Electronic Measurement Technology, 2012, 35 (11):58-62. [4] QIN Jiacai, HAN Xiang, XIAO Guangzong, et al. A review on the research of ultrasonic transducer driving power supply[J]. Electronic Design Engineering,2020,28(09):135-139. [5] Dai Fengjing,Sui Jixiang, Huang Haibo,et al. Design and realization of ultrasonic power supply based on STM32[J]. Journal of Hubei University (Natural Science Edition):1- 9[2023-06-02]. [6] HUANG Junyuan, ZHANG Wei, JIANG Buhui. Design of high-voltage high-current piezoelectric ceramic constant- current driver circuit[J]. Manufacturing Technology and Machine Tools,2022(05):66-71. [7] Ding C. Development of DC Parameter Calibration Module for Digital Integrated Circuit Test System[C]//Journal of Physics: Conference Series. IOP Publishing, 2023, 2428(1): 012006. [8] Zhu J, Meng S, Wang Y, et al. A Novel Monopolar Cross-Scale Nanopositioning Stage Based on Dual Piezoelectric Stick-Slip Driving Principle[J]. Micromachines, 2022, 13(11): 2008. [9] Sun Qingxu, Zhu Xingbang, Li Chao, et al. Design of a piezoelectric ceramic driver circuit[J]. Science and Technology Innovation and Application,2020(34):4-7. [10] MENG Xianglian, SUN Ping, GAO Hongzhi. Principles and applications of microcontroller[M]. People's Posts and Telecommunications Press, 201509.290. [11] LIN Kaiji, ZHANG Lu. Design of WI-FI video capture and transmission system based on STM32 [J]. Journal of Jilin Institute of Chemical Technology, 2022, 39(1): 90-94.