Presentation is loading. Please wait.

Presentation is loading. Please wait.

Codes by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.

Similar presentations


Presentation on theme: "Codes by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan."— Presentation transcript:

1 Codes by Dr. Amin Danial Asham

2 References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan

3 IV.BINARY CODES  An important requirement of programmable controllers is communication with various external devices that either supply information to the controller or receive information from the controller. This input/output function involves the transmission, manipulation, and storage of binary data that, at some point, must be interpreted by humans. Although machines can easily handle this binary data, we require that the data be converted to a more interpretable form.  One way of satisfying this requirement is to assign a unique combination of 1s and 0s to each number, letter, or symbol that must be represented. This technique is called binary coding.  In general, there are two categories of codes: a)those that represent numbers only b)and those that represent letters, symbols, and decimal numbers.  Several codes for representing numbers, symbols, and letters are standard throughout the industry. Among the most common are the following: a)ASCII b)BCD c)Gray

4 IV.BINARY CODES(continue) a)ASCII  Alphanumeric codes (which use a combination of letters, symbols, and decimal numbers) are used when information processing equipment, such as printers and displays, must process the alphabet along with numbers and special symbols.  These alphanumeric characters—26 letters (uppercase), 10 numerals (0- 9), plus mathematical and punctuation symbols— can be represented using a 6-bit code (i.e., 2 6 = 64 possible characters).  The most common code for alphanumeric representation is ASCII (the American Standard Code for Information Interchange).  An ASCII (pronounced as-kee) code can be 6, 7, or 8 bits.  Although a 6-bit code (64 possible characters) can accommodate the basic alphabet, numbers, and special symbols, standard ASCII character sets use a 7-bit code (2 7 = 128 possible characters), which provides room for lower case and control characters, in addition to the characters already mentioned.  This 7-bit code provides all possible combinations of characters used when communicating with peripherals and interfaces.

5 IV.BINARY CODES(continue) a)ASCII (continue)  An 8-bit ASCII code is used when parity check is added to a standard 7-bit code for error-checking purposes (note that all eight bits can still fit in one byte). shows the binary ASCII code representation of the letter Z (132 8 ).  This letter is generally sent and received in serial form between the PLC and other equipment.

6 IV.BINARY CODES(continue) a)ASCII (continue)  A typical ASCII transmission, again using the character Z as an example.  Note that extra bits have been added to the beginning and end of the character to signify the start and stop of the ASCII transmission.

7 IV.BINARY CODES(continue) a)ASCII (continue) 7-bit ASCII Code

8 IV.BINARY CODES(continue) b)BCD  The binary coded decimal (BCD) system was introduced as a convenient way for humans to: i.handle numbers that must be input to digital machines and ii.interpret numbers that are output from machines.  The decimal system uses the numbers 0 through 9 as its digits, whereas BCD represents each of these numbers as a 4-bit binary number. The following table illustrates the relationship between the BCD code and the binary and decimal number systems.

9 IV.BINARY CODES(continue) b)BCD (continue)  The BCD representation of a decimal number is obtained by replacing each decimal digit with its BCD equivalent. The BCD representation of decimal 7493 is shown here as an example:  Typical PLC applications of BCD codes include data entry (time, volume, weight, etc.) o Via thumbwheel switches (TWS), o Data display via seven-segment displays, o Input from absolute encoders, and analog input/output instructions

10 IV.BINARY CODES(continue) c)GRAY  The Gray code is suited primarily for position transducers.  It is basically a binary code that has been modified in such a way that only one bit changes as the counting number increases. 1-digits change 4-digits change  In standard binary, as many as four digits can change when counting with as few as four binary digits.  This drastic change is seen in the transition from binary 7 to 8.

11 IV.BINARY CODES(continue) c)GRAY (continue)  The Gray code is used in applications in which the normal sequence of binary numbers may produce an error or ambiguity during the transition from one number to the next.  If binary numbers are used. A change. for example from 0111 to 1000 may produce an intermediate erroneous number 1001 if the value of the rightmost bit takes longer to change than do the values of the other three bits

12 IV.BINARY CODES (continue) b)GRAY (continue)  An example of a Gray code application is an optical absolute encoder. In this encoder, the rotor disk consists of opaque and transparent segments arranged in a Gray code pattern and illuminated by a light source that shines through the transparent sections of the rotating disk. The transmitted light is received at the other end in Gray code form and is available for input to the PLC in either Gray code or BCD code, if converted.

13 V.REGISTER WORD FORMATS  As previously mentioned, a programmable controller performs all of its internal operations in binary format using 1s and 0s.  In addition, the status of I/O field devices is also read and written, in binary form, to and from the PLC’s CPU.  Each binary piece of data is a bit. Eight bits make up one byte. One or more bytes make up a word depending on the processor type.  A PLC word is also called a register or location.  Although the data stored in a register is represented by binary 1s and 0s, the format in which this binary data is stored may differ from one programmable controller to another. Generally, data is represented in either straight (non-coded) binary or binary coded decimal (BCD) format. Byte Word(16-bit register)

14 V.REGISTER WORD FORMATS 1) BINARY FORMAT  Data stored in binary format can be directly converted to its decimal equivalent without any special restrictions.  In this format, a 16-bit register can represent a maximum value of 65535 10.  The value 65535 10 in binary format all bits are 1.

15 V.REGISTER WORD FORMATS 1) BINARY FORMAT (continue)  The binary format represents the status of a device as either 0 or 1, which is interpreted by the programmable controller as ON or OFF.  Hence, 16-bits word may store the statuses of sixteen devices.  If the most significant bit of the register is used as a sign bit, then the maximum decimal value that the 16-bit register can store is +32767 10 or –32767 10 in 2’s complement.

16 0110

17 V.REGISTER WORD FORMATS (continue) 2) BCD FORMAT (continue)  Example:  Illustrate how a PLC’s 16-bit register containing the BCD number 7815 would connect to a 4-digit, seven-segment display. Indicate the most significant digit and the least significant digit of the seven-segment display.  Solution  The BCD output from the PLC register or word is sent to the seven-segment indicator through an output interface during the write section of the scan

18 Thanks


Download ppt "Codes by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan."

Similar presentations


Ads by Google