Onboard temperature network acquisition based on Linux/Qtopia

introduction
This paper implements a part of the vehicle information collection system on the embedded Linux platform—the data collection of the vehicle's normal temperature, such as collecting the temperature inside the car, the temperature of the hurricane or air conditioner, the temperature outside the car, the temperature of the water tank, and so on. The DSl8820 is a network-configurable single-bus digital temperature sensor that provides a cost-effective solution for information acquisition. Embedded Linux has become a system platform widely used in in-vehicle devices due to its excellent open source code, easy customization and expansion, multi-hardware platform support and built-in network functions. The system involved in this article uses Samsung's S3C2410AL-20 processor, the operating system uses 2.6.8.1 kernel Linux, and the GUI uses Trolltech's Qtopia; the main functions are: collection and display of temperature, audio alarm, temperature Data storage, related function settings, etc. When a voice prompt or alarm is required, the application calls the voice module; when it is necessary to store or display historical data, the application calls the SD storage module.

1 Linux system development overview Driver development is one of the main tasks of embedded Linux development. The device driver provides the device interface for the upper-layer application to control the hardware, while directly dealing with the Linux kernel. Figure 1 depicts the Linux system development framework.

This article refers to the address: http://

Application development is another major task in embedded Linux development. Qt/Embedded is a Qt version for embedded systems developed by the famous Qt library developer Trolltech. Based on the Qt/Em-bedded library, Qtopia is an open source application package and development library for mobile devices and handheld devices running embedded Linux such as PDA and Smart-Phone. It includes a full set of personal information management PIM (Personal Information Management), such as address book, schedule, MPEG playback, image display, browser and so on.

2 Overview of vehicle information system and hardware platform The development of vehicle information acquisition system mainly includes user interface development, kernel development, audio module design, serial port module design, CAN bus module design, vehicle status (including switching quantity, analog quantity, digital quantity, etc.) Detection module design, etc.
This design focuses on data acquisition for one-wire temperature networks. The temperature signal characteristics of the one-wire temperature network are: the value is not high, mostly in the range of 0-100 °C; the temperature signal changes slowly; the system does not require high-time real-time performance of the collected temperature signal; the accuracy requirement is not high.
The advantage of a first-line network is that it can measure a large amount of physical quantities, all of which pass through a one-line protocol, regardless of the specific amount being measured. The first-line network is a network that can easily set up a series of measurement environment parameters composed of one-line sensor chips.
The DSl8B20 is a networkable single-bus digital temperature sensor with the following features:
1 Adapt to a wide voltage range (3.O ~ 5.5 V), which can be powered by the data line in the parasitic power mode.
2 unique single-line interface mode, DSl8820 only needs 1 port line when connecting with the microprocessor to realize two-way communication between the microprocessor and DSl8820.
3 The temperature range is from 55 to +125 ° C, and the accuracy is ± 0.5 ° C at 10 to +85 ° C.
4 programmable resolution is 9 ~ 12 bits, the corresponding resolvable temperature is 0.5 ° C, O. 25 ° C, O. 125 ° C and 0.062 5 ° C, can achieve higher precision temperature measurement.
A single bus makes hardware overhead extremely small, but requires relatively complex software to compensate. Because the DSl8B20 uses single-bus serial data transfer, ensuring strict read and write timing becomes the key to temperature measurement, so I/O drive is not used, but a one-wire temperature network drive is written separately.
This design uses a parasitic power connection with 12-bit resolution. The advantages of parasitic Power Supply are: remote temperature detection does not require a local power supply; ROM can also be read in the absence of normal power conditions. To ensure that the DSl8820 receives sufficient supply current during its active conversion period, a strong pull-up is provided through the MOSFET on the I/O line (as shown in Figure 2). When using parasitic power mode, the VDD pin must be tied to ground.
The system core controller S3C2410X is Samsung's ARM920T core based chip. The S3C2410X integrates an LCD controller (supports STN and TFT LCD screens with touch screen), SDRAM, touch screen, USB, SPI, SD and MMC controllers, 4 PWM-enabled timers and 1 internal clock. , 8-channel 10-bit ADC, 117-bit general purpose I/O port and 24-bit external interrupt source, 8-channel 10-bit AD controller, processor operating frequency up to 203 MHz. The system displays a TFT_LCD LCD with a SHARP 3.5 in. The system block diagram is shown in Figure 2.

3 Drive Implementation This section will implement the drive module for a one-wire temperature sensor network. The driver is generally divided into two parts: the driver and kernel interface layer, and the hardware device interface layer.
3.1 Driver and Kernel Interface Layer Driver and kernel interface layer mainly completes the registration loading and unloading of the driver module in the Linux kernel. This part of the work is done by the initialization and exit functions, respectively.

1 initialization function completes the driver module loading:


3.2 Hardware Device Interface Layer Hardware Device The interface layer is used to describe the interaction between the driver and the device. This work is done through the interface between the virtual file system and the device driver. This interface is defined by the file_operation structure, which has the following structure:


3.2.2 Read Interface Function The user program may have no data to read when performing a read operation. In this case, the read operation needs to wait until there is data to be read. Here, the wait queue is used to make the process wait for no data to be read, and wake up when the data arrives. The wait queue is set to a circular buffer, each time a new data is placed as the head of the buffer, and the data that has been stored for the longest time has not been taken is the end of the buffer.


3.2.3 fasync Asynchronous Notification Function The asynchronous notification function sends a SIGIO signal to the process to notify the process of accessing the device, indicating that the device is ready for I/O reading and writing, avoiding active query and improving program efficiency. Add a struct to use asynchronous notification


3.2.4 poll system call operation interface function When the program needs to read and write to multiple files, if a file is not ready, the system will be in the state of read and write blocking, affecting the reading and writing of other files. To avoid read and write blocking, use the poll function. If the device reads without blocking, it returns POLLIN; the usual data is ready to be read and returns to POLRRDNORM.


The write interface function is used to notify the driver. For example, the notification driver reads the data of channel 2, and executes the write interface function write(fileno, &SLOT2, 1) in the application, and the driver sets the current read channel number to 2.
This completes the driver interface function. This driver is a character device driver and places the source program in the driver/ehar directory. Also need to modify the Kconfig configuration file in this directory and add Config 18820_S3C2410 option, modify driver / char / Makefile, add obj a $ (CC) NFIG_18B20 S3C2410) + = S3C2410_18820. O. Finally reconfigure the kernel and add the driver to the kernel as a module so that you can compile the driver.

4 Qtopia application design (1) create the project first use the QT Designer designer to create a form application ThermometerFigure. Ui. After the form program is created, add form controls, slot functions, signals, etc. as needed. Figure 3 is a block diagram of the implementation of the Thermometer Figure class.

(2) The Thermometer Figure class implementation uses the uic tool to generate the corresponding *. Cpp and *. h file (implementation file and header file of the form class). edit*. Cpp and *. The h file implements the connection of each member function and signal slot. The specific implementation is shown in Figure 3.
(3) create main and initialize first create main. Cpp file, and in main. Create a QApplication object in cpp. The QApplication class is responsible for the control flow and main settings of the image user interface application, processing and scheduling all events from the system and other source files; and including the initialization and termination of the application.


Execute the qmake command to generate the Makefile. Set the relevant environment variables, compiler paths, etc. before execution.
Qmake-o Makefile Thermometer.pro
(5) Compile the link project to execute the make command, which will generate the target binary file Thermometer, which can be run on the device.

(6) Publish the executable file to the Linux system, add the executable file to Qtopia's root file system, and burn the generated new root file system to the Flash root file system area of ​​the device, so that the program can be run on the desktop. It is. Figure 4 shows the implementation of the Thermometer Figure class.

Conclusion <br> This article describes some of the implementation methods of in-vehicle information system development. The development process of Linux is described by examples, including driver development and application development process. The innovation lies in the introduction of the first-line sensor network into the vehicle information collection system, which greatly simplifies the line structure and has high practical value.

CNC Tools

Insert Holder,Turning Tool,CNC Insert

Single Output Switching Power Supply,LED Power Supply Co., Ltd. , http://www.nbpowersupply.com