You are on page 1of 12

AIR UNIVERSITY

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

EXPERIMENT NO 9

Lab Title: ADVANCE PROGRAMMING

Student Name: Izza Jamal Reg. No: 191850


LAB ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes
(5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and follows
the lab safety rules

Total Marks: Obtained Marks:

LAB REPORT ASSESSMENT:


Excellent Good Average Satisfactory Unsatisfactory
Attributes
(5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained Marks:

Date: Signature:
AIR UNIVERSITY, ISLAMABAD
DEPARTMENT OF ELECTRICAL & COMPUTER ENGINEERING
Electrical Measurements & Instruments Lab

Lab Instructor: Wasim Iqbal

Advance Programming Lab#09

Submitted by
Izza Jamal (191850)

Fall-21

BEEP V-B
DATE:13/12/21
EXPERIMENT.NO.09
ADVANCE PROGRAMMING
Objective:
 To get familiar with the concept of shift registers,mov and arithematic operations.
 Get to know about the implementation on the software.

Apparatus:
 PLC Allen Bradley.
 LogixPro software.

Introduction:
SHIFT REGISTERS:
The Shift Register (SR) instruction shifts data through a predefined number of BIT locations.
These BIT locations can be a range of BITs, a single Word or DWord, or a range of Words or
DWords. The instruction has three inputs. Data, Clock and Reset. The data input will load the
beginning bit with a ‘1’ if it is on or ‘0’ if it is not. The clock input is used to shift the data
through the shift register. In our example, we will be using the encoder on the conveyor to
track the reject container. So each pulse of the clock represents a distance on the conveyor. The
last input is the reset. It will place ‘0’ in all of the bits within the shift register.

DATA MOVEMENT INSTRUCTIONS:


The Move (MOV) is an output instruction in ladder logics moves the source value to the
destination location. As long as the rung remains true, the instruction moves the data each
scan.

Move (MOV) Instruction

Entering Parameters:Source is the address or constant of the data you want to


move.Destination is the address where the instruction moves the data.

Application Note:If you wish to move one word of data without affecting the math flags, use a
copy (COP) instruction with a length of 1 word instead of the MOV instruction.

Using MOV for Variable Initialization

S:1/15 is a bit in the status date file that is energized for exactly one PLC scan when the PLC is
placed in run mode.

It Can be used to condition the initialization of variables used elsewhere in the ladder logic.

ARITHMETIC INSTRUCTIONS
Math instructions, like data manipulation instructions, enable the programmable controller to
take on more of the qualities of a conventional computer.

Addition Instruction:
Most math instructions take two input values, perform the specifi ed arithmetic function, and
output the result to an assigned memory location. For example, the ADD instruction performs
the addition of two values stored in the referenced memory locations. How these values are
accessed depends on the controller. Figure shows ;

Subtraction Instruction:
The SUB (subtract) instruction is an output instruction that subtracts one value from another
and stores the result in the destination address. When rung conditions are true, the subtract
instruction subtracts source B from source A and stores the result in the destination.
Figure shows the SUB instruction used with the SLC 500 controllers. The operation of the logic
rung can be summarized as follows:

Multiplication Instruction:
The multiply (MUL) instruction is an output instruction that multiplies two values and stores the
result in the destination address. Figure shows the MUL instruction used with the SLC 500
controllers. The operation of the logic rung can be summarized as follows: • When input switch
SW is closed the rung will be true.
Division Instruction:
The divide (DIV) instruction divides the value in source A by the value in source B and stores the
result in the destination and math register. Figure 11-11 shows an example of the DIV
instruction.

Square Root:
The operation of the logic rung can be summarized as follows • When input switch SW is closed
the SQR instruction is executed. • The number whose square root we want to determine (144)
is placed in the source. • The function calculates the square root and places it (12) in the
destination. • If the value of the source is negative, the instruction will store the square root of
the absolute (positive) value of the source at the destination

Negate:
This math function changes the sign of the source value from positive to negative. The
operation of the logic rung can be summarized as follows: • When input switch SW is closed the
NEG instruction is executed. • The positive value 101 stored at the source address N7:52 is
negated to 2101 and stored in destination address N7:53. • Positive numbers will be stored in
straight binary format, and negative numbers will be stored as 2’s complement.

Data Conversion: ( BCD TOD)


The operation of the logic rung can be summarized as follows: • When input switch SW is
closed the TOD instruction is executed. • The binary bit pattern at the source address N7:23 is
converted into a BCD bit pattern of the same decimal value at the destination address O:20. •
The source displays the value 10, which is the correct decimal value; however, the destination
displays the value 16. • The processor interprets all bit patterns as binary; therefore the value
16 is the binary interpretation of the BCD bit pattern. • The bit pattern for 10 BCD is the same
as the bit pattern for 16 binary.

Lab Tasks
Lab Task No.1:
Turn On 2 LED’s alternatively after 1s using BSL and BSR.

Lab Task No.2:


Implement logic using MOV and MVM:
1. Even Led’s On of O:2. 2. Odd Led’s On of O:2. 3.Even and Odd leds blink after 1s.

4. LSB (O:2/0) of port O:2 moves after 1s towards MSB(O:2/15) and back from MSB towards.LSB and
Operation must continue in loop.User can choose the sequence by

Seq#1 I1:1/0 Seq#2 I1:1/1 Seq#3 I1:1/2 Seq#4 I1:1/3

Part:2
Lab Task No.3:
Implement 8-bit Calculator which can perform following function. (Hint Use TOD to convert
Result to BCD)
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Square root
6. Negate

Additon:

Subtraction:

Multiplication:
Division:

Negate:

Square-Root:

Conclusions:
This lab was about advance programming using shift registers, data movement instruction and
arithematic operations.Few above mentioned ,are the lab tasks that explains the concept very
well.We basically use the sequence data table to generate the input given to the mov command.

You might also like