DATA CHARACTERIZATION

12.2.1 ASCII (American Standard Code for Information Interchange)

When dealing with non-numerical values or data we can use plain text characters and strings. Each character is given a unique identifier and we can use these to store and interpret data. The ASCII (American Standard Code for Information Interchange) is a very common character encryption system is shown in Figure 12.1 ASCII Character Table and Figure 12.1 ASCII Character Table. The table includes the basic written characters, as well as some special characters, and some control codes. Each one is given a unique number. Consider the letter A, it is readily recognized by most computers world-wide when they see the number 65.

 

Figure 12.1 ASCII Character Table

 

Figure 12.1 ASCII Character Table

This table has the codes from 0 to 127, but there are more extensive tables that contain special graphics symbols, international characters, etc. It is best to use the basic codes, as they are supported widely, and should suffice for all controls tasks.

An example of a string of characters encoded in ASCII is shown in Figure 12.1 A String of Characters Encoded in ASCII.

 

Figure 12.1 A String of Characters Encoded in ASCII

When the characters are organized into a string to be transmitted and LF and/or CR code are often put at the end to indicate the end of a line. When stored in a computer an ASCII value of zero is used to end the string.

12.2.2 Parity

Errors often occur when data is transmitted or stored. This is very important when transmitting data in noisy factories, over phone lines, etc. Parity bits can be added to data as a simple check of transmitted data for errors. If the data contains error it can be retransmitted, or ignored.

A parity bit is normally a 9th bit added onto an 8 bit byte. When the data is encoded the number of true bits are counted. The parity bit is then set to indicate if there are an even or odd number of true bits. When the byte is decoded the parity bit is checked to make sure it that there are an even or odd number of data bits true. If the parity bit is not satisfied, then the byte is judged to be in error. There are two types of parity, even or odd. These are both based upon an even or odd number of data bits being true. The odd parity bit is true if there are an odd number of bits on in a binary number. On the other hand the Even parity is set if there are an even number of true bits. This is illustrated in Figure 12.1 Parity Bits on a Byte.

 

Figure 12.1 Parity Bits on a Byte

Parity bits are normally suitable for single bytes, but are not reliable for data with a number of bits.

 

12.2.3 Checksums

Parity bits are suitable for a few bits of data, but checksums are better for larger data transmissions. These are simply an algebraic sum of all of the data transmitted. Before data is transmitted the numeric values of all of the bytes are added. This sum is then transmitted with the data. At the receiving end the data values are summed again, and the total is compared to the checksum. If they match the data is accepted as good. An example of this method is shown in Figure 12.1 A Simplistic Checksum.

 

Figure 12.1 A Simplistic Checksum

Checksums are very common in data transmission, but these are also hidden from the average user. If you plan to transmit data to or from a PLC you will need to consider parity and checksum values to verify the data. Small errors in data can have major consequences in received data. Consider an oven temperature transmitted as a binary integer (1023d = 0000 0100 0000 0000b). If a single bit were to be changed, and was not detected the temperature might become (0000 0110 0000 0000b = 1535d) This small change would dramatically change the process.

12.2.4 Gray Code

Parity bits and checksums are for checking data that may have any value. Gray code is used for checking data that must follow a binary sequence. This is common for devices such as angular encoders. The concept is that as the binary number counts up or down, only one bit changes at a time. Thus making it easier to detect erroneous bit changes. An example of a gray code sequence is shown in Figure 12.1 Gray Code for a Nibble. Notice that only one bit changes from one number to the next. If more than a single bit changes between numbers, then an error can be detected.

 

 

Figure 12.1 Gray Code for a Nibble