Il 0% ha trovato utile questo documento (0 voti)
60 visualizzazioni33 pagine

06-Programmazione Step 7

Caricato da

maxy1985
Copyright
© © All Rights Reserved
Per noi i diritti sui contenuti sono una cosa seria. Se sospetti che questo contenuto sia tuo, rivendicalo qui.
Formati disponibili
Scarica in formato PPT, PDF, TXT o leggi online su Scribd
Il 0% ha trovato utile questo documento (0 voti)
60 visualizzazioni33 pagine

06-Programmazione Step 7

Caricato da

maxy1985
Copyright
© © All Rights Reserved
Per noi i diritti sui contenuti sono una cosa seria. Se sospetti che questo contenuto sia tuo, rivendicalo qui.
Formati disponibili
Scarica in formato PPT, PDF, TXT o leggi online su Scribd
Sei sulla pagina 1/ 33

Programmazione STEP 7

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 1
Introduzione : Struttura di Programma

Programma Lineare Programma Strutturato

DB
OB 1 OB 1 FC FB FC

DB
FC FC FB

FC FC SFC

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 2
Struttura del Programma: Tipi di Blocchi (Blocchi utente)

Tipi di blocco Proprietà Miglioramenti rispetto STEP 5

Blocchi orga- - Interfaccia utente-sistema operativo - Richiamo solo da sist.op.


nizzarivi (OB) - priorità (1...27) - maggiori informazioni iniziali
- Informazioni iniziali nello stack dati locali - priorità parametrizzabile
- tutte le istruzioni eseguibili

Blocchi - Assegnazione parametri / con memoria - variabili statiche


Funzionali (FB) - senza assegnazione parametri / con memoria - DB d’istanza
-senza assegnazione parametri / senza memoria - non occorre specificare
tutti i parametri

Funzioni (FC) - un valore di ritorno da trasferire (tutti - corrispondono ai Pb e FB


i parametri devono essere assegnati nel richiamo) - tutte le istruzioni eseguibili
- fondamentalmente senza memoria - quasi tutte le istruzioni in
- possibilità di assegnare parametri KOP / FUP

- direttamente accessibili
Blocchi dati - Memoria di dati locali (DB d’istanza) tutti i 8/64KB
(DB) - Memoria di dati globali - accesso simbolico
(validi nell’intero programma) - possibilità di aprire 2 DB
- strutture di dati

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 3
Struttura di Programma: Tipi di blocchi (blocchi di sistema)

Tipi di blocco Proprietà Miglioramenti rispetto S5

Blocchi - FB (con memoria) residenti nella CPU - maggiori funzioni di sistema


funzionali che possono venir richiamati dall’utente - blocchi uguali
di sistema (SFB) per S7-300/400
- blocchi reperibili offline
Funzioni di - FC (senza memoria) residenti nella CPU, nelle biblioteche
sistema (SFC) che possono venir richiamati dall’utente

Blocchi dati - blocchi dati per memorizzare la - Non servono impostazioni


di sistema (SDB) configurazione e parametrizzazione Sulle schede

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 4
Struttura di Programma: Struttura del blocco

STEP 5 STEP 7

Intestazione blocco (10 byte)


Intestazione blocco (36 byte)
Corpo del blocco :
Corpo del blocco :
Parte dichiarazione
Parte dichiarazione
e
e
parte di programma
parte di programma
o
o
dati
dati

Pre-Intestazione blocco Descrizione interfaccia


compressa
(memorizzata su FD/HD)
(memorizzata sulla CPU)

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 5
Struttura di Programma: Richiamo blocchi in AWL

STEP 5 STEP 7
Richiamo blocco
Con o senza parametri Senza parametri Con parametri

Call FC n Call FC n
Richiamo Call FB n, DB m Call FB n, DB m
SPA PB n
Incondizionato SPA FB m UC FC n
UC FB n ---

U E 1.0 U E 1.0
SPBN M001 SPBN M001
Call FC/FB n Call FC/FB n
Richiamo M001: NOP 0 Par1: E 1.2
SPB PB n Par2: A 4.0
Condizionato SPB FB m M001: NOP 0

U E 1.0
CC FC/FB n ---

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 6
Novità in STEP 7: fronte di salita dell‘ RLC
KOP FUP AWL

U E1.0
E1.0 E1.1 M1.0 M8.0 E1.0 &
M1.0 M8.0 U E1.1
P FP M1.0
E1.1 P = = M8.0

E1.0 E1.1 M1.1 M8.1 E1.0 U E 1.0


& M8.1 U E 1.1
M1.1
N FN M1.1
E1.1 N = = M8.1

Ciclo OB1
E1.0

E1.1

RLC
Esempio
M1.0

M1.1

M8.0
M8.1

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 7
Novità in STEP 7: fronte di salita del segnale
KOP FUP AWL

E1.1 E1.0 & U E1.0


E1.0 M8.0 E1.1 U (
POS POS M8.0 U E1.1
Q
M1.0 M_BIT = FP
M1.0 M_BIT M1.0
)
E1.1 E1.0 =
E1.0 M8.1 & M8.0
NEG E1.1
Q NEG M8.1 U E1.0
U (
M1.1 M_BIT M1.1 M_BIT = U E1.1
FN
M1.1
E1.0 )
=
E1.1 M8.1

Esempio M1.0

M1.1
Ciclo OB1
M8.0

M8.1

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 8
Novità in STEP 7: Istruzioni che influenzano l‘RLC
KOP FUP AWL

U E0.0
E0.0 E0.1
A8.0 E0.0 & U E0.1
NOT A8.0
NOT ( ) E0.1 = NOT
= A8.0

CLR Non disponibile Non disponibile CLR

SET Non disponibile Non disponibile SET

E1.6 U E1.6
SAVE ( SAVE ) E1.6 & SAVE SAVE

BIE A8.1 A8.1 U BIE


BIE ( ) BIE = = A 8.1

15 8 0
Parola di
Stato BIE RLC

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 9
Parola di stato: Nuove istruzioni in S7

Significato dei bit della parola di stato (STW)

Bit Sigla Significato

0 /ERAB Prima istruzione

1 RLC Ris. Logico Combin.

2 STA Stato

3 OR Bit di Or Esempi

4 OS Memorizz. Overflow U OV Controllo Overflow


U OS Controllo Overflow con memoria
5 OV Overflow
Test dei bit di Visualizz. (A0, A1)
6 A0 Bit di Visualizzazione U == 0 Risultato uguale a 0
U > 0 Risultato maggiore di 0
7 A1 Bit di Visualizzazione U <> 0 Risultato diverso da 0
U =< 0 Risultato minore o uguale a 0
8 BIE Risultato binario

9...15 non assegnati --

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 10
Istruzioni di Caricamento

STEP 5 STEP 7

L KB 5 L5
L KF 1000 L 1000
L KG +1234567 +02 L 12.34567
L KH 8FFE L W#16#8FFE
L KC 'OTTO' L 'OTTO'
L KT 5.2 L S5T# 5s
L KZ 10 L C# 10
L KM 1001111100001100 L 2# 1001111100001100
L KY 100,12 L B# (100,12)
---- L B# (100,12,50,8)

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 11
Operazioni aritmetiche e di complemento

STEP 5 STEP 7

+F, -F, xF, :F +I, -I, *I, /I


ADD KB, ADD KF + intero a 8 bit, + intero a 16 bit
+D, -D +D, -D, *D, /D, MOD
ADD DH + intero a 32 bit
+G, -G, xG, :G +R, -R, *R, /R

KEW INVI //complemento a 1


---- INVD //complemento a 1
KZW NEGI //complemento a 2
KZD NEGD //complemento a 2
---- NEGR //complemento a 2

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 12
Operazioni di scorrimento

STEP 5 STEP 7

SRW 0..15 SRW 0..15 // Shift a destra


SLW 0..15 SLW 0..15 // Shift a sinistra

---- SRD 0..32 // Shift a destra


SLD 0..32 SLD 0..32 // Shift a sinistra

SSW 0..15 SSI 0..15 //Shift dx con segno


SSD 0..32 SSD 0..32 //Shift dx con segno

RLD 0..32 RLD 0..32 // Rotazione a sx


RRD 0..32 RRD 0..32 // Rotazione a dx
---- RLDA
---- RRDA

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 13
Operazioni di conversione

STEP 5 STEP 7

DEF BTI
DUF ITB
DED BTD
DUD DTB
---- ITD
FDG DTR
GFD RND, RND+, RND-, TRUNC

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 14
Operazioni di confronto

STEP 5 STEP 7

!=F, ><F ==I, <>I


>F, >=F, <F, <=F >I, >=I, <I, <=I

!=D, ><D ==D, <>D


>D, >=D, <D, <=D >D, >=D, <D, <=D

!=D, !=G ==R, <>R


>G, >=G, <G, <=G >R, >=R, <R, <=R

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 15
Operazioni logiche a parola

STEP 5 STEP 7

UW UW // AND a parola
OW OW // OR a parola
XOW XOW // XOR a parola

---- UD // AND a doppia parola


---- OD // OR a doppia parola
---- XOD // XOR a doppia parola

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 16
Nuove istruzioni di salto in STEP 7
Istruzioni di salto Significato

SPMZ Salta se il risultato <=0


SPPZ Salta se il risultato >=0
SPU Salta se numero reale non valido / divisione per 0
SPBN Salta se RLC = 0
SPBB Salta se RLC = "1" Salva RLC in BIE
SPBNB Salta se RLC = "0“ Salva RLC in BIE
SPBI Salta se BIE = "1"
SPBIN Salta se BIE = "0"

Distributore di salti

L Ricetta_Nr. // Carica ricetta numero


SPL OVER; // distributore di salti con 3 entrate
SPA Ric0; // Salta alla ricetta Nr. 0 (se Accu =0)
SPA Ric1; // Salta alla ricetta Nr. 1 (se Accu =1)
SPA Ric2; // Salta alla ricetta Nr. 2 (se Accu =2)
OVER: SPA ERR // Salta all’etichetta ERRore se
// ACCU >2 o <0
...
Ric0: L DBW4
...
SIMATIC S7 Date: 28.04.25 Information and Training Center
Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 17
Istruzione di Loop STEP 7

Esempio di programma con LOOP:

L 12 Inizializza il numero di cicli


BEG: T MW 100 inizio del ciclo
... ...
... ...
... ...
L MW 100 carica il contatore dei cicli

LOOP BEG salta a BEG fino a che MW100 > "0"

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 18
Elaborazione valori analogici
STEP 5 STEP 7

Valore misurato 2048 27648


su una scheda analogica

Bit nascosti L PW 128 L PEW 256


d’informazione SVW 3

High byte Low byte High byte Low byte


15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

212 211 210 29 28 27 26 25 24 23 22 21 20 U F OV S 214 213 212 211 210 29 28 27 26 25 24 23 22 21 20


S

Scalatura FB 241 FC 105, valori scalati


FB 242 FC 106, Valori de-scalati
FB 243
FB 250
FB 251
(secondo il tipo di scheda) (indipendente dalla scheda)

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 19
Novità in STEP 7: Master Control Relè
KOP FUP AWL

( MCRA ) MCRA MCRA // Attiva

E0.0
U E0.0 // Abilita MCR
( MCR< ) E0.0 & MCR<
MCR( // Apre MCR

E0.7 A8.5 A8.5


( ) U E0.7 // Contatto NA
E0.7 & =
= A8.5 // Segnale d‘uscita
M0.6 M0.6
= M0.6 // Segnale d‘uscita
( ) =

A16.0 A16.0 U E0.4 // Contatto NA


E0.4
(S) E0.4 & S S A16.0 // Set Output

( MCR> ) MCR> )MCR // chiude MCR

M69.0 UN M5.5 // Contatto NC


M5.5 I4.7 M5.5 M69.0
( ) & UN E4.7 // Contatto NC
E4.7 =
= M69.0 // Segnale d‘uscita
( MCRD ) MCRD
MCRD // Disattiva

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 20
Esercizio: Gestione di un impianto d'imbottigliamento
Impianto ON/OFF: Modo Manuale/Automatico:
E0.0 = Start (Pulsante NA) E0.4 = Manuale/Automatico (Selettore)
E0.1 = Stop (Pulsante NC) E0.5 = Comando di selezione
(Pulsante NA)
E0.2 = Comando avanti (Pulsante NA)
E0.3 = Comando indietro (Pulsante NA)

Sensore
presenza
E 16.6 (E 8.6)

M
A 20.5 (A 8.5) Nastro trasportatore avanti
A 20.6 (A 8.6) Nastro trasportatore indietro

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 21
Esercizio: Programma per un Impianto di Imbottigliamento
(Ciclo di Riempimento e Conteggio Bottiglie)
ON/OFF Impianto:
E 0.0 = Start (Contatto NA)
E 0.1 = Stop (Contatto NC) Contenitore
principale
Modo Manuale/Automatico:
E 0.4 = Manuale/Automatico (Selettore)
E 0.5 = Comando di selezione (pulsante NA)
E 0.2 = Comando avanti (Pulsante NA)
E 0.3 = Comando indietro (Pulsante NA) A 9.0 (A 5.0) Sensore presenza
Sensore Valvola di riempimento E 16.7 (E 8.7)
presenza
Sensore presenza E 16.6 (E 8.6)
E 16.5 (E 8.5)

M
A 20.5 (A 8.5) Nastro Trasportatore avanti
A 20.6 (A 8.6) Nastro Trasportatore indietro

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 22
Esercizio: Impianto imbottigliamento (Dati di Produzione)

Bottiglie vuote MW 100

Bottiglie piene MW 102

Bottiglie rotte MW 104

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 23
Esercizio: Impianto imbottigliamento (Numero di confezioni)

AW12

U(
Programma scritto in KOP
L MW 102
L 6
/I
Programma convertito in AWL
T MW 110
UN OV
Programma scritto in AWL SAVE
CLR
U BIE
L MW 102 )
L 6 SPBNB _001
/I L MW110
ITB ITB
T AW12 T AW12
001: NOP 0

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 24
PossibiIità d‘indirizzamento in STEP 7

Procedura d‘indirizzamento

Indirizzamento diretto indirizzamento indiretto

assoluto simbolico Con memorie Con registri

Aree interne Aree interne Aree interne Aree esterne


con puntatori con puntatori con puntatori con puntatori
a 16 bit a 32 bit a 32 bit a 32 bit

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 25
Indirizzamento diretto

Area Indirizzo Ampiezza Significato


(es.) Accesso
E 37.4 Byte, word, Ingressi
double word
A 27.7 Byte, word, Uscite
double word
PEB 655 Word, Ingressi di Periferia
double word
PAB 653 Word, Uscite di Periferia
double word
M 55.0 Byte, word, Bit di merker
double word
T 114 -- Temporizzatori
Z 13 -- Contatori
DBX 2001.6 Byte (DBB), word (DBW), Dati indirizzati con
double word (DBD) registro DB
DIX 406.1 Byte (DIB), word (DIW), Dati indirizzati con
double word (DID) registro DI
L 88.5 Byte (LB), word (LW), Dati locali
double word (LD)

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 26
Indirizzamento indiretto con memorie
STEP 7 STEP 5

L 11 L KF11
1. Indirizzamento T MW 60 T MW 60
indiretto con puntatori AUF DB [MW 60] B MW 60
a 16 bit in memorie A DB 0
AUF DB 11 A DB 11

L P#24.0 L KF24
2. Indirizzamento T MD 50 T MW 50
indiretto con puntatori L EW [MD 50] B MW 50
a 32 bit in memorie L EW 0
L EW 24 L EW 24

L E W [MD 50]
Istruzione Area Ampiezza Indirizzo

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 27
Esempio di indirizzamento indiretto con memorie

FC30: Esempio d‘indirizzamento indiretto

Segmento 1: Apri DB con l’indirizzamento indiretto

L #numero_DB // Copia il numero della DB nella MW100


T MW 100 //
AUF DB[MW 100] // Apre DB

Segmento 2: Loop per l’azzeramento di 10 word

L P#18.0 // memorizza l'indirizzo finale (DBW18)


T MD 40 // come puntatore nella MD 40;
L 10 // Inizializza il contatore del loop a 10
beg: T MB 50 // e appoggialo sulla MB 50;
L 0 // Carica il valore
T DBW[MD 40] // e trasferiscilo sulla DB;
L MD 40 // Carica il puntatore
L P#2.0 // e decrementalo di 2 byte
-D // e ritrasferiscilo
T MD 40 // su se stesso;
L MB 50 // Carica il contatore dei Loop
LOOP beg // decrementalo e ritorna a ‘beg’;

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 28
Registri della CPU

Registri Bit

Accu 1 * Accumulatore 1 Bits 0...31


Accu 2 * Accumulatore 2 Bits 0...31
STW Parola di stato Bits 0...15
AR 1 Registro Indirizzi1 Bits 0...31
AR 2 Registro Indirizzi2 Bits 0...31
DB 1° registro DB Bits 0...15
DI 2° registro DB Bits 0...15
DBLG Lunghezza del 1° DB Bits 0...15
DILG Lunghezza del 2° DB Bits 0...15

* in S7 - 400 vi sono anche gli accumulatori ACCU 3 e ACCU 4

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 29
Struttura del Registro Indirizzi

31 ... ... ... ... ... ... 24 23 ... ... ... ... ... ... 16 15 ... ... ... ... ... ... 8 7 ... ... ... ... ... ... 0

1 R R R B B B B B B B B B B B B B B B B X X X

Indirizzo al Byte Indir.


al bit.

Indirizzo all‘area-interna

R R R Identificatore d‘area per:


000 Periferie
001 Ingressi (IPI) identificatori
010 Uscite (IPU) per l‘indirizzo
011 Merker all‘area esterna
100 Dati nel 1° Registro DB (DB)
101 Dati nel 2° Registro DB (DI)
111 Dati locali del bl. chiamante

1 Il Registro Indirizzi contiene un indirizzo con un identificatore d’area


0 Il Registro Indirizzi non contiene un indirizzo con un identificatore d’area

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 30
Indirizzamento indiretto ad un‘area interna

Formato generico puntatore


31 ... ... ... ... ... ... 24 23 ... ... ... ... ... ... 16 15 ... ... ... ... ... ... 8 7 ... ... ... ... ... ... 0

R R R B B B B B B B B B B B B B B B B X X X

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0

AR1 dopo l‘istruzione: LAR1 P#10.0

Esempio
LAR1 P#10.0
L MW [AR1, P#200.0]

M W [AR1, P#200.0]
Area Ampiezza Registro Costante
Accesso indirizzi di offset

L MW 210

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 31
Indirizzamento indiretto ad un‘area esterna

Formato generico puntatore


31 ... ... ... ... ... ... 24 23 ... ... ... ... ... ... 16 15 ... ... ... ... ... ... 8 7 ... ... ... ... ... ... 0

R R R B B B B B B B B B B B B B B B B X X X

1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0

AR1 dopo l‘istruzione : LAR1 P#E100.0

Esempio
LAR1 P#E100.0
L B [AR1, P#110.0]

B [AR1, P#200.0]
Ampiezza Registro Costante
Accesso indirizzi di offset

L EB 210

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 32
Protezione di un blocco utilizzando il Programma sorgente

Sorgente senza protezione al blocco blocchi Sorgente senza protezione al blocco


modificabili

OB De-
Com- com-
pilazione pilazione
FB

FC

Sorgente con protezione del blocco blocchi non


modificabili

Com- OB
pilazione
FB

FC

SIMATIC S7 Date: 28.04.25 Information and Training Center


Knowledge for Automation
Siemens AG 1997. All rights reserved. Dia: 33

Potrebbero piacerti anche