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:

ESP32-C6 achieves PSA-L2
iCorp Technologies DSP, Micros & Memory
Espressif Systems recently announced that its ESP32-C6 microcontroller has achieved PSA Certified Level 2 (PSA-L2) security certification, making it the first RISC-V-based MCU to reach this level.

Read more...
Microprocessor with integrated NPU
Avnet Silica DSP, Micros & Memory
The RZ/G3E from Renesas is a microprocessor integrated with quad CPU and NPU in one chip, improving power efficiency, reliability, and security.

Read more...
Nordic Semiconductor launches nRF Connect SDK Bare Metal option for nRF54L series
Avnet Silica DSP, Micros & Memory
This is a new, RTOS-independent software solution for Bluetooth LE development, designed to ease developers’ migration from the legacy nRF5 SDK and nRF52 series to the next-generation nRF54L series.

Read more...
Dual-core support in NECTO Studio
DSP, Micros & Memory
MIKROE recently announced that version 7.3.0 of its NECTO Studio Integrated Development Environment now supports dual-core MCUs, allowing designers to program and debug each core independently.

Read more...
Post Quantum Cryptographic firmware library
DSP, Micros & Memory
The STM32 post-quantum cryptographic library enables developers to satisfy application requirements for any combination of data integrity, confidentiality, identification/authentication, and nonrepudiation.

Read more...
MultiVolt series of oscillators
Future Electronics DSP, Micros & Memory
The ECS-3225MVQ from ECS Inc. is a compact, quartz-based MultiVolt oscillator designed for precision timing in automotive, industrial, and portable electronic systems.

Read more...
MCU platform for battery-powered devices
Altron Arrow DSP, Micros & Memory
The MCX W23 is a new dedicated wireless MCU platform from NXP for battery-powered sensing devices.

Read more...
Drive innovation with AURIX TriCore MCUs
Future Electronics DSP, Micros & Memory
Infineon’s AURIX TriCore family balances safety, performance, and energy efficiency to offer a scalable and future-ready portfolio.

Read more...
Elevate your motor control designs
EBV Electrolink DSP, Micros & Memory
Built on an Arm Cortex-M33 core running up to 180 MHz, the MCX A34 family combines high-performance math acceleration and advanced motor control subsystems to unlock efficient motor drive solutions.

Read more...
Embedded platform for compute-intensive applications
iCorp Technologies DSP, Micros & Memory
The Quectel QSM368ZP-WF is a fully featured embedded ARM platform optimised for compute-intensive industrial and IoT applications.

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