DSP, Micros & Memory


Using embedded Web servers within applications

5 June 2002 DSP, Micros & Memory

There is nothing new about a low-cost microcontroller (MCU) running a TCP/IP stack and serving Web pages. Many MCUs incorporate a TCP/IP stack implementation, allowing them to be connected to the Internet. Although this is a perfectly valid use, such devices can be even more useful when used inside applications. Many applications use a status or diagnostic port to provide a view of their internal operations. Considerable effort can be needed to develop this interface, its protocols and the resulting software to run on an external computer or handheld to display the information. It is much easier to use a global standard already in use: the Internet and Web browsers. Almost everyone has surfed the Web and can easily navigate a Web page. The use of embedded Web servers to display status and diagnostic information using Web pages not only cuts development time for the system designer, but also reduces training and equipment costs when the system is deployed.

Most large systems already incorporate an embedded network, usually RS232, RS485, I2C, or CAN, from which information about system operation can be obtained. A low-cost, 8-bit MCU can interface to this network and communicate with the various sub-systems to get status information and provide control over those systems. The MCU also has an Internet interface. This allows a field service technician to connect a standard PC to the system using the serial or Ethernet port. Since the IP address of the MCU is the same on all systems, the configuration of the PC is automatically handled when the PC boots. The technician only needs to start the Web browser to begin checking status or changing parameters in the system.

Hardware interfaces

The Internet interface comes in two varieties: serial or Ethernet. The serial interface is the same as that used by many people today to connect using modems. In this case, a modem is not needed, as the stack on the MCU emulates one. The only hardware requirement is a level-shift circuit that translates the ±15 V RS232 levels to the 0 V and +5 V digital levels of the MCU. Many inexpensive devices, such as a MAX232 or DS275, will do this.

The Ethernet interface also requires an interface IC, which needs to be significantly more complex than the one needed for RS232. This device buffers packets to be transmitted or packets that have been received, checking the addresses and checksums of packets, and the interface to the network media. Ethernet interface devices include the Realtek RTL8019AS or the Crystal CS8900A. In addition to the interface IC, a clock source and a media interface device such as a transformer are required.

Serial interfaces can take advantage of the integrated serial port provided on many microcontrollers. However, Ethernet interface devices have yet to become embedded and usually implement some type of PC bus interface such as ISA or PCI. Therefore, the interface to the MCU usually requires a slew of I/O pins for address, data and control.

The second part of the Internet hardware is the microcontroller. The MCU must first be able to interface to the existing network in the application. Implementing the Web server with integrated peripherals also saves CPU overhead for the main system, compared to implementing a virtual peripheral. I2C is very popular in environmental monitoring for rack-mounted equipment such as servers. RS485 is used in many industrial applications. CAN also serves industrial applications as well as automotive busses. One example of a device that would satisfy most of these requirements is the PIC18F6720 Flash microcontroller from Microchip Technology. This device has a USART interface capable of supporting RS232 and RS485, an SPI module and an I2C module. It contains 128 KB of program memory and 3,8 KB of data memory, which is sufficient to implement the interface to the application network and the TCP/IP stack.

TCP/IP protocols

Now we must define the set of Internet protocols neded to implement the embedded Web server. The requirements can be seen in Figure 1, which shows a TCP/IP stack model containing several layers.

Figure 1. TCP/IP stack model
Figure 1. TCP/IP stack model

The Physical Layer provides the low-level interface between the MCU and the physical media. For serial interfaces, this may include firmware to emulate a modem and/or routines to transfer data using the serial port. An Ethernet interface requires routines to control the I/O pins used to connect to the address, data and control lines. The Physical Layer transfers data bits or bytes between the media and the next layer up in the stack.

The Data Link Layer converts the raw data from the Physical Layer into logical frames that the next layer up recognises. A serial interface will typically use one of two protocols: Serial Line Interface Protocol (SLIP) or Point-to-Point Protocol (PPP). SLIP is a very simple method of breaking data into frames using a delimiting character in the stream of data. PPP is a more complex protocol providing services such as compression and many other advanced features. PPP is usually used in serial interfaces for dial-up connections to the Internet, but the simplicity of SLIP may be more suited to a control and diagnostic port.

The Network Layer is responsible for handling addressing of messages and routing messages from source to destination. It is used to translate hardware addresses such as an Ethernet address into logical addresses such as an IP address. The protocols used in this layer are the Address Resolution Protocol (ARP), Internet Control Message Protocol (ICMP) and Internet Protocol (IP). ARP translates the physical address into the logical address. ICMP provides a method of communicating errors and other messages between two nodes on the network. One of the most useful features of ICMP for debugging embedded systems is the echo request and reply, or 'PING'. This feature allows one system to see if another system is connected to the network. IP is the backbone of the Internet. Some of the features of IP are the addressing and routing of packets, fragmentation and re-assembly of packets of data, packet timeout and prioritisation of packets.

The Transport Layer controls the flow of data between nodes on a network and divides the data stream into more manageable sizes for the surrounding layers. It can also provide error checking, error handling and acknowledgement of data based on the protocol. The two main protocols used in the Transport Layer are User Datagram Protocol (UDP) and Transmission Control Protocol (TCP). UDP is a connectionless-based protocol where packets of data are transmitted without any handshaking or acknowledgement of reception. It is significantly simpler than TCP and can be used successfully in many embedded applications. TCP, on the other hand, provides a reliable method of delivering packets to the destination. TCP provides full duplex transmission and can compensate for packets that arrive out of order. It can change its operation to maximise delivery based on network delays and packet sizes. TCP is an extremely robust protocol, but comes at a price of significantly increased CPU overhead.

So far we have not discussed what to do with the data, only how to get it from one place to another. The Application Layer provides the necessary services to interpret the data being received. This layer provides services such as file transfer, mail and Web browsing. The two important protocols for embedded systems are Trivial File Transfer Protocol (TFTP), based on a UDP transport, and HyperText Transfer Protocol (HTTP), based on a TCP transport. TFTP is a simple method used to transfer data to the MCU, such as new firmware to be self programmed into Flash program memory or new Web pages to display. HTTP is the underlying protocol of Web browsers. It interprets the HyperText Markup Language (HTML) and co-ordinates the transfer of data and graphics to support the Web page. The Web browser is the most universally-used graphical user interface (GUI) in the world and, most importantly, it is free!

There are several applications that can take advantage of an embedded Web server for diagnostics and control. The modern car has many subsystems that communicate over a network. This is usually a CAN network, which communicates between the engine control module, the traction control module, the body control module and others. An aeroplane has a similar system, with many subsystems that control the engines, control surfaces and flight systems. Industrial applications that have sensors measuring a process can display flow rates, temperatures, pressure, etc. Racks of equipment such as servers will have hardware to monitor power supply voltages, temperatures and fan speeds. Figure 2 shows an example of what a generic system looks like when based on a PIC18F6720. All these applications have the potential to provide an intuitive interface to a service technician to troubleshoot, diagnose and modify the system and probably are already using 8-bit MCUs.

Figure 2. Generic embedded Web server featuring the PIC18F6720
Figure 2. Generic embedded Web server featuring the PIC18F6720

Using the protocols of the TCP/IP suite best suited to an embedded environment, an 8-bit microcontroller can create a self-contained embedded Web server capable of interfacing to the application network and the outside world. It can provide an easy-to-use GUI to see the status of a system and control the application. Most importantly, it reduces development time and costs associated with diagnostic equipment and training field service technicians.

Source material reproduced with permission from ECN Magazine, November 2001.

For further information about Microchip Technology products, contact local representatives: Avnet Kopp, 011 444 2333, Azona, 012 665 2880, Memec SA, 021 674 4103 or Tempe Technologies, 011 452 0530.



Credit(s)



Share this article:
Share via emailShare via LinkedInPrint this page

Further reading:

Accelerate development of physical AI deployments
Altron Arrow DSP, Micros & Memory
With Avocado OS now available on the HummingBoard RZ-V2N- AIoT and SolidSense AIoT V2N from SolidRun, teams can move from prototype to deployed fleet in weeks.

Read more...
AI-ready edge MPU for HMIs
Future Electronics DSP, Micros & Memory
The Renesas RZ/G3E MPU is a high-performance microprocessor designed to enable advanced HMI systems with integrated artificial intelligence capabilities at the edge.

Read more...
Industrial-grade ESP32-S3 controller
DSP, Micros & Memory
Erqos Technologies has introduced the EQSP32CE, a CE-certified, industrial-grade ESP32-S3 controller designed for developers who want the flexibility of the ESP32 ecosystem in hardware that can be deployed directly into real-world automation.

Read more...
Universal NFC device
Altron Arrow DSP, Micros & Memory
Delivering high-end performance in a compact 4 x 4 mm package, the multipurpose NFC reader from ST Microelectronics, enables the convenience of contactless interaction and features for various end applications.

Read more...
Compact low-power 32-bit platform
EBV Electrolink DSP, Micros & Memory
Microchip’s PIC32CM PL10 microcontroller family expands the company’s Arm Cortex-M0+ portfolio, delivering a compact, low-power 32-bit platform designed for cost-sensitive embedded applications.

Read more...
Bridging the gap between prototype and production
DSP, Micros & Memory
Choosing between the FRDM i.MX 93, FRDM i.MX 91 and FRDM i.MX 91S development platforms can be intimidating, but once designers understand how each platform aligns with their application’s requirements, the decision becomes straightforward.

Read more...
Low-power memory born for edge AI
iCorp Technologies DSP, Micros & Memory
As intelligence moves from the cloud to the device, memory become one of the most important design decisions in modern electronics. Edge-AI products – from smart speakers and surveillance cameras to ADAS modules and wearables – need to move data fast, but they also need to sip power. Winbond’s low-density LPDDR4/LPDDR4X SDRAM range is built to strike that balance.

Read more...
Compact direct Time-of-Flight 3D LiDAR module
Altron Arrow AI & ML DSP, Micros & Memory
The VL53L9 from STMicroelectronics is the first direct Time-of-Flight (dToF) 3D LiDAR all-in-one module in ST’s portfolio, offering a resolution of 2,3K zones, wide field of view, on-chip processing, 100 frames per second, and sensing range from 5 centimeters to 9 meters.

Read more...
Next-gen smart module powers intelligence at the edge
iCorp Technologies DSP, Micros & Memory
Quectel Wireless Solutions has expanded its smart module portfolio with the SH803FD, a new-generation, high-performance smart module.

Read more...
Programmable logic redefined
DSP, Micros & Memory
Microchip’s CLB-based PIC MCUs combine programmable logic and embedded control in a single device to help reduce latency, cost, and design complexity.

Read more...









While every effort has been made to ensure the accuracy of the information contained herein, the publisher and its agents cannot be held responsible for any errors contained, or any loss incurred as a result. Articles published do not necessarily reflect the views of the publishers. The editor reserves the right to alter or cut copy. Articles submitted are deemed to have been cleared for publication. Advertisements and company contact details are published as provided by the advertiser. Technews Publishing (Pty) Ltd cannot be held responsible for the accuracy or veracity of supplied material.




© Technews Publishing (Pty) Ltd | All Rights Reserved