Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Instructions Most PLCs now support more advanced functions such as Floating point math, Boolean operations, Shifting, Sequencing, Program control.

Similar presentations


Presentation on theme: "Advanced Instructions Most PLCs now support more advanced functions such as Floating point math, Boolean operations, Shifting, Sequencing, Program control."— Presentation transcript:

1 Advanced Instructions Most PLCs now support more advanced functions such as Floating point math, Boolean operations, Shifting, Sequencing, Program control and Communications.

2 Scan time Many processes, especially in machine control, function better when the scan time is small. As the program gets larger the scan time increases. Usually, in larger programs, not all of the logic needs to be executed every scan. If this is the case, sections of ladder logic can be skipped during periods where no activity is occurring in that part of the process.

3 Jump/Label Used to skip over a section of logic to reduce scan time 99% of the time you want to jump forward

4 Jump example

5 Moving data Many times we want to be able to either change a preset value under program control or turn on/off several outputs with one instruction. The MOVE instruction allows 16 bit chunks of data to be moved around.

6 Move example

7 16 bit numbers Remember that with 16 bits the number of combinations that can be represented is 2 16 or 65,536 possible combinations. We can represent these combinations as any range of numbers, but more typically the following two ranges are used depending on the context they are in. 0 through 65,535 or -32768 to +32,767. Another example would be in representing BCD (Binary Coded Decimal) numbers. In BCD, each decimal digit if represented with 4 bits. 0000=0, while 1001=9. With 16 bits, 4 BCD digits can be represented.

8 BCD numbers Most operator I/O devices such as thumbwheel entry, numeric displays, etc use the BCD representation. Example, 2305 in decimal converts to 4 groups of 4 bit numbers. 2305 0010001100000101 Note: It is customary to show the MSB (Most Significant Bit) on the left side of a binary number. In this course, that will hold true Care must be exercised when performing math on numbers. Make sure that BCD numbers have been converted to binary first.

9 BCD conversions Many times, BCD (Binary Coded Decimal) devices are connect to outputs The BCD instructions convert to/from binary/BCD

10 BCD exercise Convert 42 BCD to binary Convert 1001 0010 to BCD What are the valid 4 bit binary values that can be converted to BCD?

11 Math Programming languages like Java, C and Pascal are considered “Strongly Typed”. This means that the programmer must specify which type of information a variable will hold. For example, information can be true/false (1 bit), numeric (integer and real numbers), string, array or custom types. In most PLCs the numeric data is either single precision (16 bit) or double precision (32bit). In PLCs, the math operations usually are different for 16 bit, 32 bit and floating point functions. In this course we will limit the scope of the math functions used.

12 Add

13 Subtract

14 Multiply

15 Divide

16 Math example #1

17 Math example #1 con’t

18 Math example #2

19 Masking Some instructions like the Masked Move (MVM) allow the source to be ANDed with a mask so that only the part of the source you want gets through Remember back in grade school when the teacher gave you a quiz that used a multiple choice answer form. When s/he graded the quiz they would overlay a template with holes cut out so that only areas where the correct answers would show through. This is an example of masking. We use masking in order to look at or control a portion of a 16 bit number. The binary mask value is ANDed with the number of interest.

20 AND

21 OR

22 XOR

23 NOT

24 Clear

25 Inequalities Greater than Less than Equal Not equal

26 Inequalities Are very useful to compare timer/counter accumulated values, etc Always be careful with the Equal/Not equal In the BASIC programming example below, is the test ever true? The real danger with using inequalities is not so much with counting when things are always incremented by one, but rather with analog inputs and other situations where the increment can be a number other than one.

27 Greater than

28 Less than

29 Equal

30 Not Equal

31 Sequencers With a sequencer, an entire block of outputs to be controlled together. Many processes are sequential in nature and can be described in discrete steps. On step #1 the outputs will be set in a certain pattern, in step #2 the pattern will be different. A truth table, as shown below, can be constructed. There are two types of sequencers, bit shift and drum. Below is an example of a when a drum sequencer, where multiple outputs are controlled at the same time, would be used. Each time the sequencer is activated it moves to the next step and will set the outputs to the following pattern

32 Drum sequencers Show picture of mechanical drum sequencer with explain

33 Sequencers

34

35 Sequencer example

36 Sequencer example (con’t)

37 Bit shift Bit shifting instructions teach a group of binary digits as one large value. And in the same way that a digital circuit shift register operates, the PLC has instructions to operate on these values. Shift left and Shift right instructions will be used. Bit shift sequencers are used to track parts on a conveyor or sequence a process through different steps. The shift operation can also be looked at as a math function. When values are shifted left it has the same effect as multiplying by 2. Conversely, when shifting right, the number is divided by 2. Point of interest: Most 8 bit microprocessors (8085, Z80, 6502) do not have multiply instructions. Multiplication is accomplished by an algorithm of shifting and adding.

38 Bit shift left

39 Bit shift left example

40 Bit shift right

41 Shifting example

42 Shifting example (con’t) What does this do? It is started by input #3

43 Control structures As discussed before, the PLC needs both memory and scan time to perform housekeeping tasks. When using a simple one-shot instruction, an additional 1 bit of memory was required to retain the status of was the one-shot fired during the last scan. With timers and counters we had the T4 and C5 files which has the control structures for those devices. With some of the more advanced instructions such as shift registers the CPU requires the use of a block of memory which is referred to as a Control structure. In AB land, this is found in a the control file (R6) and again there are 255 structures available. You cannot use the Binary file (B3) or the timer/counter files T4/C5.

44 Control structures


Download ppt "Advanced Instructions Most PLCs now support more advanced functions such as Floating point math, Boolean operations, Shifting, Sequencing, Program control."

Similar presentations


Ads by Google