Design and Implementation of Network Control System Based on ARM uCLinux

Design and Implementation of Network Control System Based on ARM uCLinux

introduction

With the development of network and communication technology, embedded systems have now entered a stage of rapid development. And has been widely used in various fields of society. This article introduces a development platform that uses ARM + uCLinux. Realize remote system monitoring based on TCP / IP. In order to replace the traditional single-chip microcomputer to achieve data collection, preprocessing and communication functions; and rely on the Internet to transmit data to the host computer, while supporting remote clients to remotely control the device, so as to achieve a specific method of remote monitoring.

1 Construction of the system platform

The system consists of embedded platform server, front-end controller, front-end sensor, client and configuration PC. You can download the system and application software by configuring the PC during development. The embedded system platform can collect field data. And transmitted to the remote client, and then the remote client processes the data, and then sends control signals to the system server, so as to remotely control the device through the front-end controller. Its system structure is shown in Figure 1

1.1 Hardware development platform

The hardware development platform of the system can choose SmartARM2200. The core of the embedded device is LPC2210 of ARM7TDMI. The development board has an A / D converter and multiple GPIO (general I / O) ports, which can collect and monitor various equipment and instruments on the industrial site. When in use, just connect the corresponding sensor signal to the port of the controller. The hardware configuration of its development board system is shown in Figure 2.

1.2 uCLinux operating system

The operating system is the core part of the embedded device software. This system uses the uCLinux system platform to complete the management and maintenance of the hardware system. uCLinux is an embedded Linux operating system widely used in the field of micro-control. It can remove some codes of virtual memory management by reducing the standard Linux kernel to optimize the memory allocation. So as to achieve the purpose of improving system operating efficiency. uCLinux can be transformed into a highly optimized, compact code embedded Linux through various aspects of miniaturization, which retains most of the advantages of Linux, including stability, good portability, excellent network functions, complete file system support, Rich API etc.

1. 3 uCLinux transplantation on ARM platform

If porting uCLinux to SmartARM2200, the following four steps are required:

(1) Download the source code and establish a cross-compilation environment

uCLinux is free software (completely open code). Users can directly from http: //. Download the source code at org / pub / uclinux and install it under the Red Hat9.0 system, so as to normally establish a cross-compilation environment in Red Hat9.0

(2) Configure and compile the kernel

Go to the installed uCLinux directory and execute the following commands in order:

make menuconfig; after entering the configuration menu, select PHILIPS / lpc2200 under Vendor / Product; use Kernel Version to select Linux-2. 4. x, Libc Version (function library version) select uClibc: the rest of the kernel and application options can be selected according to the situation.

make dep

make clean

make lib_only

make user_only

make romfs

make image

make

After the compilation, romfs will be generated in the uCLinux installation directory. img file, use it to make RAM Disk, and then in linux-2. 4. Generate the Linux kernel file in elf format in the X directory, and convert it to the bin format in the following manner

# arm-elf-objcopy-O binary linux linux. bin

In order to generate the uCLinux kernel image file linux for download. bin.

(3) Make Ram Disk Mounting Root File System

First create a 512 kB virtual disk and convert the virtual disk file format to ext2 format:

dd if / dev / zero of = initrd. img bs = 1024 count = 512

mkfs. ext2-c init. img

Then init. img and romfs. img is loaded on the host file system, and the required directories are created in RAM: / bin, / dev, / etc, / var, and then the files in the ROM are copied to the ram directory.

Next, create a device node in the dev directory of the RAM disk:

#mknod ram / dev / ttyS0 c 4 64

#mknod ram / dev / console c 5 1

Finally uninstall init. img and romfs. img, and should ensure init. The img modification has been saved, so far, the RAM DISK has been created.

(4) Download kernel and file system

Correctly set the motherboard boot selection jumper. After the motherboard is powered on, you can see the BootLoader boot information on the HyperTerminal, you can choose the default FTP connection, and use the BootLoader default IP to download, then start gftp, enter the default IP and port number of the motherboard. In this way, the Linux host can be connected to the host, and finally select the Linux kernel file and RAM disk and related configuration files to be downloaded.

2 Realization of monitoring system functions

The monitoring system is mainly composed of 3 parts: data acquisition part, equipment control part, and data transmission part. The data acquisition part can perform A / D conversion on the sensor signal, and simply process the collected data, while providing an interface to adjust the operating parameters. The data transmission part can transmit the collected data to the remote host and receive the control information of the remote host. The remote host processes, stores and displays the transmitted remote data, and can modify the parameters of the data collection part to control the data collection, and at the same time issue operation instructions to the device based on the collected data or control the remote device , So as to realize the remote monitoring function.

2.1 Data collection

Before using the A / D conversion device, you must first create a device node and load the ADC driver, and then open and close it through open () and close (). The main data collection procedures are as follows:

...

ioctl (fd, ADC_SET_CLKDIV, (Fpclk + fadc1) / fadc-1); // Set A / D conversion speed

ioctl (fd, ADC_SET_BITS, 10); // Set A / D conversion accuracy;

while (1) {

ad_data = 0;

read (fd, & ad_data, sizeof (ad_data)); // Read the value of A / D conversion;

...

2. 2 GPIO device control

Similar to A / D conversion devices, the use of GPIO also requires the creation of device nodes and the loading of drivers. Before operating GPIO, it should be opened by open (), and after use, it should be closed by close ().


First of all. Select the unused GPIO port on the development board, set its input / input status, and then operate the port according to the information returned by the client, output 0/1 level to make the externally connected relay operate. Thereby controlling the operation of the equipment. The program is mainly realized by the function ioctl. ioctl is a function in the device driver to manage the I / O channel of the device, and it can control some characteristics of the device. The prototype of its function is:

int ioctl (int fd, ind cmd, ...);

Among them, fd is the file identifier returned by the open function when the device is opened by the program; cmd is the control command of the user program to the device; as for the ellipsis behind, it is some additional parameters (generally at most one, with or without cmd Relevant). Here, it can be achieved by the following set of functions:

ioctl (fd1, GPIO_SET_PIN_IN, devicel);

// Set the tube angle to the output state;

ioctl (fd2, GPIO_SET_PIN_OUT, devicel_state);

// Set the tube angle to the input state;

ioctl (fd2, GPIO_READ_PIN, & devicel_state);

// Read the device status tube angle;

ioctl (fd1, GPIO_CLR_PIN, device);

// Clear the control signal of the tube angle of the equipment;

2. 3 network communication procedures

Network communication programs can be written using standard sockets under the TCP / IP protocol. Socket (socket) is the basic operation unit of network communication. It provides endpoints for bidirectional communication between processes of different hosts. These processes should establish a socket before communication, and realize the network communication function through the read / write operation of the socket. There are two commonly used sockets: Stream Socket (Stream Socket) and Datagram Socket (Datagram Socket). Among them, the stream socket is a reliable connection-oriented communication data stream, which is error-free transmission; and the datagram socket uses UDP to transmit data packets, and the order of the data packets is not guaranteed. This system uses streaming sockets for programming.

The process flow of establishing a connection and communication between the service process and the client process of the streaming socket is shown in FIG. 3. The specific instructions are as follows:

(1) The service process first calls socket () to create a streaming socket, and bind () to bind the server address to the socket, then calls listen () to listen for connection requests, and then calls accept () to do well Prepare to establish a connection with the client process. When there is no connection request, the service process is blocked;

(2) The client process first calls socket () to create a streaming socket, and then calls connect () to send a connection request to the service process;

(3) When the connection request comes, the service process is woken up and a new streaming socket is generated. At the same time, the new socket is used to establish a connection with the socket of the client process, and the earliest socket generated by the service process continues to be used to listen to service requests on the network;

(4) The service process and the client process exchange data by calling send () and recv (), and the server can transmit the collected data to the client. The client feeds back control information and parameter adjustment information to the server;

(5) The service process or client process can cancel the socket and interrupt the connection by calling close ().

After the server-side program is compiled through the cross-compilation environment. Can be downloaded to the development board through NFS (Network File System), and then manually added to the rc boot file. You can achieve automatic operation after booting

3 Conclusion

Embedded systems based on ARM and CLinux represent the current development direction of embedded systems. The embedded system is combined with network technology and control technology. It is an inevitable trend in the development of embedded systems. This article discusses the design and implementation of network control system based on ARM + uCLinux platform. And discussed the application of TCP / IP protocol for network communication under this platform. This method has certain reference significance for automation building, industrial control, smart home, etc.

Off-Grid Inverter

The off-grid inverter is an inverter used in off-grid solar power generation systems. Its main function is to convert the direct current generated by solar panels into alternating current to meet the power demand in off-grid environments, such as in remote areas, In camping, boats, or moving vehicles.

Main effect:
Converts the direct current generated by solar panels into alternating current to supply the power needs of homes, mobile devices, or other electrical appliances.
Off-grid inverters are usually equipped with battery energy storage systems, which store excess power so that they can continue to supply power when the solar panels cannot generate enough power.

Differences from On-Grid Inverter:
Connection method: Off-grid inverter is an inverter used in the off-grid system and does not need to be connected to the grid. They are often used in places where there is no access to the grid, such as remote areas, wild camping, or outlying islands.

Grid requirements: Unlike on-grid inverters, off-grid inverters do not need to meet grid requirements and standards because they are not connected to the grid. They can operate independently and can be adapted to different off-grid environments.

Self-sufficiency: The off-grid inverter is equipped with a battery energy storage system, which can store excess electricity so that it can continue to supply electricity when the solar panels are unable to generate electricity. This makes the off-grid system self-sufficient and not dependent on an external grid for power.

Application scenarios: Off-grid inverters are widely used in remote areas, camping, ships, mobile vehicles, and some special-purpose scenarios. On the other hand, grid-connected inverters are mainly used in home, commercial, and industrial photovoltaic power generation systems connected to the grid.

In general, the main function of the off-grid inverter is to convert the direct current generated by the solar panels into alternating current to meet the power demand in the off-grid environment and achieve self-sufficiency by being equipped with a battery energy storage system. In contrast, on-grid inverters connected to the grid are mainly used to integrate solar power into the grid, realize the interaction between solar power and the grid, and comply with the requirements and standards of the grid.


off grid solar inverter,off grid 3 phase inverter, off grid solar power inverter, off grid solar inverter 5kw, off grid solar inverters for sale

Ningbo Autrends International Trade Co., Ltd. , https://www.china-energystorage.com