Analysis of the application of MSP430 microcontroller in flow detection

Publisher:美梦小狮子Latest update time:2013-08-06 Source: dzsc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
0 Introduction

  For traditional flow detection systems, most of them use electromagnetic sensors, which are easily affected by external magnetic fields and lead to incorrect flow measurement. MSP430 microcontroller, as an ultra-low power 16-bit mixed signal processor, has been increasingly widely used in flow detection. Therefore, this paper focuses on the design of flow detector based on MSP430 microcontroller.

  1. Analysis of the working principle of the flow detector based on MSP430 microcontroller

  Taking into account the low power consumption and other characteristics of the flow meter, the controller selected is MSP430F149. Specifically, the working principle of this flow meter is as follows: when the liquid passes through the flow meter, the rotating disk inside the detector rotates, so the magnet set on the rotating disk will trigger the sensor and cause it to send out an extremely weak electrical signal. After amplifying and filtering the signal step by step, the signal enters the CPU of the detector through the output, and the CPU counter inputs it. Then the system periodically reads the number of pulses, and calculates the flow rate with the help of corresponding software. After processing, it forms the so-called differential signal, which is transmitted to the display in the form of pulses for display, so that its parameters and flow information can be input/output through the I/O interface of MSP430F149.

  2. Design and analysis of flow detector based on MSP430 microcontroller

  2.1 Circuit Design

  The controller of the flow detector uses the MSP430149 single-chip microcomputer produced by TI. By designing several main functional modules of the flow detector, the specific structure of the system is shown in Figure 1.

  1) Temperature detection module, this module mainly includes temperature sensor and differential amplifier. This module transmits the signal to the differential amplifier through the temperature sensor. After amplification, the signal is input into MSP430F149, and the information and data are processed and saved through the A/D conversion port of the microcontroller. The temperature sensor used in this system has a thermal resistor of PT100.

  2) Flow detection module, this module includes flow sensor and shaping circuit. When a certain amount of liquid passes through the sensor, the sensor will generate pulses. In this way, the flow rate can be calculated by the number of pulses obtained. The flow sensor used in the system is the WG series Wiegand sensor. Its principle is as follows: the alloy material in the sensor has a magnetic bistable function. When excited by an external magnetic field, its magnetization direction will instantly flip and generate an electrical signal in the detection coil, thereby realizing the conversion between magnetism and electricity.

  3) Communication module, this module mainly includes NRF-401 wireless communication circuit and RS485 communication interface. For RS485 interface, the chip used is SN75LBC184 produced by TI, which uses a single power supply VCC, can work normally within the voltage range of 3-5.5V, and can effectively realize the conversion between TTL and 485.

  For the wireless serial interface circuit, it uses the NRF401 wireless communication chip and applies FSK modulation and demodulation technology, so the maximum rate during operation can reach 20kb/s. In addition, the transmission power can also be adjusted, and the maximum power during transmission is +10dBm.[page]

  4) For the LCD display module, its main function is to display the current liquid flow rate.

  2.2 Software Design

  2.2.1 Module design

  For the flow meter, the execution of some programs in its design process needs to be scheduled by actual time. To realize this mechanism, it is necessary to use TIMER-A and TIMER-B in the MSP430 microcontroller. According to the design of this system, the timer needs to interrupt once per second under the condition of 32768Hz, so the following settings need to be made for TIMER-B:

    Define the clock source as ACLK; TBCTL=TBSSEL0+TBCLR

  Enable interrupt timer; TBCCTL0=CCIE

  Set the timer to 1s; TBCCR0=0X7FFF

  The timer works in the up-counting mode;

  TBCTL1=MC0

  In this way, the interrupt service program of the timer 1s can be realized, and the corresponding timer is designed in this program to perform timing related operations. The system uses thermal resistor PT100. Since the MSP430 microcontroller has an ADC12 module, the collected temperature can be converted through A/D. In order to process the temperature and other analog quantities in real time, the system adopts the serial channel multiple conversion mode. After the conversion is completed, the result will be stored in ADC12MEM.

  As for the system software, it includes two parts of software, the upper layer and the lower layer module. After receiving the command from the center, the upper layer can send commands to the lower layer by means of radio frequency wireless communication and perform timing. If there is no data returned from the lower layer, the upper layer will resend the command once the timeout expires. If there is still no data returned for more than 3 times, it will be considered that the lower layer is abnormal and submit an abnormal signal to the center. Since the MSP430 microcontroller has only one serial port, the upper and lower modules require 2 serial ports, and the second serial port needs to be realized with the help of the capture/compare function of timer A.

  2.2.2 Wireless Communication Protocol

  The communication protocol of the system includes three layers: the first is the physical layer, which is mainly implemented by the NRF401 module; the second is the data link layer, which is mainly responsible for providing wireless data transmission; the third is the application layer. When sending data, the longer data frames transmitted by this layer need to be split, and the packet header and checksum are performed, and then repackaged and sent.

  Since NRF401 is extremely sensitive, if there is no data transmission, there will be noise output on its data output pin, and such noise will be received and processed by the MCU serial port. Four bytes of 0×CC plus one byte of 0×F0 can ensure the synchronization of communication between the two parties before the data frame arrives. The system protocol uses a two-byte frame header, that is, two 0×55s. After adding the start and stop bits, the actual data sent in the process will be 0101010101, so it can effectively ensure that the data is confirmed. In addition, since the checksum is after ten bytes of data, the use of 16-bit crc check can ensure the accuracy of the data transmission process. At this time, the receiver will compare the crc and checksum. If they are different, it means that an error occurred in the transmission process. At this time, the receiver will record the error frame number. After all data is sent, the error number can be returned and resending is required.

  If all data is received normally, it will be confirmed that it was sent correctly.

  3. Conclusion

  The MSP430 microcontroller is widely used in flow detection due to its ultra-low power consumption and other characteristics.

  Through the design of the flow meter based on the MSP430 microcontroller, the accuracy problem in the traditional flow detection process and the shortened life of the detector due to the influence of liquid have been fundamentally solved. Therefore, it has a very good development prospect in flow detection.

Reference address:Analysis of the application of MSP430 microcontroller in flow detection

Previous article:Design of portable weather instrument based on MSP430 microcontroller
Next article:Design of serial port communication between MSP430 microcontroller and PC based on VB6.0

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号