“In practical work, the direct measurement method is generally used for manual operation of multi-channel resistance measurement. Although this method is very mature, it uses a lot of supporting equipment, manual recording of measurement data, and manual calculation, which is cumbersome and inefficient. It is time-consuming and labor-intensive to process data and issue measurement reports afterwards, and is prone to misjudgments and missed judgments caused by human factors.
In practical work, the direct measurement method is generally used for manual operation of multi-channel resistance measurement. Although this method is very mature, it uses a lot of supporting equipment, manual recording of measurement data, and manual calculation, which is cumbersome and inefficient. It is time-consuming and labor-intensive to process data and issue measurement reports afterwards, and is prone to misjudgments and missed judgments caused by human factors.
Aiming at these problems, this paper designs a resistance multi-channel measurement system based on MSP430 microcontroller. The system uses two MSP430F169 microcontrollers, and uses the I2C communication module integrated by this type of microcontroller to realize the dual microcontroller system. The use of the dual-machine structure enhances the anti-interference ability and reliability of the system, and improves the accuracy and stability of the measurement. The multi-channel resistance measurement system has the characteristics of simple structure, low cost and low power consumption, the measurement range is 10μΩ～3 kΩ, and the measurement accuracy is 0.2%. It can be used in the fields of scientific research and engineering application, and has strong practical value. The design idea and method of the system is also a beneficial attempt to the research of the dual single-chip microcomputer system, which lays a foundation for the follow-up research.
1 Introduction to multi-channel resistance measurement system
1.1 MSP430 microcontroller
The MSP430 series microcontroller is a 16-bit ultra-low power microcontroller introduced by Texas Instruments (TI). This series of single-chip microcomputers has the characteristics of strong computing power, abundant internal and external devices, low voltage, ultra-low power consumption, high speed and high efficiency. Its power supply voltage adopts a low voltage of 1.8 to 3.6 V, the power consumption is only 0.1 μA in the RAM data retention mode, 250 μA/MIPS in the active mode, and the maximum leakage current of the I/O input port is only 50 nA. The microcontroller system has one active mode and five low-power modes, and can be switched freely between the modes. It adopts vector interrupt, supports more than ten interrupt sources, and can be nested arbitrarily. It only takes 6μs to wake up C with interrupt request. With reduced instruction set and high processing speed, a large number of on-chip registers can participate in operations. There are abundant I/O interfaces, support JATG online programming and debugging. Among them, the MSP430F169 microcontroller integrates 64 KB of FLASH ROM and 2 KB of RAM. In most applications, there is no need to expand the ROM or RAM for the processor. The chip has a dual-channel serial data interface (USART module), which can Implement UART, SPI and I2C three communication modes. The USART0 serial communication module is used between the dual microcontrollers to realize the I2C master-slave communication, which can make the system communication simple and efficient.
1.2 System block diagram
This system is a multi-channel resistance measurement system based on dual MSP430F169 microcontrollers. Two MSP430F169 microcontrollers are used to coordinate the work. The slave MSP430F169 uses its own 8-way A/D channels to measure, collect, and calculate and analyze the collected data. The master MSP430F169 is responsible for storage, control, Display and coordination. Communication with the host computer. Utilize the inherent USART module of MSP430F169 single-chip microcomputer, adopt I2C bus line to carry on serial communication, realize the command control and data exchange between processors. The resistance measurement circuit uses a constant current source to measure the resistance, connects the resistance to be measured into the constant current source circuit, applies a constant current to both ends of the resistance, and forms a stable voltage drop across the resistance. Since the voltage value output at both ends of the resistor is relatively small, it is necessary to amplify the voltage through an amplifying circuit. The voltage to be measured is collected through the A/D interface that comes with the microcontroller, the corresponding resistance value is calculated by Ohm’s law, and then divided by the magnification, the resistance value of the small resistance to be measured can be obtained. The system block diagram is shown in Figure 1.
2 Design of hardware circuit
The hardware circuit of the system is mainly composed of the constant current source circuit of the slave MCU and the main MCU circuit. The main MCU circuit part mainly realizes the functions of control, display, storage, and communication with the host computer. The hardware circuit is relatively simple and will not be described in detail. The constant current source circuit of the slave microcontroller is mainly composed of a current source circuit, an amplifier circuit and a follower circuit. The following focuses on the introduction of the design of the constant current source circuit from the microcontroller.
2.1 Current source circuit design
The accuracy of the resistance measurement depends on the accuracy and stability of the constant current source and the stability of the amplifier. The current source circuit in the system in this paper is realized by the REF200 high-precision current source of BURRBROWN Company. The chip integrates two 100μA constant current sources and a mirror current source. Its biggest feature is the high current accuracy (100±0.5) μA provided. Easy to use, just add any voltage between 2.5 to 40 V on pin 7 or pin 8 of the chip. A current of 100 μA can be output on pin 1 or pin 2, respectively. It is flexible to use, and current output of 50μA, 200μA, 300 μA and 400μA can also be achieved through different connection methods. In this paper, the system needs to realize 8-way resistance measurement, so it needs to provide 8-way stable current. The system uses 4 REF200 chips, each chip provides 2 current sources of 100μA to realize 8 current outputs. The hardware circuit of each chip is shown in Fig. 2(a).
2.2 Amplifier circuit design
In order to ensure the stability of the measurement, and at the same time considering the gain of the amplifier controlled by the microcontroller to realize the change of the range, the system adopts the gain programmable instrumentation amplifier PGA204 of TI company. The biggest feature of this amplifier is that it can realize 1, 10, The selectable gain of 100 and 1 000 has a high common mode rejection ratio (115 dB, when G=1 000), the maximum input bias voltage is 50 μV, the maximum bias current is 2 nA, and the chip power consumption is low. The working voltage of the amplifier is only ±4.5 V, and the current when not working is only 5 mA. The gain control is very flexible. The pin A0 and pin A1 of the chip control the gain of the amplifier and are connected with the I/O of the slave. The corresponding gain can be obtained by inputting the corresponding high level or low level on pin A0 and pin A1. Programmable amplifier gain realizes the conversion of measurement range. The hardware connection of each amplifier circuit is shown in Figure 2(b).
2.3 Follower circuit design
In order to ensure the stability of the constant current source, a follower circuit is connected after the amplifying circuit. The follower circuit is realized by the high-speed precision operational amplifier OPA602 of TI Company. The amplifier has high precision and the bias current is only 1 pA. The specific hardware circuit is shown in Figure 2(c).
The constant current source circuit consists of a current source circuit, an amplifier circuit and a follower circuit. The current provided by the constant current source is related to the gain G of the amplifying circuit. The system selects the analog AVcc as the reference power supply with a size of 3 V. When the gain of the amplifying circuit G is 1, the maximum resistance measured by the system is 3 kΩ. The constant current source circuit has the characteristics of simple structure, high precision, strong stability and low power consumption.
3 Dual microcontrollers work together
3.1 I2C bus
The I2C bus is a simple two-way two-wire serial bus developed by Philips for internal control. The I2C bus is composed of a serial data bus (SDA) and a serial clock bus (SCL), one is used to transmit data, and the other is used to control the data transmission clock. The bus standard mode speed is 100 Kb/s, the fast mode speed can reach 400 Kb/s, the high-speed mode can reach 3.4 Mb/s, I2C can achieve 100 Kb/s speed operation under the maximum bus load, and the device The number of connections is limited only by a maximum capacitance of 400 pF. The process of data passing on the I2C bus is shown in Figure 3.
SDA and SCL are bidirectional signal lines connected to the positive supply through a pull-up resistor. Both signal lines are held high when the bus is idle. When the SCL line is at a high level and the SDA line transitions from a high level to a low level, it is a start signal; when the SCL line is at a high level and the SDA line transitions from a low level to a high level, it is a stop signal . The process of communication transmission between the start condition and the stop condition.
3.2 Topological structure of single chip microcomputer
Because the serial communication module USART0 of MSP430F169 microcontroller can be set to work in I2C mode. In the multi-channel resistance measurement system, the master and the slave perform I2C master/slave bidirectional communication through their respective serial communication modules USART0. Both the master and the slave can receive and send data, but the bus clock signal SCL, start signal, Termination signals are generated by the host. When the I2C bus is implemented, it is only necessary to connect the pin P3.1 (SDA) of the master and the slave with the pin P3.3 (SCL), and set the pin to the I2C mode, and the I2C bus must pass through two resistors Pull SDL and S of the bus high, respectively. The topology of the microcontroller is shown in Figure 4.
4 Software Design
4.1 Realization of dual-computer communication
The I2C module of the MSP430 single-chip microcomputer has four working modes: master sending, master receiving, slave sending and slave receiving. The dual-computer communication program design mainly includes four parts: initialization program, host mode program, slave mode program and interrupt service program.
The initialization procedure includes setting the one-chip computer P3.1 (SDA) and the pin P3.3 (SCL) as the transmission port, the port direction. Set the system clock, the system clock is generated by the host, and select SMCLK as the system clock. The I2C module is initialized and the control enable bit (I2CEN) of the control register U0CTL is set to 1. U0CTL is an 8-bit register. The selection of communication mode, communication protocol and parity bit is determined by the setting of this register.
The function of the host mode program is to complete the data transmission and reception in the host mode. First of all, it is necessary to initialize the reception and transmission of the host, define the address of the host, set the receiving mode to the R/W position, and set the interrupt register I2CIE to define the interrupt enable. The host receiving and sending initialization program is called every time the data is sent and received. By setting the three register bits of I2CRM, I2CSTP and I2CSTT to control data transmission and reception, the host generates clock signals, start and stop signals.
The data transceiver initialization part in the slave mode program is the same as the master mode program. It is worth noting that the data transceiver process is automatically controlled by the I2C module. When the slave receives data, it receives serial data on the bus with the clock signal generated by the master. and reply to the received data. When the slave sends data, after the slave receives the matching device address sent by the master and the data receiving request from the master, the master generates a clock pulse, and the slave sends data to the bus.
The function of the interrupt service routine is to realize the data transmission and reception between the host and the slave. The I2C module in the MSP430 is a multi-source interrupt. The interrupts of the 8 interrupt sources share an interrupt vector. The content of the interrupt vector register I2CIV determines which interrupt flag is currently causing the interrupt. event. When the interrupt with the highest priority generates the corresponding value in the register I2CIV, the interrupt source is judged and the corresponding host mode program and slave mode program are entered. Through the two program interrupt registers I2CIE enable operation, the corresponding interrupt is completed. event. So as to realize the sending and receiving of data between the master and the slave.
4.2 Data collection and processing
The data acquisition part mainly collects the voltage generated on the resistance to be measured which is connected to the constant current source circuit through the A/D channel from the single-chip microcomputer, and processes it. The A/D conversion of MSP430F169 has 4 modes: single-channel single conversion, single-channel multiple conversion, sequence channel single conversion, and sequence channel multiple conversion modes. Considering that there are 8 channels of acquisition, each channel needs to acquire 256 data for each measurement, so the sequence channel multiple conversion mode is selected. The A/D conversion circuit performs multi-channel repeated conversion through the analog channel, so that the voltage data collected and flowing through the resistance to be measured is continuously updated automatically, and the conversion results are sequentially stored in the conversion storage register. The EOS bit of the ADC12MCTLx register defines that after the last channel conversion is completed, it indicates that a sequence channel conversion is completed, and the trigger signal will trigger the next sequence channel conversion. The sampling time interval of data is controlled by timer A. Every time timer A interrupts, the data collected by A/D is read, A/D conversion is stopped before reading, and A/D collection is restarted after reading. After the collection is completed, a flag is set to notify other programs that new data has been obtained, and data interaction with other processing programs is realized through global variables. The sampling flow chart 5 is shown. In terms of data processing, in order to improve the accuracy of resistance measurement, each measurement channel collects 256 sets of data during each measurement, and the slave machine averages the 256 sets of data collected and then calculates the resistance measured by each channel. value.
4.3 System software implementation
The system software adopts a modular design, and the software sub-function program division corresponds to the hardware module circuit. The system software includes main program, dual-computer communication subprogram, data acquisition subprogram, data processing subprogram, serial communication subprogram, timer interrupt service subprogram, display subprogram, storage and key control subprogram. Due to space limitations, only the flow chart of the main program is given, as shown in Figure 6.
In this paper, the multi-channel resistance measurement system uses the I2C bus to realize the full-duplex communication between the MSP430 series single-chip microcomputers, and solves the key technology of the dual-computer communication system. Moreover, the accuracy, reliability and real-time performance of the measurement are improved, and it is also the specific practice of the research on the dual-processor system.