Programming Support

Programming Languages

A program loaded into PLC systems in machine code, a sequence of binary code numbers to represent the program instructions. Assembly language based on the use of mnemonics can be used, and a computer program called an assembler is used to translate the mnemonics into machine code. High level Languages (C, BASIC, etc.) can be used.

Programming Languages

PLC can be reprogrammed through an appropriate programming device:

Programming Console


Hand Programmer

Introduction to Ladder Logic

Ladder logic uses graphic symbols similar to relay schematic circuit diagrams. Ladder diagram consists of two vertical lines representing the power rails. Circuits are connected as horizontal lines between these two verticals.

Ladder diagram features

Power flows from left to right. Output on right side can not be connected directly with left side. Contact can not be placed on the right of output. Each rung contains one output at least. Each output can be used only once in the program. A particular input a/o output can appear in more than one rung of a ladder. The inputs a/o outputs are all identified by their addresses, the notation used depending on the PLC manufacturer.


Introduction to Statement list

Statement list is a programming language using mnemonic abbreviations of Boolean logic operations. Boolean operations work on combination of variables that are true or false. A statement is an instruction or directive for the PLC.

Function Block Diagrams

Function block is represented as a box with the function name written in.

please note: LD: load O: or AN: and not (and a normally closed contact)
ALD: AND the first LD with second LD

Example 1:

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.


Example 2:

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.


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

Example 3:

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

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:

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.

Example 5:

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

5. 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.

6.Timing diagram

Contact Us