1. A Brief Overview of the Serial Communications ProcessComputer serial ports transmit and receive data bit by bit. During transmission, the serial device driver program on the computer CPU takes each byte from the main computer memory (typically 8 KB in size) and places it onto the data bus along with the serial port I/O address. The byte then travels through the data bus and is stored in the serial port hardware buffer. When the serial port is ready to transmit data, it fetches the data from this hardware buffer, places it in its shift register, and transmits each bit over the communication line. The following figure shows this process:
The shift register is one byte long. From the shift register, the serial port transmits data bit by bit. When the last bit in the shift register is transmitted, the serial port must request the next byte from the CPU via an interrupt request (IRQ). However, the CPU is usually busy when the serial port needs the byte, so the serial port must interrupt the CPU. The CPU may not respond to this interrupt immediately, which may lead to a delay in bit transmission. To solve this problem, the serial port has a hardware buffer; while the serial port transmits bits from its shift register, the hardware buffer actually sends the IRQ to the CPU to request the next byte. The advantage of this process is that when the serial port takes the final bit from its shift register and is ready to transmit the next byte, it does not need to send an IRQ to the CPU. Rather, the next byte is readily available in the buffer. This buffer is a FIFO buffer and is called a Universal Asynchronous Receiver Transmitter (UART). Early UART versions had a 1-byte buffer, but recent versions such as 16550 and 16750 have up to a 64-byte buffer. The larger buffer means interrupt requests occur less often, and the CPU can respond to IRQs more efficiently and devote more time to other tasks.
Receiving data is similar to transmission. The serial port receives the data bit by bit and places it in the shift register. When a byte is received, it is transmitted into the UART. With modern UARTs and their larger buffers, the serial port continues placing the bytes. When the buffer holds 1, 4 , 8, or 14 bytes, the port sends an IRQ to the CPU to pick up the bytes. The port does not wait until the buffer contains 16 bytes, because the CPU may not respond immediately due to the interrupt request process overload involved (due to identifying the type of request, I/O address, etc.). While the CPU responds to the IRQ, if more than 2 bytes are received, the new byte may overwrite the byte in the buffer. This creates a Hardware Overrun Error.
Serial Communication General Concepts
2. Universal Asynchronous Receiver Transmitter (UART)
A UART is a 40-pin serial chip on the PC motherboard. During transmission, the UART converts the bytes from the PC parallel bus to the serial bit stream. During receiving, the UART builds the serial bits into a parallel byte and either sends the parallel byte to the CPU or places it in its buffer. The UART does not do anything with the data; it just receives it and sends it. Early UARTs had 1-byte buffers; therefore, after receiving or building every byte, they needed to send an IRQ to either send or pick up the next byte. This process is acceptable with low transfer speeds. But at high speeds, the CPU must service the request so often that it either cannot give sufficient time to other processes or cannot service the IRQ in a timely manner. In the latter case, the new byte may come before the old byte has been received, thus causing a Hardware Overrun Error. Modern UARTs such as the 16550 and 16750 (also called FIFO UARTs) have up to a 64-byte buffer. They also have adjustable trigger levels of 1, 4, 8, or 14, meaning they can send an IRQ after collecting 1, 4, 8, or 14 bytes.
All National Instruments serial interfaces use high performance UARTs capable of multiple trigger levels and 64-128 byte FIFOs.
3. Hardware Overrun Errors
In serial communication, data bits received at the serial port are bundled into a byte and transmitted into the serial port hardware buffer. From the buffer, the byte is sent into the CPU. If a new byte arrives before the byte in the buffer is moved into the CPU, a Hardware Overrun Error occurs.
A Hardware Overrun Error may happen for several reasons:
- The serial port hardware buffer is not large enough. For example, early UART chips can store only 1 byte. After each byte is received, the serial port sends an IRQ to the CPU to pick up the next byte. Therefore, the CPU must respond very quickly, or a new byte may arrive and cause an overrun error. The new UART chips have up to a 64-byte buffer (16 bytes in the 16550A and 64 bytes in the 16750), so the buffer can store more bytes before the serial port sends an IRQ to the CPU. Therefore, the CPU has sufficient time to respond to the interrupt request and act on it. These new UARTs also have adjustable trigger levels of 1, 4, 8, and 14, meaning they can send interrupt requests to the CPU on receiving 1, 4, 8, or 14 bytes.
- Some other process might have disabled the interrupt.
- In Windows, the CPU must take care of many processes and may not respond to fast IRQs from the serial port. Also, if there are high-priority IRQs from other processes, the CPU may ignore the serial port IRQ.
4. Troubleshooting Steps to Prevent Hardware Overrun Errors
- Try hardware handshaking.
- See if the UART is an older unbuffered version or a new buffered UART (such as a 16550A or 16750). You should use a buffered UART for the reasons discussed above.
- Change the Receive (Rx Trigger) buffer to 8, 4, or 1 (1 is a last resort).
Note: LabVIEW or related software usually is irrelevant to the Hardware Overrun Error.
5. National Instruments Serial Interfaces
National Instruments serial interfaces give you connectivity to the many serial devices available for industrial, manufacturing, and laboratory data acquisition. Using a National Instruments RS-485 product, one can connect up to 31 multidropped devices to a single port or use several ports to communicate with a number of point-to-point instruments. All these serial interfaces use high performance UARTs.
These serial interfaces have been designed for communication using asynchronous serial protocols. Protocols such as OptoMux and ModBus can be run using these serial interfaces, however these protocols are not directly supported through National Instruments Serial Software.
The National Instruments ENET-232 and ENET-485 serial device servers provide a mechanism to transparently control serial devices using your local Intranet or even the Internet. Applications written for a plug-in or local serial port now can use the ENET-232 and the ENET-485 to connect to remote serial ports with absolutely no change required in the application software (under Windows). These device servers connect either high-speed (100 Mb/s) or low-speed (10 Mb/s) ethernet networks to asynchronous serial ports for communication with serial devices. Since these devices are controlled using the Ethernet network, the distance limits imposed by the RS-232 and 485 standard do not apply and the ports can be as far away from the controlling machine as the network allows. The distance requirement between the ENET-232/485 port and the instruments port do still apply.
All serial interfaces include an enhanced serial driver for full interrupt-driven, buffered I/O and reliable interrupt sharing between ports. The National Instruments serial driver maintains complete software compatibility with the standard Windows serial driver, so existing applications can seamlessly use the ports on any National Instruments serial interface without a special function library. You can program all interfaces with LabVIEW, Measurement Studio, Lookout, C/C++, Visual basic, or any application package written to the Microsoft serial driver interface.
ENET-232 and ENET-485 specifcations