mobile | classic
Dataweek Electronics & Communications Technology Magazine

Follow us on:
Follow us on Facebook Share via Twitter Share via LinkedIn


Electronics Buyers' Guide

Electronics Manufacturing & Production Handbook 2019


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.

Supplied By: Avnet South Africa
Tel: +27 11 319 8600
Fax: +27 11 319 8650
Supplied By: Tempe Technologies
Tel: +27 11 455 5587
  Share on Facebook Share via Twitter Share via LinkedIn    

Further reading:

  • Managing the IoT on an energy budget
    28 August 2019, Altron Arrow, Telecoms, Datacoms, Wireless, IoT, DSP, Micros & Memory
    Historically, users wanted MCUs because they could process data and solve problems faster than a human could. MCUs also help make products more convenient and consistent in behaviour. The microcontroller ...
  • Tiny MCUs for IoT edge devices
    28 August 2019, Hi-Q Electronics, DSP, Micros & Memory
    Renesas Electronics announced four new RX651 32-bit microcontrollers (MCUs) supplied in tiny 64-pin BGA (4,5 x 4,5 mm) and LQFP (10 x 10 mm) packages. The MCUs address advanced security needs for endpoint ...
  • Qi-compliant wireless charging coils
    28 August 2019, Avnet South Africa, Passive Components
    Vishay has expanded its offering of Qi-compliant wireless charging transmitter and receiver coils with the introduction of 14 new products in industry-standard shield sizes. Consisting of eight single-coil ...
  • LED flicker, and how to prevent it
    28 August 2019, Avnet South Africa, Opto-Electronics
    With the growing popularity of LED lighting, especially now that very cheap LED luminaires are coming to the market, flicker is becoming more of a problem. Flicker, a repetitive switching on and off ...
  • 3 Watt DC-DC converters
    28 August 2019, Avnet South Africa, Power Electronics / Power Management
    Aimtec has introduced three new series of switching regulators – the AMSRB1-78JZ, AMSRL1-78JZ and AMSRL-78JZ – all meeting the EN62368 standard and suitable for IoT (Internet of Things) applications. The ...
  • Secure MCU for contactless banking and ID
    28 August 2019, Altron Arrow, DSP, Micros & Memory
    Featuring the latest 40 nm Flash process as well as enhanced RF technologies, the STMicroelectronics ST31P450 dual-interface secure microcontroller (MCU) delivers high robustness and performance for contactless ...
  • Buck converter with low quiescent current
    31 July 2019, Avnet South Africa, Power Electronics / Power Management
    Texas Instruments introduced an ultra-low-power switching regulator with what it claims is the industry’s lowest operating quiescent current (IQ) at 60 nA. The TPS62840 synchronous step-down converter ...
  • MCUs with industrial communication interfaces
    31 July 2019, Avnet South Africa, DSP, Micros & Memory
    Texas Instruments introduced new communications capabilities on its C2000 microcontrollers (MCUs). C2000 F2838x devices enable designers to use a single chip to implement connectivity, including EtherCAT, ...
  • A quick guide to multi-standard mesh networking
    31 July 2019, Avnet South Africa, Telecoms, Datacoms, Wireless, IoT
    Recent advances in wireless technology have enabled the use of mesh network topologies in home and building control applications. Low-cost IoT technology is driving the launch of devices such as smart ...
  • Mixed-signal MCUs for digital power
    26 June 2019, EBV Electrolink, DSP, Micros & Memory
    Targeted at advanced digital power applications and consumer and industrial appliances, the new STM32G4 microcontrollers (MCUs) introduce two new hardware mathematical accelerators to boost processing ...
  • eSPI-to-LPC bridge
    26 June 2019, Avnet South Africa, Computer/Embedded Technology
    Microchip Technology’s new ECE1200 bridge allows developers to implement the eSPI standard in boards with legacy LPC connectors and peripherals. Product longevity is critical in industrial computing ...
  • Designing certified power solutions for LED lighting
    26 June 2019, Avnet South Africa, Power Electronics / Power Management
    LED lighting has become the product of choice in all types of environments, from domestic to industrial through to specialist areas such as stage lighting. The combination of efficiency in terms of lumens ...

Technews Publishing (Pty) Ltd
1st Floor, Stabilitas House
265 Kent Ave, Randburg, 2194
South Africa
Publications by Technews
Dataweek Electronics & Communications Technology
Electronics Buyers’ Guide (EBG)

Hi-Tech Security Solutions
Hi-Tech Security Business Directory

Motion Control in Southern Africa
Motion Control Buyers’ Guide (MCBG)

South African Instrumentation & Control
South African Instrumentation & Control Buyers’ Guide (IBG)
Terms & conditions of use, including privacy policy
PAIA Manual


    Classic | Mobile

Copyright © Technews Publishing (Pty) Ltd. All rights reserved.