Embedded Handheld Data Acquisition System Based on MSP430 MCU

The successful application of uC/OS in the handheld data acquisition system explores a new way for the design of the handheld device software system. Using uC/OS to design embedded software overcomes the drawbacks of the traditional front and rear desktop software design methods, improves the real-time performance and stability of the system, makes the software system code modular, and further enhances the system’s ability to upgrade and expand. In the future, the application field of uC/OS will become more extensive in embedded system software design.

Introduction: The successful application of uC/OS in the handheld data acquisition system explores a new way for the design of the handheld device software system. Using uC/OS to design embedded software overcomes the drawbacks of the traditional front and rear desktop software design methods, improves the real-time performance and stability of the system, makes the software system code modular, and further enhances the system’s ability to upgrade and expand. In the future, the application field of uC/OS will become more extensive in embedded system software design.

This data acquisition system is mainly designed by using TI’s MSP430 microcontroller and embedded system uC/OS. The successful application of uC/OS in the handheld data acquisition system explores a new way for the design of the handheld device software system. Using uC/OS to design embedded software overcomes the drawbacks of the traditional front and rear desktop software design methods, improves the real-time performance and stability of the system, makes the software system code modular, and further enhances the system’s ability to upgrade and expand. In the future, the application field of uC/OS will become more extensive in embedded system software design. The multitasking software design method of uC/OS replaces the traditional embedded software design method of front and rear desktops, which makes the software system modular, overcomes the drawbacks of front and rear desktop software design, and increases the real-time performance of the system.

1 Introduction

In recent years, with the continuous reduction of power consumption and volume of IC devices, the application fields of handheld devices have become more and more extensive. But on the other hand, the traditional front and back desktop software design method restricts the full play of the hardware system functions and affects the real-time and stability of the system. This paper introduces a method of designing system software based on the embedded operating system uC/OS, which not only overcomes some disadvantages of the original front and back desktop software design, but also fully utilizes the hardware characteristics, enhances the system stability, and solves the problem well. This solves the problem that the multi-task software system of the handheld data acquisition equipment is not very real-time.

2) Introduction to uC/OS

uC/OS is an embedded operating system developed by EAN J.LABROSSE personally. The system is a real-time kernel whose source code is completely open. Designers can cut and expand the kernel according to their own needs in the application process, so as to meet the requirements of different projects for application software design. uC/OS is a completely preemptive real-time kernel that supports multitasking operations, and each task has its own separate stack, which clarifies the boundaries between tasks and enhances the stability of the system. uC/OS also provides a lot of system services, such as mailboxes, message queues, semaphores, application and release of memory with fixed block size, time functions, etc., and also supports up to 255 levels of interrupt nesting. Using these system services can easily complete complex logic requirements, thereby shortening the system development cycle and reducing development costs. At the same time, the good expansibility and portability of uC/OS enables it to be widely applied to microprocessors of various architectures.

3) Hardware system design

3.1 Hardware system design requirements

The hardware design of the handheld data device has some special requirements. First, the handheld system is generally powered by its own battery, and the requirements for the power consumption of the hardware device are very strict. In addition, the handheld device also needs to have a good human-computer interaction function. On the one hand, it must be able to Display the changes of various data, and on the other hand, it must also be able to respond to external human commands. Considering these factors, the system selects TI’s MSP430 microcontroller as the core platform of hardware design.

3.2 MSP430 Hardware Introduction

MSP430 is a 16-bit series of single-chip microcomputers introduced by TI company in recent years. It adopts the latest low-power consumption technology of TI company, making it unique among many single-chip microcomputers. MSP430 works under the voltage of 1.8~3.6V, and has normal working mode (AM) and 4 low-power working modes (LPM1, LPM2, LPM3, LPM4). When the power supply voltage is 3V, the working current of each mode is :

AM: 340uA
LPM1: 70uA
LPM2: 17uA
LPM3: 2uA
LPM4: 0.1uA

The microcontroller can easily switch between various operating modes. MSP430 also has a very high level of integration, a single chip integrates multi-channel 12bit A/D conversion, on-chip precision comparators, multiple timers with PWM function, sloped-edge A/D conversion, on-chip USART, gatekeeper Dog timer, on-chip digitally controlled oscillator (DCO), a large number of I/O ports and large-capacity on-chip memory, a single chip can meet the needs of most applications, saving a lot of board space. In this design, MSP430F149 is selected as the hardware design platform, and its various power consumption modes are completely suitable for the design of low power consumption requirements, and the rich on-chip resources can also meet the development of the interactive interface. More importantly, its up to 60KB flash memory and 2KB RAM provide sufficient space for uC/OS porting and stable operation.

3.3 Hardware Structure of Handheld Data Acquisition System

For this design, a complete handheld data acquisition system also needs to have the following hardware modules:

1) A/D conversion module, built-in sensor on board, reserved analog signal input interface.
2) DS1302 external real-time clock.
3) Two RS232 serial ports are used to communicate with the host computer and other devices.

The overall hardware diagram is as follows:

Embedded Handheld Data Acquisition System Based on MSP430 MCU
FIGURE 1: SYSTEM HARDWARE BLOCK DIAGRAM

4) Software system design

4.1 Disadvantages of front-end and back-end software design methods

The design of general embedded software systems adopts the design method of front and back desktops. The foreground program is an infinite loop, and the loop calls the corresponding functions in turn to complete the corresponding operations. The background is the interrupt service program, which is responsible for processing asynchronous events. This design method has three drawbacks in practical application:

First, the interruption cannot be responded to in time, the processing time is too long, and the real-time requirements of the system cannot be guaranteed.

Second, when the system has many tasks, the conventional method to realize the real-time operation of multiple tasks is to use multi-level nesting to realize the parallel processing of multiple tasks, which increases the difficulty of software writing and reduces the reliability of the software system.

Third, it is difficult to exchange information between tasks. When multitasking is running, synchronization and mutual exclusion between tasks are inevitable. The front-end and back-end design methods generally use global variables to solve communication problems, but when there are many tasks and complex situations, it is easy to make mistakes, and deadlock will occur if the call is improper.

The data acquisition system designed in the project is a typical multi-task system, and it needs to be able to respond to multiple external signals. The traditional front and rear desktop software design methods can no longer meet the needs of the project. Therefore, uC/OS is introduced in the design, using A multitasking approach to software design.

4.2 Software Design Based on uC/OS

To design a software system using uC/OS, the first thing to do is to implement the transplantation of uC/OS on the hardware application platform, mainly to complete the rewriting of several processor-related files such as OS_CPU_C.C, OS_CPU_A.ASM, etc. According to the requirements of the environment, the selected compiler must be able to support function overloading. This design selects IAR for MSP430 1.26A from IAR. In addition, in this design, the author modified the idle task into the following form.

void OSTaskIdleHook (void)
{
LPM3; /* Enter low power mode
}

In this way, when the system enters the idle state, it will enter the low power consumption mode LPM3, so as to give full play to the low power consumption of the hardware, which also reflects the flexibility of the uC/OS application.

After the transplantation is completed, the system tasks should be divided reasonably according to the project requirements, and the communication mechanism between the tasks and each interrupt signal should be determined. In the design, we divide the whole system into the following parts:

Task 1 Data collection and display
Task 2 Serial Communication
Task 3 DS1302 real-time clock setting

External interrupts: Multiple external keyboards trigger interrupts to wake up different system tasks.

Timer interrupt: a timerA interrupt, used to display the system time.

Embedded Handheld Data Acquisition System Based on MSP430 MCU
Figure 2 System software flow chart

The function of task 1 is to collect external analog input signals, display the collected data on the LCD after a certain filtering algorithm and conversion processing, and save the data into an array. This task is the highest priority task of the system and is controlled by mailboxes CltMbox1 and CltMbox2. When the task starts, wait for the mailboxes CltMbox1 or CltMbox2. If there is no mailbox release, the system will go to task 2 for execution. If there is an external keyboard trigger signal for data acquisition, when the key press time exceeds 1s, the mailbox CltMbox2 is released, and the system starts to execute task 1 cyclically, until the external stop interrupt signal hangs up CltMbox2. If the key press time is less than 1s, the mailbox CltMbox1 will be released. After the task 1 is executed 10 times, the mailbox CltMbox1 will be released, and then it will enter the waiting state until it is triggered by an external signal again. Task 1 must suspend itself for 1s after each execution. This provides time for the execution of other tasks. On the other hand, it also takes into account the actual resolution of the human eye. Too fast LCD refresh rate is meaningless. .

Task 2 realizes the serial communication function, which is mainly used to complete the data exchange between the handheld device and the upper computer, and its execution is also controlled by the trigger signal of the external keyboard. When the send button is triggered, a mailbox SMbox will be released. After task 2 gets the mailbox, the collected data will be sent to the host computer. If you need to modify the parameters of the software filtering algorithm or conversion formula, you must trigger the keyboard to receive key, task 2 will receive the data from the host computer after getting the corresponding mailbox RMbox, and change the corresponding parameters.

Task 3 is the setting task of the external real-time clock, and it has the lowest priority among the three system tasks. In the traditional front-end and back-end software design methods, if this task is placed in the foreground system, a lot of time-consuming will reduce the real-time performance of the system, so that other interrupt tasks cannot be responded in time. If it is placed in the background for processing , calling a program that is too large in an interrupt will reduce the stability of the system, but this problem is well solved in the uC/OS multitasking architecture. As the lowest priority task of the system, any high-priority task in the ready state can interrupt the setting of the external real-time clock. When other higher-priority tasks are completed, the setting process will be in the original interrupted place. Go ahead. In the process of setting the external real-time clock, if a data acquisition trigger signal is generated, task 1 will enter the ready state, but because the process of data acquisition is very fast, when task 1 hangs for 1s, task 3 will get the system’s data again. The right to control gives us the feeling that the data collection and display of the system are completed while setting the external clock, so that the time-sharing operation function provided by uC/OS is used to solve the real-time nature of the system. problem and enhance the stability of the system.

Time display is the most called task in the system. Considering the power consumption of the system, the time display task is placed in the interrupt of TimerA to complete the design. Triggering through the external keyboard will turn on the interrupt enable of TmerA, and the LCD will start to display the time of the external real-time clock. The interrupt enable of TimerA can also be turned off through keyboard control, so that when no task is ready, the system will enter an idle task, thereby further reducing the power consumption of the system.

4.3 System upgrade and expansion

In order to meet the requirements of remote data acquisition and processing, this system can be used in conjunction with GSM MODEM to achieve the function of remote wireless data transmission. The data acquisition system communicates with the GSM MODEM through RS232, and transmits the data to be sent to the GSM MODEM, and then sends it to the remote data acquisition station through the GSM MODEM. The software modification to add this function is very simple, just add this function as an independent task to uC/OS, and complete the call of the task through the keyboard trigger, without the need to modify the logic of the entire software system, which also It reflects the advantages of uC/OS modular software design. It should be noted that the initialization process of GSM MODEM takes a long time. Try not to switch tasks during this process, which will cause the failure of the entire sending process. The effective method is to treat the GSM transmission as the task of the lowest priority, and then call the task after no other task is triggered.

5 Conclusion

The successful application of uC/OS in the handheld data acquisition system explores a new way for the design of the handheld device software system. Using uC/OS to design embedded software overcomes the drawbacks of the traditional front and rear desktop software design methods, improves the real-time performance and stability of the system, makes the software system code modular, and further enhances the system’s ability to upgrade and expand. In the future, the application field of uC/OS will become more extensive in embedded system software design.

6) References

[1] Jean J.Labrosse, translated by Shao Beibei. Embedded real-time operating system μC/OS-Ⅱ (2nd edition). Beijing University of Aeronautics and Astronautics Press 2002.3.

[2] Wei Xiaolong edited. MSP430 series microcontroller interface technology and system design example. Beijing: Beijing University of Aeronautics and Astronautics Press 2002 Hu Dake editor. MSP430 series microcontroller C language programming and development. Beijing: Beijing University of Aeronautics and Astronautics Press 2002 IAR Company, MSP430 Windows WorkBench, TEXAS INSTRUMENTS. 1999 72~83

The Links:   1MBI100L-060 NL10276AC30-06