An Introduction to

ASCII

What is ASCII?

The American Standard Code for Information Interchange (ASCII) is a character encoding standard for electronic communication that assigns a unique 7-bit integer (0 – 127) to 128 different characters. It is used to translate binary data into human-readable letters, numbers and symbols, as well as essential control characters (like Start of Text or Carriage Returns) that define the boundaries of a data message. Over time, ASCII has been extended to include symbols and characters for different languages.

Featured ASCII Gateways

view all our ASCII gateways

ASCII Data Encoding

Traditional ASCII field devices like barcode scanners, RFID readers and weigh scales generate a raw analog voltage based on physical input such as light reflection (barcode scanners), radio frequency induction (RFID) or mechanical pressure (weigh scales). An internal analog-to-digital converter (ADC) translates this electrical signal into a digital mathematical value.

When this input is received, the device’s processor maps the value to its corresponding character using an internal ASCII lookup table and then translates it into a standard 7-bit or 8-bit binary pattern. This binary data is handed off to the communication interface to be sent to the receiver, typically a PLC or ASCII gateway. The data transmission depends on the device’s physical interface:

  • For serial devices, the binary data is sent to a Universal Asynchronous Receiver-Transmitter (UART) that wraps each character in a frame and pulses the signal down the wire bit by bit
  • For ethernet devices, the binary data is handed to an Ethernet controller, which bundles the characters into a TCP/IP packet

ASCII Reference Table

The 128-character ASCII reference table is shown below.

Dec Hex Oct Chr Dec Hex Oct HTML Chr Dec Hex Oct HTML Chr Dec Hex Oct HTML Chr
0 0 000 NULL 32 20 040   Space 64 40 100 @ @ 96 60 140 ` `
1 1 001 SoH 33 21 041 ! ! 65 41 101 A A 97 61 141 a a
2 2 002 SoTxt 34 22 042 " 66 42 102 B B 98 62 142 b b
3 3 003 EoTxt 35 23 043 # # 67 43 103 C C 99 63 143 c c
4 4 004 EoT 36 24 044 $ $ 68 44 104 D D 100 64 144 d d
5 5 005 Enq 37 25 045 % % 69 45 105 E E 101 65 145 e e
6 6 006 Ack 38 26 046 & & 70 46 106 F F 102 66 146 f f
7 7 007 Bell 39 27 047 ' 71 47 107 G G 103 67 147 g g
8 8 010 Bsp 40 28 050 ( ( 72 48 110 H H 104 68 150 h h
9 9 011 HTab 41 29 051 ) ) 73 49 111 I I 105 69 151 i i
10 A 012 LFeed 42 2A 052 * * 74 4A 112 J J 106 6A 152 j j
11 B 013 VTab 43 2B 053 + + 75 4B 113 K K 107 6B 153 k k
12 C 014 FFeed 44 2C 054 , , 76 4C 114 L L 108 6C 154 l l
13 D 015 CR 45 2D 055 - 77 4D 115 M M 109 6D 155 m m
14 E 016 SOut 46 2E 056 . . 78 4E 116 N N 110 6E 156 n n
15 F 017 SIn 47 2F 057 / / 79 4F 117 O O 111 6F 157 o o
16 10 020 DLE 48 30 060 0 0 80 50 120 P P 112 70 160 p p
17 11 021 DC1 49 31 061 1 1 81 51 121 Q Q 113 71 161 q q
18 12 022 DC2 50 32 062 2 2 82 52 122 R R 114 72 162 r r
19 13 023 DC3 51 33 063 3 3 83 53 123 S S 115 73 163 s s
20 14 024 DC4 52 34 064 4 4 84 54 124 T T 116 74 164 t t
21 15 025 NAck 53 35 065 5 5 85 55 125 U U 117 75 165 u u
22 16 026 Syn 54 36 066 6 6 86 56 126 V V 118 76 166 v v
23 17 027 EoTB 55 37 067 7 7 87 57 127 W W 119 77 167 w w
24 18 030 Can 56 38 070 8 8 88 58 130 X X 120 78 170 x x
25 19 031 EoM 57 39 071 9 9 89 59 131 Y Y 121 79 171 y y
26 1A 032 Sub 58 3A 072 : : 90 5A 132 Z Z 122 7A 172 z z
27 1B 033 Esc 59 3B 073 &#059; ; 91 5B 133 [ [ 123 7B 173 { {
28 1C 034 FSep 60 3C 074 &#060; < 92 5C 134 &#092; 124 7C 174 &#124; |
29 1D 035 GSep 61 3D 075 &#061; = 93 5D 135 &#093; ] 125 7D 175 &#125; }
30 1E 036 RSep 62 3E 076 &#062; > 94 5E 136 &#094; ^ 126 7E 176 &#126; ~
31 1F 037 USep 63 3F 077 &#063; ? 95 5F 137 &#095; _ 127 7F 177 &#127; Delete

ASCII Messaging and Framing

Once a physical value is encoded into ASCII characters, it must be packaged and transmitted. Depending on the physical layer, the data is delivered either as a stream of individual characters or as a bundled data packet.

Serial ASCII

Bit-by-Bit Transmission

Because serial wires can only carry one signal at a time, the UART sends data in a bitstream. While the original ASCII standard is a 7-bit code that includes an 8th “parity” bit for error detection, most modern industrial applications use an 8-bit format.

In standard serial communication, the least significant bit (LSB) is sent first, followed by the remaining bits and ending with the most significant bit (MSB). Understanding this bit order is crucial for troubleshooting and ensuring data is not misinterpreted by a PLC.

Serial ASCII Frame Structure

In serial ASCII, each character is wrapped in a data frame that defines the start, order, and end of the character.

  • Start Bit: A single bit (logic “0”) that signals to the receiver’s UART that a character is coming
  • Data Bits: The binary data for the character, sent with the least significant bit (LSB) sent first
  • Stop Bit: A final bit (logic “1”) that signals the end of the character and allows the timing to reset for the next character

The character-by-character delivery of serial ASCII strings requires PLCs to catch individual frames and manually reassemble them into a usable string, which is CPU-intensive and prone to timing errors. This delivery method causes a multitude of challenges for system integrators but is easily handled by ASCII gateways.

Ethernet ASCII

Packetized Delivery

In ASCII over Ethernet, the individual start and stop bits are stripped away. Instead of streaming characters one-by-one, the device bundles the entire string into a TCP/IP packet. This packet protects the data with its own internal error-checking and headers, delivering the entire message to the PLC all at once (though the PLC must still manage the TCP socket connection).

ASCII Message Structure

The ASCII message frame uses non-printable control characters to help the receiver identify when one complete data set ends and the next begins. The start delimiter, STX, is an optional character that signals a new data packet is starting. The most common end-of-message delimiters are the Carriage Return (CR) or Line Feed (LF) characters.

ASCII Message Example: Weigh Scale Payload

To a PLC or ASCII gateway, messages are processed as a sequence of hexadecimal values. Suppose a weigh scale measures a value of 125.5. If you were to look at the message, [STX]125.5[CR][LF], through a serial sniffer, it would appear as 02 31 32 35 2E 35 0D 0A.

Component Start Delimiter Data Payload End Delimiter 1 End Delimiter 1
ASCII Characters [STX] 1 2 5 . 5 [CR] [LF]
Hex Value 02 31 32 35 2E 35 0D 0A

ASCII Test Tools

When you come across a device using ASCII commands to operate, it is advantageous to have tools that allow you to visualize the commands on the wire. For ASCII over Ethernet, our team uses SocketTest. For serial-based ASCII, we recommend MTTTY Serial Terminal. Having both of these tools handy can be useful in the field to help resolve quite a few headaches. Best of all, they’re free.

Like what you’re reading?

Subscribe to our Automation Education email series to learn the ins and outs of the top industrial protocols in a byte-size weekly format!

ASCII Devices

ASCII-based devices largely come from two camps: devices that are text centric and devices that originally interacted with a PC based application.

RTA 435NBX-N700 ASCII to Allen-Bradley PLC gateway.

Text-Centric ASCII Devices

Text-centric ASCII devices read or display human readable characters. Examples include barcode scanners, weigh scales, printers, RFID readers and LED displays.

ASCII Command Response Devices

In industrial automation we leverage open protocols like Modbus, EtherNet/IP and PROFINET to move messages reliably. For many devices, the interface between the node and PC was a custom ASCII protocol. This is accomplished by defining a set of commands and responses. Below are some examples of Command (CMD)/Response (RSP) strings:

CMD:GO
RSP:OK.

CMD: Get all?
RSP: 79.8,44.3,186_c,ON,Error2

CMD: ACQ?
RSP: ACQ:ENZERO=5,VMIN=6,AVG=8.99

CMD: ACQ?ENZERO,VMIN
RSP: ACQ:ENZERO=5,VMIN=6

ASCII Physical Layers

Now that we know what ASCII is and what devices utilize the 7-bit character encoding, let’s talk about the two most common physical layers used to pass ASCII messages.

ASCII over Serial

For most of its life, ASCII communication occurred over a serial physical layer. Often that physical layer was RS-232, where the ASCII characters were converted into binary bits and transmitted by a signal voltage of +/- 3-13VDC. In RS-232, for example, negative voltage represents a logic “1” (mark) while a positive voltage represents a logic “0” (space).

The main limitation was that devices needed to be close together and most communication was 1-to-1, forcing early PLCs to require numerous serial ports. Modern PLCs have largely done away with native serial ports.

ASCII over Ethernet

In an Ethernet-enabled device, ASCII characters aren’t sent bit-by-bit via a UART. Instead, the device opens a TCP Socket (usually on a specific port like 2101 or 5000) and sends the entire ASCII message as a single data packet.

Ethernet TCP/IP is more reliable over longer distances than its serial counterparts. Serial devices utilizing ASCII messages were among the first to swap physical layers to Ethernet. The same ASCII data payload is simply placed inside a standard TCP/IP packet. This offers the additional benefit of a network that supports multiple nodes, but it requires the receiver (the PLC) to manage connection states and port numbers rather than just monitoring a voltage signal.

Challenges of ASCII in Industrial Automation

Generally speaking, ASCII is challenging to deploy in an automated control system. Many industrial devices, such as barcode scanners, RFID readers, weigh scales, displays and other legacy devices only communicate in ASCII, creating several major roadblocks for modern control networks.

  • Edge Device Ubiquity: The overwhelming majority of edge devices still rely on raw ASCII. These devices prioritize low-cost, universal compatibility and lack the onboard processing power required for modern industrial protocols and native compatibility with ethernet-enabled PLCs.
  • Unstructured Data: Modern PLCs are designed for structure data organized into tags or registers. ASCII devices send out unstructured text strings at an undefined length that are meaningless to a PLC in its raw form.
  • Hardware Incompatibility: Modern PLCs are largely Ethernet-based and do not provide a serial port, yet many edge devices still rely on legacy serial interfaces. Workaround solutions, such as in-rack serial modules, take up physical space and require complex hardware configuration.
  • Burden of Custom Coding and Maintenance: PLCs aren’t designed to manipulate string data. Integrating ASCII data directly into a PLC requires custom parsing logic to be written and maintained within PLC programs.
  • Scan Time and CPU Overhead: Constant string manipulation is CPU-intensive and can consume valuable processing power, potentially impacting the PLC’s overall scan time and deterministic performance.
  • Socket Persistence & Timeouts: Unlike “always-on” serial, Ethernet ASCII requires a managed connection. A PLC must be programmed to detect TCP socket drops and manually re-establish the connection.

RTA 435NBX-N700 ASCII to Allen-Bradley PLC gateway.

ASCII Gateways

ASCII gateways eliminate the most challenging elements of leveraging ASCII data in PLCs. Sitting between your raw ASCII devices and your control network, the gateway passes only the data payload (without any delimiters) to the PLC. This offloads the grunt work of parsing ASCII strings to the gateway, which then writes the payload values directly to your PLC data tables.

Going beyond a simple one-to-one connection, ASCII gateways also provide advanced data manipulation. They take noisy ASCII strings and can parse them into individual data points before send them to the PLC. Conversely, they can concatenate multiple data points from the PLC into a perfectly formatted string for ASCII display devices or printers. This approach ensures your PLC scan time remains deterministic and that your logic stays clean and easy to maintain.

ASCII logo

The History Behind ASCII

It was way back in 1961 when a bunch of white-shirted, black-tied engineers at IBM led the effort at the American National Standards Institute (ANSI) to develop a single common way to interchange numbers between computers. It was a mess before that. Different vendors not only represented letters and numbers differently in their computers, but they used different numbers of bits. A lot of vendors used 6 bits (that’s just 64 different combinations!).

The IBM guys convinced everyone that all computers should represent letters, numbers and special characters in the same way. Their effort led to the American Standard Code for Information Interchange, or ASCII (pronounced AS-kee).

In 1968, President Lyndon Johnson signed a memorandum adopting ASCII as the standard for federal computers, but it wasn’t until Intel invented eight-bit microprocessors in the early 1970s that eight bits and ASCII became common. By the end of that decade, IBM 360 computers (what every Fortune 500 company used) were using an old EBCDIC standard (Extended Binary Coded Decimal Interchange Code), which was finally retired with the introduction of the personal computer in 1981.

Where is ASCII Today?

ASCII is still all around us in RFID devices, barcode scanners and printers. Heck, it’s even used in weather stations to send data. It’s the only data format that can be universally decoded by any computer on the planet.

ASCII was the most common encoding used on the Internet until it was taken over by Unicode in the early 2000s. ASCII formed the foundation of Unicode and was therefore included in its set as well as its successor, UTF-8, and the standard encodings being created today.

The Future of ASCII

If you’re an ASCII aficionado, don’t worry. Even after 75 years, ASCII isn’t going away. Strings will continue to move between all sorts of devices: controllers, printers, labelers, barcode readers, enterprise applications, cloud servers and more. As long as we need to move strings around the factory floor, as long as people need string type information to communicate, as long as barcode readers read barcodes and printers print strings, we’ll always have ASCII.

The pertinent question for all of us is: how are we going to move that ASCII data in the future? In the past, we used RS-232 and RS-485, sometimes with protocols like Modbus, to move data to PLCs. Those technologies worked but they were slow and unreliable. Today, we’ve replaced much of that with USB. Sending ASCII data into PLCs over USB has become the standard way barcodes get into PLCs. USB is faster than the serial technologies, more reliable and less expensive. However, USB is limited by distance and connectivity issues inherent in the technology.

Today, we’ve replaced much of that with USB. Sending ASCII data into PLCs over USB has become the standard way barcodes get into PLCs. USB is faster than the serial technologies, more reliable and less expensive. However, USB is limited by distance and connectivity issues inherent in the technology.

The better choice, of course, is Ethernet. Ethernet is the default physical layer for the factory floor. Anything and everything on the manufacturing floor will have Ethernet in the future, even sensors. Note that using Ethernet and TCP/IP requires implementing some sort of application layer to move ASCII data.

ASCII FAQs

The American Standard Code for Information Interchange (ASCII) is a character encoding standard for electronic communication that assigns a unique 7-bit integer (0 – 127) to 128 different characters.

Prior to ASCII, different vendors represented letters and numbers differently in their computers. IBM convinced everyone that all computers should represent letters, numbers and special characters in the same way. Their effort led to the ASCII standard, and it’s the only data format that can be universally decoded by any computer on the planet.

ASCII encoding converts physical input into raw analog voltage, which is then translated into a digital mathematical value. This value is mapped to a character in an ASCII lookup table and encoded into a 7-bit or 8-bit binary value. A UART sends the corresponding electrical signal down the wire to a PLC or ASCII gateway.

The ASCII character frame structure consists of a start bit, payload (sent with the least significant bit first), and stop bit. Each character is sent one by one.

The ASCII message structure consists of a start delimiter (STX), payload, and end delimiter (CR and/or LF).

PLCs are not designed to manipulate string data and require additional hardware or custom coding as workaround solutions. An ASCII gateway eliminates these challenges.

ASCII gateways offload the work of parsing string data for the PLC and allow text-based data to be written directly to PLC data tables. Further, gateways offer advanced data manipulation including parsing strings into individual data points before sending them to the PLC and concatenating multiple data points from the PLC into a formatted string for display devices. As a result, your PLC remains deterministic and logic remains clear and maintainable.

ASCII Resources

ASCII Solutions

View All ASCII Gateways >

Move ASCII serial barcode, weigh scale, and RFID slave data to Allen Bradley PLCs

Connect ASCII Devices to a Profinet IO Controller

Link ASCII Devices to an Allen-Bradley PLC

Connect a USB device to an Allen-Bradley PLC

For more information on our ASCII products:

solutions@rtautomation.com

1-800-249-1612

Contact form