This paper implements a part of the vehicle information collection system on the embedded Linux platform - data collection of the normal temperature of the car, such as the temperature inside the car, the temperature of the heater or air conditioner, the temperature outside the car, the temperature of the water tank, etc. DS18B20 is a networkable single-bus digital temperature sensor, which provides an economical and effective solution for information collection. Embedded Linux has gradually become a widely used system platform for vehicle-mounted equipment with its excellent performance such as open source code, easy customization and expansion, support for multiple hardware platforms and built-in network functions. The system involved in this paper uses Samsung's S3C2410AL20 processor, the operating system uses the 2.6.8.1 kernel Linux, and the GUI uses Trolltech's Qtopia; the main functions are: the collection and display of various temperatures, audio alarms, storage of temperature data, and related function settings. When voice prompts or alarms are required, the application calls the voice module; when historical data needs to be stored or displayed, the application calls the SD storage module.
1 Overview of Linux system development
The development of drivers is one of the main tasks of embedded Linux development. The device driver provides the upper-level application with a device interface to control the hardware, and directly interacts with the Linux kernel. Figure 1 describes the Linux system development framework.
Figure 1 Linux system development framework
Application development is another major task of embedded Linux development. Qt/Embedded is a Qt version for embedded systems developed by Trolltech, a well-known Qt library developer. Qtopia is an open source application package and development library developed on the basis of Qt/Embedded library specifically for mobile devices and handheld devices such as PDA and SmartPhone running embedded Linux. It includes a full set of personal information management PIM (Personal Information Management), such as address book, schedule, MPEG playback, image display, browser, etc.
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 switch quantity, analog quantity, digital quantity, etc.) detection module design, etc.
This design focuses on the data acquisition of the one-line temperature network. The characteristics of the temperature signal of the one-wire temperature network are: the value is not high, mostly in the range of 0"100 ℃; the temperature signal changes slowly; the system does not have high requirements for the real-time performance of the collected temperature signal; the accuracy requirement is not high.
The advantage of the one-wire network is that it can measure a large number of physical quantities, and all communications are carried out through the one-wire protocol, regardless of the specific quantity being measured. The one-wire network is a network that can easily build a series of environmental parameter measurement networks composed of one-wire sensor chips.
DS18B20 is a networkable single-bus digital temperature sensor with the following functional characteristics:
① It adapts to a wide voltage range (3.0~5.5 V) and can be powered by the data line in parasitic power mode.
② The unique single-wire interface mode, DS18B20 only needs one port line when connected to the microprocessor to realize two-way communication between the microprocessor and DS18B20.
③ The temperature range is -55~+125 ℃, and the accuracy is ±0.5 ℃ at -10~+85 ℃.
④ The programmable resolution is 9~12 bits, and the corresponding resolvable temperatures are 0.5 ℃, 0.25 ℃, 0.125 ℃ and 0.062 5 ℃, which can achieve high-precision temperature measurement.
The single bus makes the hardware overhead extremely small, but relatively complex software is required for compensation. Since DS18B20 uses a single bus serial data transmission, ensuring strict read and write timing becomes the key to temperature measurement. Therefore, I/O driver is not used, but a single-wire temperature network driver is written separately.
This design uses a parasitic power connection method with 12-bit resolution. The advantages of parasitic power are: remote temperature detection does not require a local power supply; ROM can also be read under normal power supply conditions. To ensure that DS18B20 obtains sufficient power supply current during its effective conversion period, a strong pull-up is provided on the I/O line through MOSFET (as shown in Figure 2). When using the parasitic power supply method, the VDD pin must be connected to the ground. The
system core controller S3C2410X is a chip based on the ARM920T core of Samsung. S3C2410X integrates 1 LCD controller (supports STN and TFT LCD screens with touch screens), SDRAM, touch screen, USB, SPI, SD and MMC controllers, 4 timers with PWM function and 1 internal clock, 8 channels of 10-bit ADC, 117-bit general I/O port and 24-bit external interrupt source, 8-channel 10-bit AD controller, the processor operating frequency reaches up to 203 MHz. The system display uses SHARP 3.5 in TFT_LCD liquid crystal display. The system block diagram is shown in Figure 2.
Figure 2 Information acquisition system and some circuit connection principles
3 Driver implementation
This section will implement the driver module of the one-wire temperature sensor network. The driver is generally divided into two parts: driver and kernel interface layer, hardware device interface layer.
3.1 Driver and kernel interface layer
The driver and kernel interface layer mainly completes the registration, loading, unloading and clearing of the driver module in the Linux kernel. This part of the work is completed by the initialization and exit functions respectively.
① Initialization function completes the loading of the driver module:
② Exit function completes the unloading of the driver module:
3.2 Hardware device interface layer
The hardware device interface layer is used to describe the interaction between the driver and the device. These tasks are implemented through the interface between the virtual file system and the device driver. This interface is defined by the file_operation structure, and its structure is as follows:
3.2.1 Open device function
The open device function mainly completes the initialization of the device.
Before using the kernel timer, you need to define a timer structure static struct timer_list CycleTimer. The following are the specific operations of the timer:
3.2.2 Read interface function
When the user program performs a read operation, there may be no data to read. At this time, the read operation needs to wait until there is data to read. Here, a waiting queue is used to make the process wait when there is no data to read, and wake up when data arrives. The waiting queue is set as a circular buffer. Each new data is placed as the head of the buffer, and the data that has been stored for the longest time and has not been taken away is the tail 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 accessing the device, indicating that the device is ready for I/O reading and writing, avoiding active queries and improving program efficiency. To use asynchronous notification, you need to add a structure pointer of struct fasync_struct, and then implement the fasync interface function. [page]
Finally, call the kernel's kill_fasync function where you need to notify the user space. The DS18B20Event() function mentioned in the device opening function is to put data into the circular buffer, wake up the waiting queue and start asynchronous notification. The latter two functions are implemented as follows:
3.2.4 poll system call operation interface function
When the program needs to read and write multiple files, if a file is not ready, the system will be in a 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; if the data is usually ready and can be read, it returns POLLRDNORM.
3.2.5 release release device function
The write interface function is used to notify the driver. For example, to notify the driver to read the data of channel 2, execute the write interface function write (fileno, &SLOT2, 1) in the application program, and the driver sets the current read channel number to 2. The
driver interface function is completed. This driver belongs to the character device driver, and the source program is placed in the driver/char directory. At the same time, you need to modify the Kconfig configuration file in this directory and add the Config 18B20_S3C2410 option, modify driver/char/Makefile, and add obj$(CONFIG_18B20_S3C2410) +=S3C2410_18B20.O. Finally, reconfigure the kernel and add the driver to the kernel as a module, so that the driver can be compiled.
4 Qtopia application design
(1) Create a project
First, use QT 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 the implementation block diagram of the ThermometerFigure class. Figure 3
Implementation block diagram of the ThermometerFigure class
(2) ThermometerFigure class implementation
Use the uic tool to generate the corresponding *.cpp and *.h files (implementation files and header files of the form class). Edit the *.cpp and *.h files to implement the connection of each member function, signal slot. The specific implementation is shown in Figure 3.
3) Create main and initialize
First, create the main.cpp file and create a QApplication object in main.cpp. The QApplication class is responsible for the control flow and main settings of the graphical user interface application, and handles and schedules all events from the system and other source files; it also includes the initialization and termination of the application.
(4) Edit the *.pro file and generate Makefile.
Use the progen tool to create Thermometer.pro. The specific implementation is as follows:
Execute the qmake command to generate the Makefile file. Before executing, set the relevant environment variables, compiler path, etc.
qmakeo Makefile Thermometer.pro
(5) Compile and link the project
Execute the make command to generate the target binary file Thermometer, which can be run on the device.
(6) Release the executable file to the Linux system
Add the executable file to the root file system of Qtopia, 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. Figure 4 is the ThermometerFigure class implementation interface.
Figure 4 ThermometerFigure class implementation interface
Conclusion
This article introduces some implementation methods of vehicle information system development. The Linux development process is described through examples, including driver development and application development processes. The innovation lies in introducing a one-line sensor network into the vehicle information acquisition system, which greatly simplifies the line structure and has high practical value.
Keywords:linux Qtopia car
Reference address:Vehicle temperature network acquisition technology based on Linux/Qtopia
1 Overview of Linux system development
The development of drivers is one of the main tasks of embedded Linux development. The device driver provides the upper-level application with a device interface to control the hardware, and directly interacts with the Linux kernel. Figure 1 describes the Linux system development framework.
Figure 1 Linux system development framework
Application development is another major task of embedded Linux development. Qt/Embedded is a Qt version for embedded systems developed by Trolltech, a well-known Qt library developer. Qtopia is an open source application package and development library developed on the basis of Qt/Embedded library specifically for mobile devices and handheld devices such as PDA and SmartPhone running embedded Linux. It includes a full set of personal information management PIM (Personal Information Management), such as address book, schedule, MPEG playback, image display, browser, etc.
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 switch quantity, analog quantity, digital quantity, etc.) detection module design, etc.
This design focuses on the data acquisition of the one-line temperature network. The characteristics of the temperature signal of the one-wire temperature network are: the value is not high, mostly in the range of 0"100 ℃; the temperature signal changes slowly; the system does not have high requirements for the real-time performance of the collected temperature signal; the accuracy requirement is not high.
The advantage of the one-wire network is that it can measure a large number of physical quantities, and all communications are carried out through the one-wire protocol, regardless of the specific quantity being measured. The one-wire network is a network that can easily build a series of environmental parameter measurement networks composed of one-wire sensor chips.
DS18B20 is a networkable single-bus digital temperature sensor with the following functional characteristics:
① It adapts to a wide voltage range (3.0~5.5 V) and can be powered by the data line in parasitic power mode.
② The unique single-wire interface mode, DS18B20 only needs one port line when connected to the microprocessor to realize two-way communication between the microprocessor and DS18B20.
③ The temperature range is -55~+125 ℃, and the accuracy is ±0.5 ℃ at -10~+85 ℃.
④ The programmable resolution is 9~12 bits, and the corresponding resolvable temperatures are 0.5 ℃, 0.25 ℃, 0.125 ℃ and 0.062 5 ℃, which can achieve high-precision temperature measurement.
The single bus makes the hardware overhead extremely small, but relatively complex software is required for compensation. Since DS18B20 uses a single bus serial data transmission, ensuring strict read and write timing becomes the key to temperature measurement. Therefore, I/O driver is not used, but a single-wire temperature network driver is written separately.
This design uses a parasitic power connection method with 12-bit resolution. The advantages of parasitic power are: remote temperature detection does not require a local power supply; ROM can also be read under normal power supply conditions. To ensure that DS18B20 obtains sufficient power supply current during its effective conversion period, a strong pull-up is provided on the I/O line through MOSFET (as shown in Figure 2). When using the parasitic power supply method, the VDD pin must be connected to the ground. The
system core controller S3C2410X is a chip based on the ARM920T core of Samsung. S3C2410X integrates 1 LCD controller (supports STN and TFT LCD screens with touch screens), SDRAM, touch screen, USB, SPI, SD and MMC controllers, 4 timers with PWM function and 1 internal clock, 8 channels of 10-bit ADC, 117-bit general I/O port and 24-bit external interrupt source, 8-channel 10-bit AD controller, the processor operating frequency reaches up to 203 MHz. The system display uses SHARP 3.5 in TFT_LCD liquid crystal display. The system block diagram is shown in Figure 2.
Figure 2 Information acquisition system and some circuit connection principles
3 Driver implementation
This section will implement the driver module of the one-wire temperature sensor network. The driver is generally divided into two parts: driver and kernel interface layer, hardware device interface layer.
3.1 Driver and kernel interface layer
The driver and kernel interface layer mainly completes the registration, loading, unloading and clearing of the driver module in the Linux kernel. This part of the work is completed by the initialization and exit functions respectively.
① Initialization function completes the loading of the driver module:
② Exit function completes the unloading of the driver module:
3.2 Hardware device interface layer
The hardware device interface layer is used to describe the interaction between the driver and the device. These tasks are implemented through the interface between the virtual file system and the device driver. This interface is defined by the file_operation structure, and its structure is as follows:
3.2.1 Open device function
The open device function mainly completes the initialization of the device.
Before using the kernel timer, you need to define a timer structure static struct timer_list CycleTimer. The following are the specific operations of the timer:
3.2.2 Read interface function
When the user program performs a read operation, there may be no data to read. At this time, the read operation needs to wait until there is data to read. Here, a waiting queue is used to make the process wait when there is no data to read, and wake up when data arrives. The waiting queue is set as a circular buffer. Each new data is placed as the head of the buffer, and the data that has been stored for the longest time and has not been taken away is the tail 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 accessing the device, indicating that the device is ready for I/O reading and writing, avoiding active queries and improving program efficiency. To use asynchronous notification, you need to add a structure pointer of struct fasync_struct, and then implement the fasync interface function. [page]
Finally, call the kernel's kill_fasync function where you need to notify the user space. The DS18B20Event() function mentioned in the device opening function is to put data into the circular buffer, wake up the waiting queue and start asynchronous notification. The latter two functions are implemented as follows:
3.2.4 poll system call operation interface function
When the program needs to read and write multiple files, if a file is not ready, the system will be in a 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; if the data is usually ready and can be read, it returns POLLRDNORM.
3.2.5 release release device function
The write interface function is used to notify the driver. For example, to notify the driver to read the data of channel 2, execute the write interface function write (fileno, &SLOT2, 1) in the application program, and the driver sets the current read channel number to 2. The
driver interface function is completed. This driver belongs to the character device driver, and the source program is placed in the driver/char directory. At the same time, you need to modify the Kconfig configuration file in this directory and add the Config 18B20_S3C2410 option, modify driver/char/Makefile, and add obj$(CONFIG_18B20_S3C2410) +=S3C2410_18B20.O. Finally, reconfigure the kernel and add the driver to the kernel as a module, so that the driver can be compiled.
4 Qtopia application design
(1) Create a project
First, use QT 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 the implementation block diagram of the ThermometerFigure class. Figure 3
Implementation block diagram of the ThermometerFigure class
(2) ThermometerFigure class implementation
Use the uic tool to generate the corresponding *.cpp and *.h files (implementation files and header files of the form class). Edit the *.cpp and *.h files to implement the connection of each member function, signal slot. The specific implementation is shown in Figure 3.
3) Create main and initialize
First, create the main.cpp file and create a QApplication object in main.cpp. The QApplication class is responsible for the control flow and main settings of the graphical user interface application, and handles and schedules all events from the system and other source files; it also includes the initialization and termination of the application.
(4) Edit the *.pro file and generate Makefile.
Use the progen tool to create Thermometer.pro. The specific implementation is as follows:
Execute the qmake command to generate the Makefile file. Before executing, set the relevant environment variables, compiler path, etc.
qmakeo Makefile Thermometer.pro
(5) Compile and link the project
Execute the make command to generate the target binary file Thermometer, which can be run on the device.
(6) Release the executable file to the Linux system
Add the executable file to the root file system of Qtopia, 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. Figure 4 is the ThermometerFigure class implementation interface.
Figure 4 ThermometerFigure class implementation interface
Conclusion
This article introduces some implementation methods of vehicle information system development. The Linux development process is described through examples, including driver development and application development processes. The innovation lies in introducing a one-line sensor network into the vehicle information acquisition system, which greatly simplifies the line structure and has high practical value.
Previous article:STM32 development environment (tool) Keil MDK introduction
Next article:Embedded design of car anti-theft alarm system based on ARM
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
Guess you like
- Problems with STM32F103C8T6 standby mode
- TE Award Live: I will predict the future - Registration for the latest application of sensors in the Internet of Things has started~
- Microchip live broadcast today|Using PKCS #11 and security devices to develop Linux system security IoT edge devices to the cloud...
- Silicon Labs Development Kit Review + Development Board Arrives
- MicroPython and CircuitPython installation package tool pipkin
- filter
- Looking for a company that can make SIC simulation models
- The volume control IC PT2259 has background noise, how to solve it?
- How to overcome the load-pull measurement challenges of 5G mmWave? (Part 2)
- [National Technology N32G430] 4GPIO inversion