bee2931 basic plc 2011
TRANSCRIPT
17/10/2011
SNAIM (c) 2011 1
BEE2931 BEE2931 -- Basic PLC Basic PLC Based Model : OMRON CQM1HBased Model : OMRON CQM1H-- CPU51CPU51
Instructor : syahrulnaim bin mohamad nawiE-Mail : [email protected]:09-4242129 h.p: 019-9825807Room no:E10-C25
Universiti Malaysia Pahang ©2011 snaim
Course OutcomesCourse Outcomes
By the end of semester, students should be able to:ab e to:
CO1 Describe the basic principle of PLC and it’s function.
CO2 Implement PLC Hardware configuration.CO3 Identify PLC system wiring and
component.CO4 E d i PLC P i CO4 Execute and practice PLC Programming
for specific tasks.CO5 Practice right attitude and safety procedure.
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 2
Mark distribution Mark distribution
Quizzes 5%Lab Report 10%Lab Report 10%Assessment 1 25%Assessment 2 30%Test 30%Total 100%Total 100%
References References
1 Jon Stenerson “Industrial Automation and Process Control”,Upper Saddle River, NJ: Prentice Hall,2003
2 John R Hackworth & Frederick D Hackworth,Jr “Programmable Logic Controller:Programming Method and Application”,Upper Saddle River,NJ:Prentice Hall,2004
3 OMRON “Sysmac CQM1H Series Operation Manual”,Revised August 2005
4 F k D P t ll “P bl L i C t ll ” 3 d Editi M4 Frank D. Petruzella, “Programmable Logic Controllers”, 3rd Edition, Mc-Graw Hill, 2005.
5 Omron, “Programming Manual”, Revised December 2003, Omron Corporation, 2003.
17/10/2011
SNAIM (c) 2011 3
1.0 INTRODUCTION1.0 INTRODUCTION
Universiti Malaysia Pahang ©2011 snaim
1.1 What is Control System1.1 What is Control System
In general, a control system is a collection of electronics devices and equipments to of electronics devices and equipments to ensure the stability ,accuracy and smooth transition of a process or a manufacturing activity.
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 4
1.1 What is Control System1.1 What is Control System
A control system consists of three sections: input processing and outputsections: input, processing and output.
Sensor
Input
Processor
Processing/ “Brain”
Actuator
Output
Binary (on/off)• Push Button Switch
Hard – wired System• Relay
Binary• Motor
Universiti Malaysia Pahang ©2011 snaim
• Limit Switch• ProximityContinuous• Transducer• Transmitter
• Electronic Logic• Pneumatic LogicSoftware – Programmable System• Computer• Micro-processor• PLC System
• Relay• CylinderContinuous• Control Valve
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 5
Universiti Malaysia Pahang ©2011 snaim
1.2 What is a Programmable 1.2 What is a Programmable ControllerController
In an automated system, the PLC is commonly regarded as the heart of the commonly regarded as the heart of the control system.The PLC may used to control a simple and repetitive task.Or a few of them may be interconnected together with other controller or host together with other controller or host computer through a sort of communication network, in order to integrate the control in a complex process.
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 6
1.2 What is a Programmable 1.2 What is a Programmable ControllerControllerPLC (Programmable Logic Controller)
A PLC works by looking at its inputs and depending on their state, and the user entered program, turns on/off outputs.
A PLC can be thought of as: Industrial Computers with
i ll d i d p
specially designed architecture in both their central units (the PLC itself) and their interfacing circuitry to field devices (input / output connections to the real world).
Universiti Malaysia Pahang ©2011 snaim
1.3 PLC Development1.3 PLC DevelopmentEarly control systems consisted of huge control boards consisting of hundreds to thousands of electromechanical relaysthousands of electromechanical relays.
The schematic was commonly called “Ladder Schematic”
The Ladder displayed all switches, sensors, motors, valves, relays etc in the system.
Problems: Long commissioning time, Mechanical Reliance, Any system logic design change required the power to the control board to be isolated stopping production.
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 7
1.3 PLC Development1.3 PLC DevelopmentGeneral Motors was among the first to recognize a need to replace the systems “wired control board”
Goal – Eliminate the high cost associated with inflexible, relay controlled systems.
New Controller Specifications:◦ Solid State System◦ Computer Flexibility
O ( ) ◦ Operate in Industrial Environment (vibrations, heat, dust etc.) ◦ Capability of being reprogrammed◦ Easily programmed and maintained by electricians and
technicians.
Universiti Malaysia Pahang ©2011 snaim
1.3 PLC Development1.3 PLC DevelopmentIn 1969 Gould Modicon developed the first PLC.
St th P d ith L dd L i f ti Strength – Programmed with Ladder Logic, function block, statement list
Initially called Programmable Controllers PC’s Now - PLC’s, Programmable Logic Controllers
PLC’s have evolved from simple on/off control to being PLC s have evolved from simple on/off control to being able to communicate with other control systems, provide production reports, schedule production, diagnose machine and process faults.
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 8
1.3 PLC Development1.3 PLC Development
Universiti Malaysia Pahang ©2011 snaim
Wire Logic Vs PLCWire Logic Vs PLCITEM WIRED LOGIC PLC
Controlled Device (Hardware)
Specific Purpose General Purpose ( )Control Scale Small and Medium Medium and large
Change or addition to specification
Difficult Easy
Delivery period Several Days Almost immediate
Maintenance (by makers and users)
Difficult Easy and users)Reliability Depends on design and
manufacture Very High
Economic Efficiency Advantage on small scale operation
Advantage on small medium and large scale operation
17/10/2011
SNAIM (c) 2011 9
Advantageous of using PLC Advantageous of using PLC Shorter project implementation timeEasier modification without cost penaltyp yProject cost can be accurately calculatedShorter training time requiredDesign easily changed using softwareA wide range control applicationEasy maintenanceHigh reliabilityStandardization of Controller Hardware
What PLC Can Do?What PLC Can Do?CONTROL TYPE FUNCTIONS
Sequences Control •Conventional Relay Control Logic Replacer /P.C.B Card Controller Replacerp•Timers/Counters•Auto/Semi-auto/Manual Control of machine and Processes
Sophisticated Control / Regulatory Control
•Arithmetic Operation•Information handling•Analog Control (Temperature, Pressure)•P I D (Proportional-Integral-Derivation)P.I.D (Proportional Integral Derivation)•Servo Motor and Stepper Motor
Supervisory Control •Process Monitoring and Alarm•Fault Diagnostic and Monitoring•Interfacing with Computer -Printer/ASCII •Factory Automation•Local Area Network / Wide Area Network
17/10/2011
SNAIM (c) 2011 10
PLCs’ manufacturerPLCs’ manufacturerOMRONAllen BradleySchneider (Modicon, Telemecanique, Square D)GE FanucSiemensAutomation Direct (Koyo)ToshibaMitsubishiHitachiKeyenceFestoEberleTexas Instruments
HoneywellYokogawaEmerson
PLC operationPLC operation1. CHECK INPUT STATUS◦ First the PLC takes a look at each input to determine
if it is on or off. In other words, is the sensor if it is on or off. In other words, is the sensor connected to the first input on? How about the second input? How about the third... It records this data into its memory to be us
2. EXECUTE PROGRAM◦ Next the PLC executes your program one instruction
at a time. Maybe your program said that if the first input was on then it should turn on the first output input was on then it should turn on the first output. Since it already knows which inputs are on/off from the previous step it will be able to decide whether the first output should be turned on based on the state of the first input. It will store the execution results for use later during the next step.
17/10/2011
SNAIM (c) 2011 11
PLC operationPLC operation3. UPDATE OUTPUT STATUS◦ Finally the PLC updates the status of the outputs. It updates
the outputs based on which inputs were on during the first the outputs based on which inputs were on during the first step and the results of executing your program during the second step. Based on the example in step 2 it would now turn on the first output because the first input was on and your program said to turn on the first output when this condition is true.
Check i/p Status Execute Program Update o/p Status
2.0 PLC HARDWARE 2.0 PLC HARDWARE DESIGNDESIGN
17/10/2011
SNAIM (c) 2011 12
PLC ConfigurationPLC Configuration
Rack Mini
Shoe Box
Micro
PLC ConfigurationPLC ConfigurationThe configuration of PLC refers to the packaging of the components.
Typical configurations are listed below from largest to smallest.◦ Rack Type : A rack can often be as large as 18” by 30” by 10”
◦ Mini: These are similar in function to PLC racks, but about the half size. Dedicated Backplanes can be used to support the cards OR DIN rail mountable with incorporated I/O bus in module.
◦ Shoebox: A compact, all-in-one unit that has limited expansion biliti L t d t k th id l f ll capabilities. Lower cost and compactness make these ideal for small
applications. DIN rail mountable.
◦ Micro: These units can be as small as a deck of cards. They tend to have fixed quantities of I/O and limited abilities, but costs will be lowest. DIN rail mountable.
17/10/2011
SNAIM (c) 2011 13
Sizing of PLCSizing of PLC
Micro PLC: I/O up to 32 points
Small PLC: I/O up to 128 points
Medium PLC: I/O up to 1024 points
Large PLC: I/O up to 4096 points
Very Large: I/O up to 8192 points
Basic PLC SchemaBasic PLC Schema
CPUCPUPower SupplyMemoryInput BlocksOutput BlocksCommunicationsExpansion Connections
17/10/2011
SNAIM (c) 2011 14
CPU ModuleCPU Module
The Central Processing Unit (CPU) Module is the brain of the
SelfCheck
ExecuteC d
ScanInputs
UpdateO t t
PLC.Primary role to read inputs, execute the control program, update outputs.The CPU consists of the arithmetic logic unit (ALU), timing/control circuitry,
CodeOutputsaccumulator, scratch pad memory, program counter, address stack and instruction register.A PLC works by continually scanning a program
PLC ProgramSCAN
MemoryMemoryThe memory includes pre-programmed ROM memory containing the PLC’s operating system, driver programs and application programs and the RAM memory.
PLC manufacturer offer various types of retentive memory to save user-programs and data while power is removed, so that the PLC can resume execution of the user-written control program as soon as power is restoredrestored.
17/10/2011
SNAIM (c) 2011 15
Memory cont’dMemory cont’dMany PLCs also offer removable memory modules, which are plugged into the CPU module.
Memory can be classified into two basic categories: volatile and non-volatile.
- Volatile memory is that which loses state (the stored information) when power is removed.
- Nonvolatile memory, on the other hand, maintains the information in memory even if the power is interrupted.
Memory cont’dMemory cont’dSome types of memory used in a PLC include:
ROM (Read-Only Memory)ROM (Read-Only Memory)
RAM (Random Access Memory)
PROM (Programmable Read-Only Memory)
EPROM (Erasable Programmable Read-Only Memory)
EEPROM (Electronically Erasable Programmable Read-Only Memory)Only Memory)
FLASH Memory
Compact Flash – Can store complete program information, read & write text files
17/10/2011
SNAIM (c) 2011 16
I/O ModulesI/O Modules
Input and output (I/O) modules connect the PLC to sensors and connect the PLC to sensors and actuators.
Provide isolation for the low-voltage, low-current signals that the PLC uses internally from the higher-power electrical circuits required by
d most sensors and actuators.
Wide range of I/O modules available including: digital (logical) I/O modules and analog(continuous) I/O modules.
Inputs ModulesInputs ModulesInputs come from sensors that translate physical or chemical phenomena into electrical signals.
The simplest form of inputs are digital/discrete in
AC/DC.
In smaller PLCs the inputs are normally built in and are
specified when purchasing the PLC.
F l PLC h i h d d l For larger PLCs the inputs are purchased as modules, or cards, with 8,16, 32, 64, 96 inputs of the same type on each card.
17/10/2011
SNAIM (c) 2011 17
Inputs ModulesInputs Modules
The list below shows typical ranges for input voltagesranges for input voltages.
◦ 5 Vdc
◦ 12 Vdc
◦ 24 Vdc
◦ 48 Vdc
◦ 12 Vac
◦ 24 Vac
◦ 120 Vac
◦ 240 Vac
Outputs ModulesOutputs ModulesOutput modules rarely supply any power, but instead act as switches.
External power supplies are connected to the output card and the card will switch the power on or off for each output.
A common choice when purchasing output cards is relays, transistors or triacs.
Relay are the most flexible output devices. They are capable of switching both AC and DC outputs. But, they are slower, cost more, and they will wear out after millions of cycles.
17/10/2011
SNAIM (c) 2011 18
RelaysRelaysThe most important consideration when selecting grelays, or relay outputs on a PLC, is the rated current and voltage.
For transistor outputs or higher density output cards relay terminal blocks are available. terminal blocks are available. ◦ Advantage of individual standard
replaceable relays
Output ModulesOutput Modules
Typical output voltages are listed belowlisted below.
◦ 5 Vdc
◦ 12 Vdc
◦ 24 Vdc
◦48 Vdc
◦24 Vac
◦120 Vac
◦240 Vac
17/10/2011
SNAIM (c) 2011 19
Analogue Inputs/OutputsAnalogue Inputs/OutputsAnalogue input cards convert continuous signals via a A/D converter into discrete values for the PLC
Analogue output cards convert digital values in then PLC to continuous signals via a D/A converter.
Resolution can be important in choosing an applicable card
Example, for a temperature input of 0 to 100 degrees C◦ For 8 bit resolution the value in the PLC is 0 to 255
◦ For 12 bit resolution the value in the PLC is 0 to 4095◦ For 12 bit resolution the value in the PLC is 0 to 4095
◦ For 12.5 bit resolution the value in the PLC is 0 to 6000
◦ For 13 bit resolution the value in the PLC is 0 to 8192
◦ For 16 bit resolution the value in the PLC is 0 to 32768
Analogue CardsAnalogue CardsTypical Analogue Input signals are:
Analogue Output signals control:◦ Analogue Valves
◦ Flow sensors
◦ Humidity sensors
◦ Load Cells
◦ Potentiometers
◦ Pressure sensors
◦ Temperature sensors
◦ Analogue Valves◦ Analog Actuators◦ Chart Resorders◦ Variable Speed Drives◦ Analogue Meters
Typical Analogue Signal Levels
◦ Vibration ◦ 1-5 Vdc◦ 4-20mA◦ 0-10 Vdc◦ -10 – 10Vdc
17/10/2011
SNAIM (c) 2011 20
Special ModulesSpecial ModulesRF ID VoiceG Fl C l l i
Fast Response (Interrupt)PIDL C llGas Flow Calculation
Weigh CellHydraulic ServoASCIIFuzzy LogicTemperature SensorTemperature Control
Loop ControllerBASIC CardsRS232 Comm’s Modbus ASCII/RTUEthernet Comm’sHigh Speed CountersPosition Control Cardsp
Heat/Cool ControlField Bus Cards◦ DeviceNet, Profibus etc◦ Lonworks, BACNet
Per to Per Comm’s◦ Controller Link◦ DH+◦ Modbus Plus
NetworksNetworksASIDevicenet
Ethernet I/PSmart Distributed Devicenet
Interbus-SProfibusInterbusFieldbus
Smart Distributed System (SDS)SeriplexCANopenLonworksBACNet
• Gateways enable communications between different network topologies
17/10/2011
SNAIM (c) 2011 21
OMRON PLC OMRON PLC CQM1HCQM1H--CPU51CPU51
Universiti Malaysia Pahang ©2011 snaim
CQM1H CPU51CQM1H CPU51
Power Supply CPU unit Input Output
PA206
pp yUnit
CPU unit pModule
Output module
CQM1H-CPU51 0 CH OC 221
RS-232 PORT
INNERBOARDSLOT 1
INNERBOARDSLOT 2
17/10/2011
SNAIM (c) 2011 22
ConfigurationConfiguration
Universiti Malaysia Pahang ©2011 snaim
ConfigurationConfiguration
I/O point capacity : 512 points.CPU BlockCPU Block◦ Dedicated I/Os module up to 11 units
connectable.
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 23
ConfigurationConfiguration
CPU and Expansion I/O Block◦ CPU: Up to 5 units (exclude I/O Control unit)◦ CPU: Up to 5 units (exclude I/O Control unit)◦ Expansion: Up to 11 units (exclude I/O Interface
Unit)
Universiti Malaysia Pahang ©2011 snaim
Power ConsumptionPower Consumption
Important to select suitable power supply modulemodule.Requirement to power up each module that attached.
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 24
Power ConsumptionPower Consumption
Universiti Malaysia Pahang ©2011 snaim
Output unit current consumptionOutput unit current consumption
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 25
PLC WIRING SYSTEMPLC WIRING SYSTEM
Universiti Malaysia Pahang ©2011 snaim
Incoming Power SupplyIncoming Power Supply
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 26
I/Os wiring circuit I/Os wiring circuit -- inputinput
Input Card:
1 2 3 4 5 6 7 8 9 10
H H
G
F
E
D
G
F
E
D
COM 0000 0001 0002 0003 0004 0005 0006
X2: 11 X2: 12 X2: 13 X2: 14 X2: 15 X2: 16 X2: 17 X2: 18
K6.5
Universiti Malaysia Pahang ©2011 snaim1 2 3 4 5 6 7 8 9 10
C
B
A
C
B
A
NAME DATE
VERIFY BY
CHECK BY
DRAW BY
SheetDrawing Number
File Name Rev.
FKEE Skills Center,Faculty of Electrical & Electronics Engineering,KUKTEM,Locked Bag 12,25000 Kuantan, PahangPhone No: 09-5492318Fax No: 09-5492377Rev Decription Date
Title
Input Card <Drawing No>
ELECTRICAL_DRAWING_MCC2. vsd
2
SNAIM
<Name>
<Name>
05/12/2006
<date>
<date>
<Rev.>
SENSOR 1START Remote DCS1 /6.6
STOP SELECTORSWITCH
N24
P24
I/Os wiring circuit I/Os wiring circuit -- outputoutput
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 27
Inductive device connectionInductive device connection
Universiti Malaysia Pahang ©2011 snaim
Point assignmentPoint assignmentRack: 01FChannel: .Card: Digital Input - OCH
Point No.
Address Description Name Tag Lebel/mark
00 0000 Start PB1 0000
01 0001 Stop PB2
©snaim 2008
02 0002 Auto/manual SS1
03 0003 Sensor 1 S1
04 0004
17/10/2011
SNAIM (c) 2011 28
Address AssignmentAddress Assignment
Inputp0000
Input slot/channel no Input point no.
©snaim 2008
Address AssignmentAddress Assignment
Outputp10000
Input slot/channel no Input point no.
©snaim 2008
17/10/2011
SNAIM (c) 2011 29
Address AssignmentAddress Assignment
For CQM1H, the address are address are dedicated by the system (can’t setting by user)E.g.◦ Build in 0CH card is Build in 0CH card is
start from 00.00◦ Next second input
card will start at 01.00
Universiti Malaysia Pahang ©2011 snaim
CXCX--POGRAMMINGPOGRAMMING
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 30
Introduction Introduction –– PLC programmingPLC programmingStatement List
If PB1 AND PB2 then
set output1reset output2
Block Diagram
Ladder Diagram
Universiti Malaysia Pahang ©2011 snaim
Basic Element of LDBasic Element of LD
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 31
Anatomy of a LDAnatomy of a LD
Typically flows from left to right. • Divided into sections called rungs, • Each i/os instruction is assigned an address Each i/os instruction is assigned an address
indicating the location in the PLC memory where the state of that instruction is stored.
17/10/2011
SNAIM (c) 2011 32
CXCX--ProgrammerProgrammer
17/10/2011
SNAIM (c) 2011 33
Main windowsMain windows
LaderLader LogicLogic
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 34
LaderLader LogicLogic
Universiti Malaysia Pahang ©2011 snaim
AND ApplicationAND Application
IN A IN B OUTIN A IN B OUT
0 0
0 1
1 0
Universiti Malaysia Pahang ©2011 snaim
1 0
1 1
17/10/2011
SNAIM (c) 2011 35
AND Application AND Application -- exerciseexercise
MAN MODEMAN MODE&
PUSH START PB
GREEN LIGHT ON
Universiti Malaysia Pahang ©2011 snaim
GREEN LIGHT OFF
REMOTE MODE OR
RELEASE START PB
OR ApplicationOR Application
IN A IN B OUTIN A IN B OUT
0 0
0 1
1 0
Universiti Malaysia Pahang ©2011 snaim
1 0
1 1
17/10/2011
SNAIM (c) 2011 36
OR ApplicationOR Application
IN A IN B OUT
0 0
0 1
©snaim 2008
0 1
1 0
1 1
Latching / holding circuitLatching / holding circuit
To hold the output for desire rung.TechniqueTechnique◦ Or ladder◦ KEEP instruction◦ SET & RSET Instruction
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 37
Latching by using or functionLatching by using or function
Universiti Malaysia Pahang ©2011 snaim
KEEP InstructionKEEP Instruction
Purpose:◦ Defines a bit (B) as a latch, controlled by the
set (S) and reset (R) inputs.( ) ( ) pOperand Data Areas:◦ B: Bit IO, AR, HR, LR.
17/10/2011
SNAIM (c) 2011 38
Flow chart
start
Push Start button
I/O Assignments Input Devices
000.00 Start PB
000.01 Stop PB
100.01 Green Light
Green Light On
Push Stop Button
Green
Ladder Diagram
Light OFF
End
SET & RSET InstructionSET & RSET Instruction
•Turns ON B for an ON execution condition; does not affect B for an OFF execution condition.•Operand Data Areas:B: Bit IO, AR, HR, LR.
Turns OFF B for an ON execution condition; does not affect B for an OFF execution condition.Operand Data Areas:B: Bit IO, AR, HR, LR
17/10/2011
SNAIM (c) 2011 39
More Exercise….More Exercise….
Timer (TIM)Timer (TIM)
A timer is activated when its execution di i ON d i ( S) condition goes ON and is reset (to S)
when the execution condition goes OFF. Once activated, TIM measures in units of 0.1 second from the S.
Universiti Malaysia Pahang ©2011 snaim
N TC Number 000 - 511
S Set value (word, BCD)
IO, AR, DM, HR, #
17/10/2011
SNAIM (c) 2011 40
Timer (TIM)Timer (TIM)
If the execution condition remains ON long enough for TIM to time down to
ONON
long enough for TIM to time down to zero, the Completion Flag for the TC number used will turn ON and will remain ON until TIM is reset (execution condition goes OFF).
Universiti Malaysia Pahang ©2011 snaim
BASIC TIMER: EXERCISE 1BASIC TIMER: EXERCISE 1
Start
Push Start button
Timer 5 Sec?
Yes
No
Yellow Light ON
End
Yes
17/10/2011
SNAIM (c) 2011 41
BASIC TIMER: BASIC TIMER: EXERCISE 2EXERCISE 2
Start A
Select Manual Mode
Timer 5 Sec?
Yes
No
Timer 5 Sec?
Green Light ON
Select Auto
Yellow Light ON
End
Yes
A
Auto Mode
Yellow & Green Light
OFF
FLICKER: EXERCISE 3FLICKER: EXERCISE 3
Start A
Push Start button
Timer 1 Sec?
Yes
No
Timer 1 Sec?
Green Light OFF
Push StopGreen Light ON
End
Yes
A
Push Stop
System RESET
17/10/2011
SNAIM (c) 2011 42
FLICKER: EXERCISE 4FLICKER: EXERCISE 4
Start
Push Start button
A
Timer 1 Sec?
No
Timer 3 Sec?
Green Light
Yes
No
1 Sec?
Green Light OFF
Continuous Blinking
Yes
Light ON
End
A
Push Stop
System RESET
TIMER APPLICATIONTIMER APPLICATIONLab sheet 2 : Exercise 5
Input A i
Input DevicesAssignment0000 Start PB0001 Stop PB0002 Auto/Man SelectorOutput Assignment
Output Devices
10001 Green Light
Universiti Malaysia Pahang ©2011 snaim
g10002 Red Light10003 Yellow Light
17/10/2011
SNAIM (c) 2011 43
Counter (CNT)Counter (CNT)
CNT is used to count down from SV when the execution condition on the count pulse -CP, goes execution condition on the count pulse CP, goes from OFF to ON.The present value (PV) will be decremented by one whenever CNT is executed with an ON execution condition for CP and the execution condition was OFF for the last execution
Universiti Malaysia Pahang ©2011 snaim
N CNT Number
000 - 511
SV Set value (word, BCD)
IO, AR, DM, HR, #
Counter (CNT)Counter (CNT)
The Completion Flag for a counter is turned ON when the PV reaches zero and will
ONON
ON when the PV reaches zero and will remain ON until the counter is reset.CNT is reset with a reset input, R.When R goes from OFF to ON, the PV is reset to SV.
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 44
Timer and CounterTimer and Counter
Please note that TIM number and Please note that TIM number and CNT number should be unique (NOT SAME) in a same program.
E.g.
!E.g.◦ CNT000 then use TIM000 in same
program.
Universiti Malaysia Pahang ©2011 snaim
BASIC COUNTER: BASIC COUNTER: EXERCISE 6EXERCISE 6
Start
Push Start Button
Counter 5 X ?
Green Light ON
Yes
No
End
Push Stop Button
Green Light OFF
17/10/2011
SNAIM (c) 2011 45
TIME DELAYED 60 SEC: TIME DELAYED 60 SEC: EXERCISE 7EXERCISE 7
Start A
Push Start button
Timer 6 Sec?
Yes
No
Yellow Light ON
Push Stop
System
End
Yes
A
Counter 10 X?
yRESETNo
Yes
Extra exercise…Extra exercise…
MAN MODE NG PART ON &MAN MODE
OK PART BLINKING
AUTO MODE
RUN PART BLINKING &
NG PART ON &RUN PART OFF
STOP PB
IF STOP PB5 x
NO
Universiti Malaysia Pahang ©2011 snaim
BLINKING &OK PART OFF
START PB ALL PART OFF OR RESET SYSTEM
5 x
YES
17/10/2011
SNAIM (c) 2011 46
•DIFU & DIFD•INC & DEC•Shift Register•Move & Compare
INTERMEDIATE INTERMEDIATE PROGRAMPROGRAM
p•Interlocking
DIFU instructionDIFU instruction
Differential UP (rise edge)DIFU (13) turns ON the designated bit (B) for one scan on reception of the leading (rising) edge of the input signal
Universiti Malaysia Pahang ©2011 snaim
Operand Data Areas
B Bit IO, AR, HR, LR
17/10/2011
SNAIM (c) 2011 47
DIFD instructionDIFD instruction
Differential Down (fall edge)DIFD(14) turns ON the designated bit (B) for one scan on reception of the trailing (falling) edge of the input signal.
Universiti Malaysia Pahang ©2011 snaim
Operand Data Areas
B Bit IO, AR, HR, LR
DIFU DIFU vsvs DIFDDIFD
Universiti Malaysia Pahang ©2011 snaim
17/10/2011
SNAIM (c) 2011 48
MOVE instructionMOVE instruction
Copies the contents of S to D
Operand Data Areas
Universiti Malaysia Pahang ©2011 snaim
S Source Word IO, AR, DM, HR, LR, #
D Destination word
IO, AR, DM, HR, LR
Compares (CMP) instructionCompares (CMP) instruction
Compares Cp1 and Cp2 and;Outputs the result to the GR, EQ and LE flags in the SR area
Operand Data Areas
Universiti Malaysia Pahang ©2011 snaim
Cp1 1st compare word
IO, AR, DM, HR, TC, LR, #
Cp2 2nd compare word
IO, AR, DM, HR, TC, LR, #
17/10/2011
SNAIM (c) 2011 49
Increment (INC) instructionIncrement (INC) instruction
Increments Wd, without affecting Carry (CY)Carry (CY).For INC(38) and DEC(39) the source and result words are the same. That is, the contents of the source word is overwritten with the instruction result.
Universiti Malaysia Pahang ©2011 snaim
Operand Data Areas
Wd Increment Words
IO,AR,DM,HR,LR
Decrement (DEC) instructionDecrement (DEC) instruction
DEC(39) decrements Wd, without ff i CY affecting CY.
DEC(39) works the same way as INC(38) except that it decrements the value instead of incrementing it.
Universiti Malaysia Pahang ©2011 snaim
Operand Data Areas
Wd Decrement Words
IO,AR,DM,HR,LR