In the design of adaptive optical systems, the wavefront corrector has been developed as an important component of the optical system. It is combined with the wavefront sensor and the wavefront control part to enable the optical system to overcome external dynamic interference, which is difficult to achieve with traditional optical technology. Among the many types of wavefront correctors, discrete piezoelectric continuous mirror deformable mirrors are widely used due to their large deformation and no discontinuity in surface deformation. The structure of the deformable mirror consists of a substrate, a driver and a thin mirror. Several piezoelectric drivers are fixed on the substrate, and a thin optical mirror is fixed in front of the driver. When voltage is applied to the driver, the piezoelectric ceramics can produce positive or negative deformation, thereby pushing the thin mirror surface to deform, playing a role in changing the optical wavefront and correcting the wavefront error. In order to prevent the piezoelectric driver output voltage from being abnormal and causing system failure, it is necessary to timely understand the output voltage of each piezoelectric driver, and the project requires monitoring the output voltage of thousands of piezoelectric drivers, so the design of a piezoelectric driver output voltage monitoring and display system has become an urgent issue to be solved.
The main work of this design is to use the 20-channel voltage measurement module to collect the output voltage of the piezoelectric ceramic driver, transmit the voltage data to the high-speed microcontroller through the RS485 interface via the ModBus RTU communication protocol, and display the output voltage value of each piezoelectric driver in real time on the LCD screen. The block diagram of the 20-channel voltage monitoring system is shown in Figure 1.
Figure 1 Block diagram of 20-channel voltage monitoring system
1 Introduction to 20-channel voltage measurement module
1.1 Functions and features of 20-channel voltage measurement module The 20
-channel voltage measurement module is an intelligent data acquisition module that can measure 20-channel voltage signals. The input signal is DC. Its output is RS485, and the communication protocol complies with the ModBus RTU protocol. This module can be widely used in various industrial measurement and control systems. Its main functional features are as follows: It
adopts the latest electronic technology and is a digital intelligent data acquisition module with high-speed signal processor and microprocessor as the core; it can measure 20 channels of 0-500 V DC voltage signals; and the range can be selected according to needs; it is equipped with an optically isolated RS-485 communication interface and ModBus RTU communication protocol, and can effectively transmit information data with a monitoring system with a ModBus compatible protocol.
The technical indicators of the 20-channel voltage measurement module are as follows:
the measurement accuracy can reach level 0.2. When using the module for networking, the address range is 0-255, and the baud rate is optional, with a default value of 9 600 b/s.
Working conditions: temperature range is -30~70℃, humidity range is 10%~90%RH; storage conditions: temperature range is -40~80℃, humidity range is 10%~90%RH.
1.2 ModBus communication protocol
Among various system communications, Modbus protocol is a truly open and standard network communication protocol widely used in the industrial field. Through this protocol, communication can be achieved between controllers and between controllers and other devices. Since the 20-way voltage measurement module used in the design adopts the ModBus communication protocol, the single-chip microcomputer as the host should also adopt this protocol to achieve communication between the host and the slave. Before programming to implement the host function, it is necessary to understand the protocol specification. The
host query information includes the slave device address, function code, all data to be sent, and error checking. The slave response information includes the domain to confirm the action to be taken, any data to be returned, and error checking.
The communication mode between the host and the slave conforms to the query-response mode. The function code in the query message sent by the host tells the slave what function to perform. The data segment contains additional information about the function to be performed by the slave and the starting address and number of registers. Error checking provides a way for the slave to verify whether the message content is correct. The response of the slave is based on the premise that there is no error in the read instruction. The function code in the response message is the response to the query message, and the data segment contains the data collected by the slave. If an error occurs in the intermediate process, the function code will be modified, and the data segment contains a code describing the error information. Error checking allows the host to confirm whether the message is available.
1.3 Networking of 20-channel voltage measurement module
Because the output of the 20-channel voltage measurement module is standard RS485, the 20-channel voltage measurement module with RS485 as the interface can be networked. Usually, the maximum number of RS485 network nodes is 32. The repeater can improve the load capacity of the RS485 interface, and can reach the ability to drive 256 modules at most. Therefore, multiple 20-channel voltage measurement modules can be networked to meet the needs of real-time monitoring of hundreds or even thousands of voltages, and finally meet the requirements of monitoring and displaying the output voltage of multiple piezoelectric drivers.
2 System Part Hardware Design
2.1 RS485 Communication Interface
Since the 20-channel voltage measurement module supports RS485 serial communication, in order to realize the data communication between the single-chip microcomputer and the voltage measurement module, an RS485 communication interface must be designed. The host can transmit the query information to the slave through the RS485 interface, and the slave can respond to the collected real-time voltage data to the host. The RS485 signal transceiver dedicated chip MAX485 is used to realize signal conversion. When designing the circuit, the level correspondence between the in-phase and inverting ends of the MAX485 chip should be fully considered. Since the slave responds to the initial bit of the data frame - low level, the host generates a receiving interrupt. Therefore, only when the initial level of the in-phase terminal A of the MAX485 chip is greater than the initial level of the inverting terminal B, can it be guaranteed that when the main controller microcontroller turns on the receiving interrupt, no false interrupt will be generated, resulting in the receipt of the wrong data frame. The RS485 interface circuit schematic is shown in Figure 2.
Figure 2 Schematic diagram of RS485 interface circuit
2.2 LCD liquid crystal display module
LCD liquid crystal display module-LM320160CCW is a 320x160 full-graphic dot matrix liquid crystal display module. The module supports parallel port communication, built-in boost circuit, and 5 V power supply; the module display is controlled by the built-in main control chip S1D13700, with high reliability, simple instructions, and easy operation; in addition, the liquid crystal module uses high-brightness LED backlight to achieve excellent contrast display, blue background white text or white background black text, and the display effect is optional. The above characteristics of the liquid crystal module are suitable for the C8051F120 main controller selected in this design, and the LCD liquid crystal display range can also meet the needs of information display in this design. For the liquid crystal display module with built-in control chip, when designing the circuit, it is convenient to use it by simply distinguishing the control circuit signal of the liquid crystal. Since the LM320160CCW liquid crystal module is equipped with a liquid crystal control unit, it is not necessary to add more control chips in the interface circuit design to realize the display of graphics or characters.
2.3 LCD and controller interface circuit design
In the interface circuit design, since the LM320160CCW LCD display module is powered by 5 V, and the microcontroller is powered by 3.3 V, they cannot be simply connected to each other, and level processing is required. In this design, 741S245 is selected as the bus driver, and a 5 V pull-up resistor is added to the microcontroller pin to ensure the signal driving ability. The interface circuit schematic is shown in Figure 3, where P3 and P7 are the I/O ports of the microcontroller, and RV1 is an adjustable resistor used to adjust the backlight contrast of the LCD module.
Figure 3 LCD interface circuit schematic
3 System software design
After the system is powered on and reset, the LCD module needs three steps: system initialization, writing instruction codes, and writing data to work properly. In the process of writing instructions and data, attention should be paid to the timing problem. If the timing is too short, the instructions and data cannot be written correctly into the LCD module, resulting in the inability to display information or a distorted screen. Since the main controller microcontroller is programmed in C language, both the microcontroller program and the LCD module display program are highly portable and operable.
3.1 Writing instructions and data to
the LCD module Before the LCD module works normally, the module is initialized first. Writing the system setting command will cause the LCD module to exit the power mode and start the internal clock of the module. After a certain delay, the internal state of the LCD module will be initialized. Then set the display mode of the LCD module, including turning on the display, setting the cursor, setting the graphics mode, etc. The writing of all instructions can be implemented through public instruction functions. The instruction writing program is as follows:
The LCD320160CCW display data writing program includes data information such as screen clearing, graphical interface, symbols and Chinese characters. The writing of data is based on the correct writing of instructions. Because the LCD module is a graphic dot matrix, the display information can be converted into a corresponding dot matrix array. When the information needs to be displayed, just call the dot matrix array. The data writing program is as follows:
3.2 Controller main program design
Figure 4 is the flow chart of the microcontroller main program. After the system and LCD are initialized, the host calculates the error check CRC code of the query information and attaches it to the end of the sent information, with the low byte in front and the high byte in the back; the query information is sent regularly through timer 2. Since the set UAWT baud rate is 9600 b/s, the number of bytes of the query information is 8, and the number of bytes of the correct response information from the slave is 35. Then the total number of bytes in the sending and receiving process is 43, and the time required is T=43x8x1 s/9600x1000=35.8 ms, so the time of timer 2 is determined to be 50 ms. Except for the sending and receiving time in a timing interval, the rest of the time is used for LCD display. Since the voltage change rate of the piezoelectric driver is relatively large compared to the timing frequency of the timer, it can be considered that the monitoring and display have good real-time performance, and arranging task scheduling in this order in the program can meet the real-time requirements in actual projects.
Figure 4 MCU main program flow chart
4 Conclusion
This paper introduces the 20-channel voltage measurement module and ModBus protocol, and builds a hardware connection based on the high-speed microcontroller C8051F120. By writing the controller program, the data communication between the microcontroller and the voltage measurement module and the real-time display of the voltage on the LCD are realized. The practical results show that the design has a simple hardware structure, stable and reliable operation, and a short development cycle. It meets the needs of real-time monitoring and display of the output voltage values of each piezoelectric driver in the adaptive optical system. The specific object is shown in Figure 5.
Figure 5 Voltage monitoring and real-time display system