Basic programming
Step7 Basic-1
2|krones
krones Akademie
Beispieltext
– Step7 Basic-1
Basic-Programming Languages
− Ladder diagram (LAD)
• graphic programming language
• close to wiring schematics
− Function block diagram (FBD)
• graphic programming language
• uses symbols known from Boolean
algebra
− Statement List (STL)
• text based programming language
• close to machine language
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
3|krones
krones Akademie
Beispieltext
– Step7 Basic-1
Symbols
= Table for allocation of symbols to adresses:
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
4|krones
krones Akademie
Beispieltext
– Step7 Basic-1
Symbol table
− Is automatically created by step7 within
every project
− Manual insert:
Insert Symbol Table
creates a new Symbol Table
− Symbol table can also be opened by double-clicking
at the program editor
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
5|krones
krones Akademie
Beispieltext
– Step7 Basic-1
Exercise 1
− Create OB 1
− Create FC 1: „0000_BIT_PROG“
− Call FC 1 in OB 1
− Insert Network, add Name and Comment
− Simple series- and parallel connection
− monitor online
− Add symbolic names for each operands and objects
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
6|krones
krones Akademie
Beispieltext
– Step7 Basic-1
Further CPU Configurations
− Clock memory
− Scan cycle monitoring time
− CPU protection
− Retentive memory
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
7|krones
krones Akademie
Beispieltext
– Step7 Basic-1
Clock pulse flag
− With a clock pulse flag, a bit of a clock pulse flag
byte is provided whose frequency is permanently
set and whose binary state periodically changes at
a ratio of 1:1. The clock pulse flag byte to be used is
defined in the hardware configuration of the CPU
− This clock pulse flag is programmed as a simple flag
(e.g. M1.5 in our example)
Clock pulse flag bit
of the clock pulse Mx.7 Mx.6 Mx.5 Mx.4 Mx.3 Mx.2 Mx.1 Mx.0
flag byte
FREQUENCY IN HZ 0,5 0,625 1 1,25 2 2,5 5 10
Duration of period
2 1,6 1 0,8 0,5 0,4 0,2 0,1
in seconds
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
8|krones
krones Akademie
Beispieltext
– Step7 Basic-1
Cycle time monitoring
− Enter the cycle monitoring time in the CPU properties
under "Cycle/Clock Memory."
− When the cycle time exceeds the cycle monitoring time,
the CPU enters the STOP operating point.
− Cause for an exceeding:
- Communication processes
- Increasing frequency of alarm events
- Fault in CPU program
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
9|krones
krones Akademie
Beispieltext
– Step7 Basic-1
Protection of the CPU
− Protective stage 1:
Corresponds to the preset behaviour
− Protective stage 2:
Only reading access is possible, independently of
the position of the key switch
− Protective stage 3:
Neither reading nor writing access is possible,
independently of the position of the key switch
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
krones
10| krones Beispieltext
Akademie – Step7 Basic-1
Retentivity
− In the "Retentive Memory" tab, you can determine
which memory areas are retained after a power failure
and after a transition from STOP to RUN, even without
battery buffering (in the backup memory of the CPU).
Whether or how much retentive areas can be planned
depends on the CPU
− If a buffer battery is inserted, data blocks are always
retentive
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
krones
11| krones Beispieltext
Akademie – Step7 Basic-1
Exercise 2
− Create FC2
− Test clock pulse memory
• Outputs flashing
− Insert OB121 and test behaviour of plc including a programming error
(e.g. not existing adresses)
− Insert OB 100 (Startup-OB) and call FC 100
− In FC 100:
• Create logic 0 (M0.0) and
• logic 1 (M0.1)
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
krones
12| krones Beispieltext
Akademie – Step7 Basic-1
Further Functions within the object library
− Flip Flops
− Compare
− Counter
− Time
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
krones
13| krones Beispieltext
Akademie – Step7 Basic-1
Save programm in static memory
− After the block comparison, the current program can
now be loaded with the current parameters in the
memory card
− This can be performed under "PLC"
"Download User Program to Memory Card."
− In case of a power failure or memory reset, the
saved current parameters are loaded from the static
to the dynamic memory.
It is thus important to have saved as the most
current parameters possible before an MRES.
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
krones
14| krones Beispieltext
Akademie – Step7 Basic-1
Exercise
− Programming your own counter without using an existing counter function of the library
− Create FC3: „0000_Counter“ and call within OB1
− Programming language FC3: Function block diagramm
Network 1
− The SR FlipFlop M10.0 is setted by Input I61.0 and resetted by Input I61.1
− Is the FlipFlop setted and with every positive edge of Memory M1.5 (every Second) the Value
of Memorybyte MB20 will be increased by +1
Network 2
− Input I61.2 resets the Value of MB20 back to 0
− Testing of saving in static Memory (download user programmm to memory card)
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
krones
15| krones Beispieltext
Akademie – Step7 Basic-1
Characteristics of Functions and Functionblocks
Function Functionblock
− Single output − Several outputs
− No internal memory (no static variables) − Internal memory
− To be called many times − Used for complex and returning programm
applications
− Can be called several times (instances)
− Own name and Datablock for each instance
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
krones
16| krones Beispieltext
Akademie – Step7 Basic-1
Funktionblock declaration of variables
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
krones
17| krones Beispieltext
Akademie – Step7 Basic-1
Exercise
− Create FB3: „0000_MyCounter“
− Programming language FB3: Function Block Diagram
− Transfer functionality from FC3
− Declare variables:
• Input: Start, Stop, Reset BOOL
• Output: CounterValue INTEGER
• Static: SR FlipFlop and Pos-Edge
− Create DB 31 and DB 32 as Instance-DBs of FB3
− Call both instances of FB3 in FC3
− Wire inputs to simulation card switches and outputs to memorywords
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
krones
18| krones Beispieltext
Akademie – Step7 Basic-1
Data blocks
− Data blocks are created and opened like program blocks. They are used to save data and
system states, for example.
− The data block is created by entering a symbolic name, type, starting value, and comment
(optional) for every data element.
− The address is automatically generated and cannot be changed.
− The DBs have a declaration view and data view in which the current values are also listed.
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
krones
19| krones Beispieltext
Akademie – Step7 Basic-1
Exercise
− Create DB 3
− Insert array from 0..10 in declaration view
− Insert sruct type in array in declaration view
− insert MyCounter variables to struct:
• Start BOOL
• Stop BOOL
• Reset BOOL
• CounterValue INTEGER
− Update wireing in FC 3
KRONES AG 2014 - Verwendung, Vervielfältigung und Verbreitung sind ohne Zustimmung des Autors nicht gestattet.
Vielen Dank!