0% found this document useful (0 votes)
10 views

Lab 11 Math Instructions

This document discusses converting between BCD and binary representations of numbers in a PLC. It explains how thumbwheel switches output numbers in BCD code and how the FRD instruction can be used to convert BCD to standard binary format for use in PLC programs.

Uploaded by

okuwobi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Lab 11 Math Instructions

This document discusses converting between BCD and binary representations of numbers in a PLC. It explains how thumbwheel switches output numbers in BCD code and how the FRD instruction can be used to convert BCD to standard binary format for use in PLC programs.

Uploaded by

okuwobi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Chapter

Programmable Logic Controllers

Lab 11
Lab 11 Math Instructions
Math Instructions use words not bits

Bit Level: Input a bit for a pushbutton I:0/5

Bit I:0/5
or
Bit I:0.0/5

Word Level: Needs more than one bit. The number 7 from a
thumbwheel switch in binary (BCD) requires the word level.

Word I:0.0 111 = 7


Math Instructions
Math Instructions
Chapter
Programmable Logic Controllers

Lab 11-1
Math Instructions Project
Lab 11-1 Math Instruction Project

Operation: This project simulates a manufacturing process that has a press


stamping out parts that go onto the conveyor. An inspection is made at photo 1
and the cylinder will push the bad parts onto the bottom conveyor. The good parts
continue down the line. When 25 good parts are made, the press is stopped and
the parts are packaged into a box of 25. Then the button is pressed again to
restart
CYLINDER

PHOTO GOOD
#1 PARTS
STAMPING
PRESS

PHOTO #2
BAD
PARTS
Lab 11-12 Math Instruction Project

Quality Control: If more than 10 % (3 bad parts) are rejected the process
shuts down. Photocell #2 will subtract the bad parts from the total to give good
parts. Use cylinder #1 to be the stamping press, oscillating out and back 25 or
more times depending on the number of bad parts.

CYLINDER

PHOTO GOOD
#1 PARTS
STAMPING
PRESS

PHOTO #2
BAD
PARTS
Lab 11-1 Math Instruction Project

Quality Control: If more than 10 % (3 bad parts) are rejected the process
shuts down. Photocell #2 will subtract the bad parts from the total to give good
parts. Use cylinder #1 to be the stamping press, oscillating out and back 25 or
more times depending on the number of bad parts.

CYLINDER

PHOTO GOOD
#1 PARTS
STAMPING
PRESS

PHOTO #2
BAD
PARTS
Lab 11-1 Math Instruction Project

What instructions to use for the project – Consider the following:

 The Math functions that are most common are:


ADD, SUBSTRACT, MULTIPLEY, AND DIVIDE

 Additional math function are SQUARE, NEGATE, TO BCD,


ROM BCD, GREY CODE

 Math functions are often combined with data manipulation instruction


in programs.

 Counters are often used to keep track of parts sorting

 Quality control can be set using counters for detection of a % of


bad parts.
Chapter
Programmable Logic Controllers

Lab 11-2
Scale with Parameters Instruction
Scale With Parameters Instruction

The Scale with Parameters instruction is very useful for changing a data word into an
engineering scales such as temperature, RPM, flow rate, pressure, gallons, etc. Data
transmitted from most transducers is often in the form of 4 to 20 ma which is changed by
the analog to digital converter to 4000 to 20,000 and stored in a 16 bit word. That data is
called raw data and does not indicate the numbers corresponding to the units needed. The
SCP instruction can change to the scale needed. The diagram below illustrates the
process.

4-20ma
Temperature
Transducer Analog PLC
Input

Module

Temperature Probe
Scale With Parameters Instruction

The Scale with Parameters instruction


accepts data from a 16 bit input word file
address such as I:6.0

The SCP outputs the scaled data to a


file such as N7:0 or F8:1. The F file is
used if there will be decimal numbers.

The data in the example changes


4000-20,000 from the input file I:6.0
to 0-300 at N7:0.0 at the output file
Scale With Parameters Instruction

The data is proportional as show in the Input Output


4000 0
table. The input data ranging from 4000
5000
to 20,000 has a resolution of 12,000 6000
parts. (20,000-4,000=12,000) 7000
8000 125
Correspondingly, the output data would 9000
also have a resolution 12,000 with a 10000
temperature range of 0 – 300 degrees. 11000
Only a few temperatures are shown for 12000 150
13000
illustration. To show all, the chart would
14000
have to have 12,000 lines. 15000
16000 175
The resolution of the output data word is 17000
18000
300/12,000 = .025 which means a 19000
temperature change of .025 can be 20000 300
detected.
Scale With Parameters Instruction

In lab 10-5, N files will be used to demonstrate to operation of the SCP.


Scale With Parameters Instruction

For more information of the SCP, go to the help files in RSLOGIX


Scale With Parameters Instruction

For more information of the SCP, go to the help files in RSLOGIX


Chapter
Programmable Logic Controllers

Lab 11-3
FRD Conversion Instruction
Converting BCD to Binary

The thumbwheel used is a mechanical BCD encoder changes the decimal


number on the switch to an 8-4-2-1-BCD code for each switch. The
thumbwheel switch on the PLC Bench trainer is a (0-9) single unit. The
Thumbwheel switch on the PLC Case Trainer is a 2-unit switch (0-99) BCD
Output. The BCD is produced by the rings inside the switch which connect to
24vdc to the four proper terminals. For example when switched to “2”, the
terminals 2 and 1 outputs to produce a BCD code of 0011. The C connection
is for the +24VDC power.

Red Red 24 VDC


C 1 Orange
I:0/0
2 Yellow
Unit w I:0/1
4 Gree
0s-9 n I:0/2
8 White
I:0/3

C 1 I:0/4
2 I:0/5
Unit
4
0s-9 I:0/6
8

PLC Terminal Strip


Converting BCD to Binary

The BCD (Binary Coded Decimal) code stores numbers from 0-9 in
groups of 4 in the memory. Each numbers is a nibble (4-bits) and
number larger than 9 will use more groups. For example 99 would
use 2 nibbles. A 16 bit word has four nibbles and can store a BCD
code to represent the decimal number 9999
Stardard binary as shown below has the weight double in the next column to the left. If the number 75 was stored as standard binary if would look like this:

0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1
Converting BCD to Binary

Here is the number 75 in standard binary

0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1
StardardThe
binary
sameas number
shown below
in BCD
haswould
the weight
be stored
double
as in the next column to the left. If the number 75 was stored as standard binary if would look like this:

0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 1
0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1
Converting BCD to Binary 7 5

Here is the number 75 in BCD code.

0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 1
Stardard binary as shown below has the weight double in the next column to the left. If the number 75 was stored as standard binary if would look like this:

0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1
Converting BCD to Binary

It is necessary to convert BCD to Binary for numbers greater than 9 in BCD. The
FRD instruction will convert BCD to binary.

In the FRD instruction below, the 2-unit thumbwheel switch is wired to slot 0 input
modules terminals 0-7. The number on the thumbwheel switch in BCD will be
converted to standard binary and loaded into the integer file. Hen it will move to
a counter with the MASK MOVE instruction which blocks out switches wired to
the same input word.

I:0.0

N7:0
Stardard binary as shown below has the weight double in the next column to the left. If the number 75 was stored as standard binary if would look like this:

0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1
PLC Program to convert BCD to Binary
FRD instruction
FRD instruction
Chapter
Programmable Logic Controllers

The End
Lab 11 Math Instructions

You might also like