Home >
Microcontroller >Microcontroller Production > Interface circuit between digital measuring tool and 51 microcontroller
Interface circuit between digital measuring tool and 51 microcontroller
Source: InternetPublisher:萌面大虾 Updated: 2013/11/08
The data processing part of a digital measuring instrument that uses a capacitive grid as a sensor is a module, and a serial interface is set up on the module. By connecting this interface to a microcontroller, its functions can be expanded, such as adding certain control functions, or using This module develops own length measurement or control instruments. This article takes the BJ200 caliper module as an example to give its interface circuit and interface program with the 51 microcontroller. Pin:
Figure 1, digital display module pin diagram Figure 1 shows the relative position of the interface, 1 is negative 1.5V; 2 is the data signal; 3 is the synchronization signal; 4 is 0V, which is the ground terminal. If you do not use a battery but use a regulated power supply, you can increase the power supply voltage to 1.8~2.0V to improve its anti-interference ability. Data format: The data of the serial port is a binary code, which is output once every 0.2 seconds. Each time, two sets of data are output. The first set is the absolute phase shift, which is not subject to manual control and is meaningless for measurement. The second set is the relative phase shift. , is the phase shift relative to the zero position, which is the data we want to collect. A set of 24 bits of data, with the low bit first, the high bit last, and the last bit is the sign bit. If the last bit is "1", it means that the data is a negative number and is output in the complement code; if it is "0", it means that the data is a positive number and is output in the original code. If D is used as the decimal representation of this data, the final measured displacement "l" can be expressed as follows:
Interface with 8051: Signal level conversion circuit: See Figure 2 for the circuit. Since the module uses a negative 2V power supply, its output signal needs to be converted to be compatible with 8051. R2, Q2, U1D and U1E convert the data signal, and the output is represented by DATA; R1, Q1 and U1A convert the synchronization signal, and the output is represented by CLK; the circuit behind CLK is used to provide an interrupt signal to the microcontroller, and the signal is not transmitted When the signal is transmitted, the INT signal is low level. During the signal transmission, due to the action of the R3 and C1 integral circuits, INT remains high level. After the signal transmission is completed, INT returns to low level. The microcontroller is set to pulse interrupt mode and detects this The falling edge of the pulse switches to the interrupt service routine and reads data from the serial port.
Interface circuit with 8051: The circuit is shown in Figure 3, in which each terminal of DATA, CLK, and INT is connected to the port with the same name in Figure 2 respectively. MC14053 is a 3-pole double-throw analog switch, and we choose one of them; MC14557 is a 64-bit variable shift register. The number of shifts is determined by the connection of L1, L2, L4, L8, L16, and L32. This is connected to 24 bits ((16+4+2+1)+1=24), and its output terminal is connected to the serial port of 8051. After the 8051 is reset, P1.7 is set to 0, and the clock terminal of MC14557 is connected to the module synchronization signal CLK. After the data transfer is completed, INT generates a negative transition, the microcontroller enters the interrupt service program, sets P1.7 to 1, and the MC14557 clock terminal is connected to the serial clock of 8051. The program reads 24-bit data into the microcontroller in three times, and the data communication task is completed. . After that, the data can be processed in various ways to meet the work requirements.
Programming: In order to cooperate with the above circuit, P1.7 is first set to 0 in the program, external interrupt is enabled in the main program, and the interrupt mode is set to pulse mode. 8051 uses serial communication mode 0 to read data from MC14557. It reads 8 bits at a time and needs to read 24 bits three times. The R0 and R1 registers are used in the program. After the data is read, it is stored in units 30H, 31H, and 32H in the order of high-order bit first, that is, the highest bit of 30H is the sign bit. ;------------Start---------------- CLR P1.7 ;MC14557 clock receives module synchronization signal MOV IE, #81H ;Open external Interrupt 0 SETB IT0; Set the interrupt mode to pulse mode; The following is the data receiving subroutine: MOV IE, #00H; Disable interrupt MOV SCON, #00H; Serial communication mode 0 SETB P1.7; Convert MC14557 clock to CPU Control MOV R0, #32H MOV R1, #03H; Read data L0 in three times: SETB REN; Start receiving data JNB RI, $ MOV A, SBUF; Move data from buffer to RAM unit MOV @R0, A CLR RI DEC R0 DJNZ R1,L0 CLR P1.7;MC14557 clock is converted to CLK RET. In addition to the serial data reading method used in this example, the serial input and parallel output registers can also be used to convert the serial data output by the module into parallel data, and then Read into the microcontroller. This interface circuit has been used in the digital display thickness gauge designed by the author to measure the thickness of optical glass components. In this instrument, the author used the collected data to add functions such as tolerance input, absolute/relative measurement mode conversion, and out-of-tolerance alarms to meet user requirements.
Latest Microcontroller Circuits
- Hardware interface circuit between CH375 and single chip microcomputer
- Interface circuit between MMA1220D and microcontroller
- How to design an ESP32-based microcontroller development board
- How to use ESP8266 to design a portable air quality monitoring station
- How to use ESP32 to implement the design of air quality monitoring system
- Experiment on using 51 microcontroller to drive relay
- USB-serial port conversion circuit made with CP2102 chip
- USB to parallel port, serial port circuit diagram (ch341)
- ISP2 using real USB chip and M8
- Microcontroller test board circuit three