Programming Examples I

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Programming Examples I

Example 1:

Write a program (instruction list) to put the number (4000) in a memory location, and the
number (41) in another location. divide the first one by the second and put the result in a
memory location.

solution:

Example 2:

Make a program to increase the counter by one with each pulse from the pulse generator
SM0.4 (on rising edge) , and decrease another counter by the same pulse.

Solution:
steps of solution would be like
this:

1. put zero in memory location


vw100.

2. put (10) in the memory


location vw110.

3. with each rising edge from


SM0.4 (every 30 sec), we
increase memory location vw100
by one. and at the same time
decrease vw110 by one. the
program will continue like that
without any instruction to stop.

#please note that:


MOVW => move word
INCW => increment word
DECW => decrement word

Programming
Examples II
Example 3:

Put a value in memory location vw200, and using shifting method, move this value to the
output of the PLC.

Solution:
when we press the PLC input button (I0.0), the PLC will put the value (980) inside memory
location vw200, and when the rising edge of the pulse arrives, the contents of memory
location will be shifted to the left for one bit (the instruction SLW = shift left word). we could
put 2 after # to shift two bits to left. If we put 7 after the #, the overflow indicator will be
activated (SM1.1=1) which will activate the output in question.

here is the ladder diagram:

Example 4:
Using two timers, write a program so we have a pulse on PLC output with (TON = 10 sec.)
and (TOFF = 10 sec.)
*TON: timer output on, TOFF: timer output off.
Solution:

Example 5:

Using up-counter (CTU), make the PWM algorithm.

solution:
there is inside the PLC places for generating a series of pulses with fixed durations, one of
these places is SM0.5, it generates a pulse of 1 second (on time is 0.5 sec and off time is 0.5
sec). another one is SM0.4, it generates a 60 second pulses.

.. and timing diagram:

Index:

o Introduction to PLCs
o PLC History
o PLC Hardware
o PLC Operation
o PLC Communications
o PLC Communication II
o RS-232 Communications
o RS-485 interface
o ISO/OSI model
o ISO/OSI Protocols
o Sinking Sourcing I/O
o PLC Input Units
o PLC Output Units
o Analog Input/Output Modules
o Choosing the correct I/O hardware
o PLC Networks
o PLC Programming
o PLC Instructions
o PLC Instructions II ‘Timers’
o PLC Instructions III ‘Counters’
o Advanced Instructions
o Advanced Instructions II
o Programming Examples I
o Programming Examples II
o Programming Examples III
o Programming Examples IV
o Programming Examples V
o Programming Examples VI
o Programming Examples VII
o Vendor selection
o Siemens PLC vs Allen Bradley PLC
o PLC selection criteria
o Choosing the correct processor
o PLC Installation & Commissioning
o Distributed Control Systems
o SCADA
o Industrial Safety Systems
o Signature Image Processing (SIP)
o Programmable Automation Controller
o Common Industrial Protocol (CIP)
o PROFIBUS
o CoDeSys
o HART Communications Protocol
o Fault detection techniques
o Troubleshooting
o Troubleshooting II
o Applications
o PLC LAN Applications
o Important online PLC and Automation resources
o PLC Books

You might also like