As a capacitive sensor with a digital gauge, it is a data processing module, the module set up a serial interface, connected with this interface and the microcontroller can extend its functionality, such as increasing some of the control functions, or The length of the module to develop their own measurement or control instruments. This module, for example to give it BJ200 caliper and 51 MCU interface circuit and the interface program.
Figure 1, the digital display module pin diagram
Figure 1 shows the relative position of the interface, a negative 1.5V; 2 for the data signal; 3 for the synchronization signal; 4 to 0V, or ground. If we do not use the battery, and using power supply, power supply voltage can be increased to 1.8 ~ 2.0V, to improve its anti-jamming capability.
Serial data is binary, the output of about 0.2 seconds once every two sets of data output, the first group, the absolute phase shift, without manual control, no sense of measure, and the second group, the relative phase shift, is a relatively phase shift in the zero position, that is, we want to collect the data. A set of data 24-bit, low front, high in the post, the last one is the sign bit. The last one is “1” indicates that the data is negative, in order to complement the output of “0” indicates that the data is positive, the original code output. If using D as the decimal representation of this data, the final displacement of the measured “l” can be expressed as follows:
Signal level conversion circuit:
Circuit shown in Figure 2. Because the module uses the negative 2V power supply, the output signal so it can be transformed, and 8051 compatible. R2, Q2, U1D and U1E transform the data signal, the output with the DATA that; R1, Q1, and U1A transformation of the synchronous signal, said output with CLK; CLK to the back of the circuit provides an interrupt signal to the microcontroller, the signal is not sent time, INT signal is low, the signal transmission period, as the R3, C1 integrator role, INT stays high, the signal transmission is completed, INT returned low, the microcontroller is set to pulse interrupt mode, detect this falling edge is transferred to the interrupt service routine, the data read from the serial port.
8051 interface circuit:
Circuit shown in Figure 3, which DATA, CLK, INT and 2, respectively, each end of the same name in port. MC14053 is a knife, double-throw analog switch 3, we selected one group; MC14557 is variable up to 64-bit shift register, shifting the median from the L1, L2, L4, L8, L16, L32 of the connection decided This then into 24-bit ((16421) 1 = 24), the output end to the 8051’s serial port.
8051 reset, P1.7 is set 0, MC14557 termination to the module clock synchronization signal CLK. Data transfer is completed, INT negative transition, the microcontroller into the interrupt service routine, the P1.7 set 1, MC14557 clock termination to the 8051 serial clock, the program three times the 24-bit data read into the microcontroller, data communication task is completed . Since then, a variety of data can be processed to achieve the job requirements.
Order and above the circuit with the program set to 0 in the first P1.7, the main program to open up external interrupts, interrupt mode is set to pulse mode. 0 8051 serial communications to read data from the MC14557, a read 8-bit, need to read 24 times.
Procedures used in the R0, R1 register, data read into the order after the first deposit at high 30H, 31H, 32H units, ie the highest bit of 30H is a sign bit.
;———— Started —————-
CLR P1.7; MC14557 clock synchronization signal receiving module
MOV IE, # 81H; open external interrupt 0
SETB IT0; interrupt set to pulse
; The following is the data reception subroutine:
MOV IE, # 00H; disabling interrupts
MOV SCON, # 00H; serial communication 0
SETB P1.7; the MC14557 CPU clock switch control
MOV R0, # 32H
MOV R1, # 03H; read data three times
L0: SETB REN; begin receiving data
JNB RI, $
MOV A, SBUF; data from the buffer RAM unit to move
MOV @ R0, A
DJNZ R1, L0
CLR P1.7; MC14557 clock switch to the CLK
In addition to this case, read the data used in serial mode, you can also use the string in and out of register, the module output serial data is converted to parallel data, read into the microcontroller.
This interface circuit has been designed for digital paper thickness, used to measure the optical elements of glass thickness. In this instrument, the author uses the data collected tolerance added to the input, the absolute / relative measurement conversion, tolerance alarm function to meet user requirements.