Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Beckhoff
TwinCAT
Beckhoff
Lightbus
Beckhoff
Embedded PC
Beckhoff Beckhoff
EtherCAT Drive Technology
1 09.07.2007
Control basado en PC
Evolución en control
Hardware Software
IPC Mechanic Electronic IPC
Slots/CPUs Tasks
Prog. Prog.
HMI par. Connect Fieldbus HMI
Tool Tool
Comm. direct Access
Komm.
Router
RT-Kernel
PLC 1
PLC 2
E/A
..
NC
CPU
E/A
NC
Mapping
Fieldbuses
2 09.07.2007
Qué es TwinCAT ?
3 09.07.2007
Posibles soluciones
a s
Potencia
fo rm
l ata
s p
s l a I
o d a NC
ra t P ,
P a P T
AT : N C
C C ,
w in , P L
T I /O
AT :
w inC
T
PC
CX1000
BCxxxx
BXxxxx Coste
4 09.07.2007
TwinCAT: Arquitectura
TwinCAT
No modifica Windows
No necesita hardware especial
Convierte Windows en un Real Time OS.
Floating Point Unit (FPU) fully supported
Completo acceso desde Windows por medio de ADS via OCX, Dll
Acceso Remoto via TCP/IP
PC platform
Hardware Standar,
Utiliza los recursos del PC
use of mainstream operating system (Windows)
Fácil Integración con la red ofimática
open field bus communication
5 09.07.2007
Plataforma PC
TwinCAT System
Usermode
Diagnose PLC User User
SysMan
i.e. Scope Control HMI HMI
ADS ADS ADS ADS OPC
OCX/Dll OPC
TCP/IP
ADS Router
Windows NT, 2000, XP
Realtime Server
Kernelmode
Server Server i.e. CAM
I/O I/O I/O I/O
Server
I/O Mapping
Fieldbus Card Drivers
6 09.07.2007
TwinCAT real-time
7 09.07.2007
TwinCAT on a CX1000 platform
TwinCAT
Almacenamiento cíclico de variables retentivas
Programación del display
Safe operation
TwinCAT real-time sobrevive a BSOD (pantallas azules)
Motherboard diagnosis for fan/temperature
Performance
Tiempo de ciclo minimo 50µs
8 09.07.2007
TwinCAT en una plataforma BXxxxx
TwinCAT
• Descargar y recuperar el código fuente
• Depuración online/ Cambio online
• Acceso remoto desde el field bus
BXxxxx
• hardware embebido
• Smart System Bus
(basado en CANopen)
• display
• cursor de navegación
• sistema operativo embebido
• acceso directo a los terminales.
• 2 tareas
9 09.07.2007
TwinCAT en una plataforma BCxxxx
TwinCAT
• Descargar programa
• Depuración online
• Acceso y programación desde el Field bus
BCxxxx
• hardware embebido
• sistema operativo embebido
• acceso directo a entradas/salidas
•1 tarea
10 09.07.2007
TwinCAT I/O System
Mapping
II O
O II O
O II O
O
field bus 1 field bus 2 field bus 3
11 09.07.2007
TwinCAT PLC Control
Estructura modular
• máx. 4 PLCs en a PC
• 1 PLC en CX1000/BX/BC
Tareas
• max. 4 task in one PLC
Fàcil de configurar y de depurar
• cambio online del programa
• todas las posibilidades de depuración:
• puntos de paro, monitorización, scope
12 09.07.2007
Estadística tiempos de ejecución
3500
DWORD, DINT
Tiempo de ejecución
1000
500
54 24 5
0
Conv. BC9000 CX1000 PIII 850 P4 2,8
PLC MHz GHz
13 09.07.2007
Conectividad
Fácil de usar:
ADS (Automation Device Specification)
OPC (OLE for Process Control)
14 09.07.2007
Conectividad
LAN (TCP/IP)
PC PC CX1000
PLC HMI PLC HMI HMI
16 09.07.2007
Visión general Twincat System Manager
17 09.07.2007
TwinCAT System Service
TwinCAT parado
TwinCAT arrancando.
TwinCAT funcionando.
TwinCAT Configuración
18 09.07.2007
TwinCAT System Service
19 09.07.2007
Multitarea
20 09.07.2007
Gestión de tareas
22 09.07.2007
Real time operation
23 09.07.2007
Tiempo Real
24 09.07.2007
Operación en Tiempo Real
25 09.07.2007
Funcionamiento en Tiempo Real
1 1 2 1‘ 3 2 4 2‘ 3
e.g.: 1ms 2ms 3ms 4ms 5ms
t
NC cycle (e.g. 1ms) NC cycle NC cycle NC cycle
t
SPS cycle (e.g. 2ms) PLC cycle
26 09.07.2007
Funcionamiento en tiempo real
27 09.07.2007
TwinCAT PLC
28 09.07.2007
Creando un proyecto nuevo
29 09.07.2007
Creando un proyecto nuevo
IEC 61131-3 define una tarea com un elemento que controla la ejecución y
que permite llamar diferentes programas.
30 09.07.2007
POU Unidades Organizativas de Programación
31 09.07.2007
POU
32 09.07.2007
PROGRAM PRG
Program PRG
• Llamado por una tarea (TwinCAT: 1 programa llama a otro)
• Ejecuta : FB‘s, Functions, (Programs)
• Variables locales : estáticas, las variables locales mantienen el valor
del último ciclo.
• Inputs: Frecuentemente 0, pero VAR_INPUT es posible
• Outputs: frecuentemente 0, but VAR_OUTPUT es posible
• Paso por referencia: VAR_IN_OUT también posible
• Debug: Las variables locales son visibles en modo online
• Using: main, hand, automatic....
33 09.07.2007
Function block FB
Function block FB
• Llamada por programas o otras FB´s
• Llama : FB‘s, functions,
• Variables locales : estáticas.
• Inputs: 0,1,2,3 VAR_INPUT
• Outputs: 0,1,2,3 VAR_OUTPUT
• Paso por referencia 0,1,2,3 VAR_IN_OUT
• Debug: Variables locales son visibles en cada instancia de la function
block.
• Using: Multiples instancias de código con variables retentivas
34 09.07.2007
Crear instancias
PROGRAM MAIN
PRG Instancia_1
VAR Var_In :WORD;
Instancia_1 :A; Var_Out :BYTE;
FB Instancia_2 :A; Var_1:WORD;
Instancia_3 :B; Instancia_1
END_VAR
X :REAL;
FUNCTION_BLOCK A CAL Instancia_1 Y :REAL;
VAR _INPUT
CAL Instancia_3
Var_IN :WORD;
END_VAR
VAR _OUTPUT
Instancia_2
Var_Out :BYTE;
FB Var_In :WORD;
END_VAR Var_Out :BYTE;
VAR Var_1:WORD;
FUNCTION_BLOCK B
Var1 :WORD; Instancia_1
VAR_INPUT
Instancia_1: B; X :REAL;
X :REAL;
END_VAR
END_VAR Y :REAL;
VAR _OUTPUT
Y :REAL;
LD Var1 END_VAR
CAL Instancia_1 Instancia_3
X :REAL;
Y :REAL;
35 09.07.2007
Function FC
Function FC
• Llamadas por: programs, function blocks y otras functions
• Llama: functions
• Variables locales : temporales. Una vez utilizadas las variables en el
siguiente ciclo vuelven a las condiciones iniciales
• Inputs: 1,2,3........ VAR_INPUT
• Outputs: Sólo 1!, pero es posible un estructura. El nombre de la
variable de salida es el mismo que el de la función.
• Excepto Twincat: VAR_IN_OUT posible,
• Debug: Las variables no son visibles en modo online pero sí se puede
realizar una depuración paso a paso.
• Using: algoritmos, escalados,…
36 09.07.2007
FC Specials
Desde
DesdeTwinCAT
TwinCAT2.8:
2.8:Valor
Valordevuelto
devueltopor
porlala
función
función
Valor
Valordevuelto.
devuelto.
Nombre
Nombrede
delalaFunction
Function El
Elnombre
nombrededelalasalida
salidaes
es
scale.
scale.
Inputs Scale
Scalepuede
puedeser
serusado
usado
Inputs
como
como una variablelocal
una variable local
variable
variable dentro delala
dentro de
Variables
Variableslocales
localessonson función(Write/Read)
función(Write/Read)
sólo
sólo validas durantelala
validas durante
ejecución
ejecucióndedelalafunción
función
37 09.07.2007
Identificadores
No Permitido
38 09.07.2007
Prefijos
b – Boolean bEndschalterLinks
r – Real rSollPosition
s - String sRxDatos
ST_ - Declaración de estructuras
st - Instancias de estructuras ST_MotorDatos (declaration)
FB_ - Declaración de Function Blocks stM1Parametro (instance)
fb – Instancias a Function Blocks
M_ - Declaration de métodos FB_Alarma (declaration)
fbM1Alarma (instance)
39 09.07.2007
Palabras reservadas (key words) y comentarios
40 09.07.2007
Tipos de datos elementales
41 09.07.2007
Tipos de datos elementales
42 09.07.2007
String
43 09.07.2007
Caracteres especiales
character description
A $$ Caracter dollar
CR $‘ Comilla simple
1
0 $L or $l Line feed
0 (*Str. Abschluss*)
$N or $n New line
$P or $p Page feed
$R or $r Line break
$T or $t Tab
44 09.07.2007
ASCII <-> CHR
45 09.07.2007
Declaración de variables de tipos elementales
bStellerUntenLinks:BOOL:=TRUE;
La dirección física de la
variable no es conocida por el
programador (variables no
direccionadas)
46 09.07.2007
Declaración de variables de tipos elementales
%Q B Byte
%M W
Estas variables apuntan
D a una dirección física de
memoria
bStellerUntenLinks AT%IX0.0:BOOL:=TRUE;
47 09.07.2007
Visibilidad de las variables
48 09.07.2007
Acceso por medio de variables direccionadas
Project Machine
PROGRAM A PROGRAM B
VAR VAR
locVar AT%MB2:WORD;
END_VAR END_VAR
LD %MB2
49 09.07.2007
Nombres iguales de variables globales y locales
PROGRAM A
VAR
Var1 :WORD;
END_VAR
LD Var1
50 09.07.2007
Atributos
Si necesitas utilizar
Projekt Maschine constantes matemáticas,
parámetros constantes de
VAR_GLOBAL CONSTANT una máquina,etc. se debe
extender VAR_GLOBAL ..
END_VAR con la palabra
END_VAR reservada CONSTANT.
Esto también es así con
PROGRAM A variables locales
VAR CONSTANT VAR_GLOBAL CONSTANT
pi:REAL:=3.141592654;
END_VAR END_VAR
52 09.07.2007
Tipos de datos derivados
Tipo padre
Name Data type Initial value Range
h
e
New value i
r
Derivación
Name Data type Initial value Range
53 09.07.2007
References (Alias Types) (Variable II)
54 09.07.2007
Enumeraciones
Syntaxis:
TYPE <identificador>:(<Enum_0> ,<Enum_1>, ...,<Enum_n>);
END_TYPE
Ejemplo:
TYPE DiaSemana:(Lu, Ma, Mi, Ju, Vie, Sa, Do:=10);(*Lu = 0 Ma = 1..
.. Sa = 6 Do = 10*)
END_TYPE
TYPE bit:(Up, Dn);(*Up = 0 Dn = 1*)
END_TYPE Recordad:No es
posible utilizar dos
o más veces el
mismo nombre en
la enumeración.
55 09.07.2007
Enumeraciones
Una variable de tipo enumeración se inicializa por defecto con el primer valor
de la enumeración . Se pueden hacer operaciones númericas con las
enumeraciones de tipo entero. También es posible asignar un número
directamente a una variable del tipo enumeración
VAR
WochenTag:DiaSemana;
END_VAR
WochenTag:=3;
56 09.07.2007
Declaración de estructuras
form
Las estructuras son tipos de datos
Pers_Data importantes para representar la
información de un objeto de nuestra
planta.
Name: Firstname:
Las estructuras pueden ser pasadas
directamente a FunctionBlocks
Age: Address:
57 09.07.2007
Instancias de estructuras
P1
Name:=‚Müller‘
P1 Firstname:=‚Peter‘
Age:=32
K2
Address:=‚Postweg 34‘
P3
Name:=‚Koschnik‘
P3
Firstname:=‚Heinz‘
Age:=37
Address:=‚Domplatz 10‘
VAR
P1, P3 : Pers_Data;
END_VAR VAR_INPUT
VAR_OUTPUT Employees: Pers_Data;
K2 : Pers_Data; END_VAR
END_VAR
Name_total:=CONCAT(P3.Firstname, P3.Name)
■
■
58 09.07.2007
Arrays
Todos los elementos de un array deben de ser del mismo tipo, incluido estructuras.
Son posibles 1,2 y 3 dimensiones
VAR
Feld_1 :ARRAY[1..10] OF BYTE; 1-dimension
Feld_2 :ARRAY[1..10, 2..5] OF UINT; 2-dimension
Feld_3 :ARRAY[1..10,2..5,3..10] OF DINT; 3-dimension
END_VAR
Es posible direccionar todo el array a una posición de memoria.
VAR
Feld_1 AT%MB100:ARRAY[1..10] OF BYTE;
END_VAR
Acceso a los elementos
Feld_1[2] := 120; (* acceso directo*)
Feld_2[i,j] := EXPT(i,j); (*acceso indirecto*)
59 09.07.2007
Ejemplo inicialización array 1 dimensión
1 dimensión
Faktor Wert
0 1 2 3 4 5 6 NO ES POSIBLE
ARRAYS DINÁMICOS
T#1s T#2s T#1s T#0s T#0s T#0s T#0s
Acceso:
VAR
tiempo : TIME;
END_VAR
Tiempo := DBTiempo[1];
60 09.07.2007
Ejemplo inicialización array 2 dimensiones
Factor Valor
Acceso:
0 1 2 3 4 5 6 VAR
61 09.07.2007
Inicialización de un array con comentarios
62 09.07.2007
Ejemplo inicialización array 3 dimensiones
1
1 23 24 25
0 1 13 14 15
0 Access:
20 21 22
1 3 4 5 VAR
0 10 11 12 ejemplo : UINT;
0 1 2 END_VAR
0 0 1 2 ejemplo :=
0 1 2
Supportpoint[ 2,0,1 ];
0 1 2
63 09.07.2007
Fuera de rango
VAR
Feld_1 :ARRAY[1..10] OF BYTE;
Feld_2 :ARRAY[1..10, 2..5] OF UINT;
Feld_3 :ARRAY[1..10] OF DINT;
END_VAR
i:= 9 9
Feld_1[i+2] := 120;
Feld_1[9]; 0
Feld_2[1,2]; 120
64 09.07.2007
Check Bounds (FUN)
IF I< L THEN
Error CheckBounds := L;
ELSIF I > U THEN
Error CheckBounds := U;
ELSE
i Limited
value „OK“ case CheckBounds := I;
Min
Max
END_IF
65 09.07.2007
Check Bounds (FUN) modo de operación
END_VAR CheckBounds := L;
ELSIF I > U THEN
CheckBounds := U;
index:=2;
ELSE
CheckBounds := I;
arrVar[Checkbounds[2,0,3]:=100;
END_IF
FUNCTION CheckBounds :INT
index:=index+2 VAR_INPUT
I,L,U : INT;
arrVar[Checkbounds[4,0,3]:=100; END_VAR
IF I< L THEN
CheckBounds := L;
Checkbounds ELSIF I > U THEN
devuelve 3, el
acceso es CheckBounds := U;
limitado al ELSE
máximo
CheckBounds := I;
END_IF
66 09.07.2007
Combinación de structuras y arrays
68 09.07.2007
ST
69 09.07.2007
ST Texto estructurado:
Order de ejecución de los operadores:
70 09.07.2007
ST Texto Estructurado: Ejemplos
Instrucción Ejemplo
71 09.07.2007
Instrucción IF
Keywords:
Se utiliza para generar varios bloques
de código que se ejecutan en función
de las condiciones. IF THEN
No es posible efectuar un salto hacia ELSIF
atrás en en código.
ELSE
END_IF
La instrucción„GOTO“ no está
disponible
ej.:
72 09.07.2007
Instrucción IF
No
Condición
IF Condición THEN Si
Bloque de instrucciones;
END_IF
Bloque de
instrucciones
73 09.07.2007
Instrucción IF
Condición No
IF a>b THEN
Sí
Bloque de Instrucciones A;
ELSE
Bloque de Instrucciones B;
END_IF Instrucciones A Instrucciones B
74 09.07.2007
Instrucción IF
IF Condición1 THEN
Bloque de instrucción A;
ELSE
IF Condición2 THEN
Bloque de instrucción B;
ELSE
Condición 1
IF Condición3 THEN
No
Sí Bloque de instrucción C;
Condición 2 ELSE
No Bloque de instrucción D;
Sí END_IF
Condición 3 END_IF
No
Sí END_IF
75 09.07.2007
Instrucción IF
IF Condición1 THEN
Bloque instrucciones A;
ELSIF Condición2 THEN
Bloque instrucciones B;
Condition 1 ELSIF Condición3 THEN
No Bloque instrucciones C;
Yes ELSE
Condition 2 Bloque instrucciones D;
No
Yes END_IF
Condition 3
No
Yes
76 09.07.2007
Instrucción IF
77 09.07.2007
Instrucción Case
7..10 : Instrucción 3 No
Yes
..
No
ELSE
Yes
Instrucciones por
defecto
Instrucción 1 Instrucción 2 Instrucción 3 Instrucción por defecto
END_CASE;
78 09.07.2007
CASE Seleccion con valores enteros usando tipos enumerados
CASE State OF
Tipo enumerado:
INIT: instrucciones;(*State=0*)
TYPE Schritte :
START: instrucciones;(*State=1*)
( INIT:=0, START, AUTOMATIK, ENDE);
AUTOMATIK: instrucciones;(*State=2*)
END_TYPE
ENDE: instrucciones;(*State=3*)
END_CASE
VAR
State:Schritte;
(* State:INT also possible*)
END_VAR
79 09.07.2007
CASE Selección con constantes
VAR CONSTANT
Step1 : INT:= 0;
Step2 : INT:= 1; CASE State OF
VAR
State:INT;
END_VAR
80 09.07.2007
CASE ejemplo máquina de estados
TYPE Steps :
( INIT:=0, START, AUTOMATIC, END);
END_TYPE
Instruction
Instructionpara
paralas
lasacciones
acciones
CASE State OF
dentro
dentrodel
delpaso
paso
INIT: Q0:=TRUE;
IF Transición THEN state := START; END_IF
START: Q1:=TRUE; transiciones
transiciones
Se utilizan para evitar tener que repetir Si un bucle infinito es ejecutado esto
un listado de instrucciones común. El no implica un aumento de %CPU
número de iteraciones es conocido en destinado a Twincat.Tareas de mayor
runtime prioridad interrumpiran a la tarea
donde se encuentra el bucle infinito.
Desvantajas de los bucles:
Tareas de prioridad inferior a la tarea
Si se produce un error de
del bucle no serán ejecutadas.
programación la iteración puede ser
infinita.
1 1 2 1‘ 3 1‘‘ 4 1‘‘‘ 1‘
e.g.: 1ms 2ms 3ms 4ms 5ms
82 09.07.2007
Bucles (Visión general)
Todos los bucles pueden ser finalizados con una instrucción EXIT, sin
importar la condición de salida del bucle.
83 09.07.2007
Bucle FOR
ciclo n
85 09.07.2007
Bucle REPEAT
Ciclo n
i:=0;
Sí Expresión No
REPEAT
booleana
Field[i]:=i*2;(*Instrucciones*)
i:=i+1;
UNTIL i>100
ciclo n
END_REPEAT
86 09.07.2007
Llamadas a FB‘s en ST
VAR
TON1:TON;
END_VAR
TON1 (IN:= NOT TON1.Q , PT:=T#1s );
Q0:= TON1.Q
87 09.07.2007
Explicación llamadas a FB en ST
VAR
TON1:TON;
END_VAR
89 09.07.2007
Llamada a FB (alternativo)
Declaración
VAR
Transfiere sólo el parámetro
de entrada. TON1:TON;
ESTO NO ES UNA
LLAMADA A UNA FB!!!!! END_VAR
(* igual:*)
Result:=Scale (input, 0.0, 32767.0, 0.0, 100.0);
(* igual :*)
Result:=Scale (
x:= input,
xug:= 0.0,
xog:= 32767.0,
yug:= 0.0,
yog:= 100.0
);
91 09.07.2007
Llamadas a FB‘s en ST
92 09.07.2007
SFC
93 09.07.2007
SFC Sequential Function Chart
Step
N Action
•Sólo un estado es activo al
mismo tiempo
•La condición para canviar
entre un estado y otro se
Transition Qualifier denomina transición.
• En la acción se tiene que
programar lo que se debe
Following efectuar en cada estado.
step N Action
Transition
Action,
Puede ser escrita en Structured
Text, Instruction list, Ladder
Diagram, Function Block Diagram y
Qualifier
en Sequential Function Chart .
94 09.07.2007
Estados
Transición
95 09.07.2007
Acciones
Transición
Transición
Estado1
N Acción Estado1 N bOutput
Transición
Transición
96 09.07.2007
Acciones, se permiten varias por estado
Transición
Estado1 N bOutput
P STAction
N LDAction
R FBDAction
97 09.07.2007
Estados/ramas alternativas
EstadoA EstadoB
N Acción N Acción
Transición Transición
98 09.07.2007
Estados / ramas alternativas
Transición
Transición
Estado B
N Acción
Estado A
N Acción
Transición
Estado C
Transición N Acción
Transición
99 09.07.2007
Estados / ramas alternativas
Transición
Estado A
N Accción Transición
Transición
100 09.07.2007
Estados / Ramas alternativas
Transición en el
comienzo de las
ramas
Transition simultáneas Línea doble, para
indicar la rama
paralela
Estado B
Estado A N Acción N acción
Transición
Transición en el final
101 09.07.2007
Estados / Ramas alternativas
Estado B
N Acción
Transición
Estado A
N Acción
Estado C
N Acción
Transición
102 09.07.2007
Transición
Estado 1
N Acción
Instrucción ST.
A>B
El resultado debe ser
BOOLEANO.
Nota: Si la instrucción es
demasiado larga se
visualizará sólo una parte.
103 09.07.2007
Transiciones
Transiciones programadas
Inicio
N Acción
001
Comentario GT
A AND
B
Estado1 0
t
N Acción Action processing
0
Go on t
1 Cycle
Estado 001
release
AND
siguiente N Acción
Output
Step1.X
Transition
105 09.07.2007
Último scan del estado
0
TRUE
t
Action processing
Comportamiento: 0
t
Counter := Counter +1; 1 cycle 1 cycle
1;
1;
r+
r+
te
Solución: Utilizar la variable de estado
te
un
un
para saltarse el último scan:
Co
Co
r :=
r :=
IF Schritt.X THEN
te
te
un
un
Counter := Counter +1;
Co
Co
END_IF
(*Counter vale 2*)
106 09.07.2007
Parámetros
0
TRUE
t
Action processing
0
N: Non Stored t
1 cycle
Correspondencia en FBD
001
107 09.07.2007
Parámetros
0
TRUE
t
Action processing
0
t
1 cycle
Correspondencia FBD
001
Step.X SR
S
Action processing
R
108 09.07.2007
Parámetros
0
TRUE
t
Action processing
0
t
Correspondencia en FBD
001
SR
S
Action processing
Step.X R
109 09.07.2007
Parámetros
0
TRUE
t
Action processing
0
t
Delay
Correspondencia en FBD
001
TON
Step.X IN Q Action processing
T#1s PT ET
110 09.07.2007
Qualifier
0
TRUE t
Action processing
0
LIMITED t
Combination in FBD
Step.X
1
001
AND Action processing
0
TON t
Step.X IN Q Action processing
1
T#1s PT ET
0
t
Limit
111 09.07.2007
Qualifier
0
TRUE t
Action processing
0
1 cycle 1 cycle t
Combination in FBD
001
112 09.07.2007
Qualifier, Combinations
113 09.07.2007
Sequential Function Chart step diagnosis
VAR
SFCEnableLimit: BOOL;
(*When it has the value TRUE, the timeouts of the steps will be registered in SFCError.
Other timeouts will be ignored.*)
SFCInit: BOOL;
(*When this boolean variable has the value TRUE the sequential function chart is set back to
the Init step. The other SFC flags are reset too (initialization).
The Init step remains active, but is not executed, for as long as the variable has
the value TRUE. It is only when SFCInit is again set to FALSE that the block can
be processed normally. *)
114 09.07.2007
Sequential Function Chart step diagnosis
SFCReset: BOOL;
(*This variable, of type BOOL, behaves similarly to SFCInit. Unlike the latter, however,
further processing takes place after the initialization of the Init step. Thus for example
the SFCReset flag could be re-set to FALSE in the Init step.*)
115 09.07.2007
Sequential Function Chart step diagnosis
SFCQuitError: BOOL;
SFCPause: BOOL;
SFCTrans: BOOL;
(*This boolean variable takes on the value TRUE when a transition is actuated. .*)
116 09.07.2007
Sequential Function Chart step diagnosis
SFCError: BOOL;
(*This Boolean variable is TRUE when a timeout has occurred in a SFC diagram. If
another timeout occurs in a program after the first one, it will not be registered unless
the variable SFCError is reset first. *)
SFCErrorStep: STRING;
(*This variable is of the type STRING. If SFCError registers a timeout, in this variable is
stored the name of the step which has caused the timeout. *)
SFCErrorPOU: STRING;
(*This variable of the type STRING contains the name of the block in which a timeout
has occurred. *)
117 09.07.2007
Sequential Function Chart step diagnosis
SFCCurrentStep: : STRING;
(*This variable is of the type STRING. The name of the step is stored in this variable
which is active, independently of the time monitoring. In the case of simultaneous
sequences the step is stored in the branch on the outer right.
No further timeout will be registered if a timeout occurs and the variable SFCError is not
reset again.*)
118 09.07.2007
Sequential Function Chart step diagnosis (from 2.8)
SFCErrorAnalyzation: STRING;
(*This variable, of type STRING, provides the transition expression as well as every
variable in an assembled expression which gives a FALSE result for the transition and
thus produces a timeout in the preceding step. A requirement for this is declaration of
the SFCError flag, which registers the timeout. SFCErrorAnalyzation refers back to a
function called AppedErrorString in the TcSystem.Lib library. The output string
separates multiple components with the symbol “|”. *)
SFCTip: BOOL;
SFCTipMode: BOOL;
(*This variables of type BOOL allow inching mode of the SFC. When this is switched on
by SFCTipMode=TRUE, it is only possible to skip to the next step if SFCTip is set to
TRUE. As long as SFCTipMode is set to FALSE, it is possible to skip even over
transitions.*)
END_VAR
119 09.07.2007
Sequential Function Chart process diagnosis
Implicit variable
120 09.07.2007
Sequential Function Chart process diagnosis
121 09.07.2007
Online (and per ADS) can be requested
122 09.07.2007
Sequential Function Chart Tipmode
• effect:
SFCTipMode SFCTip Transition effect
Process stays in the current step
TRUE FALSE TRUE
Change to next step
TRUE TRUE TRUE
Change to next step
TRUE TRUE FALSE
Process stays in the current step
FALSE TRUE FALSE
Change to next step
FALSE FALSE TRUE
123 09.07.2007
Actions also in other IEC languages possible! (POU type :
PRG, FB)
„Mainprogram“
Call actio
n
Action step1
Action step2
124 09.07.2007
Overview
Contents
Timing
125 09.07.2007
Remanent Flags Variables Attributes
These variables maintain their value, even after a power failure. When the
program is run again, the stored values will be processed further. A
practical example would be an operations timer that recommences
timing after a power failure. A practical example would be an operations
timer that recommences timing after a power failure. All other variables
are newly initialized, either with their initialized values or with the
standard initializations.
TwinCAT supports two kind of remanent flags:
RETAIN PERSISTENT
126 09.07.2007
Retain Persistent
Retain Persistent
To store
Possible for unlocated, located (%M) Unlocated, located (%I, %Q, %M)
127 09.07.2007
Boot project
Power ON
Requirement :
Start
It should be possible to 1 NT
automate the loading and
the starting of the PLC
project after switching on
the computer. 2 Start TwinCAT Log on
4 Start PLC
128 09.07.2007
1&2
129 09.07.2007
Create a boot project
Requirement:
130 09.07.2007
3&4
Enabling for loading the boot Enabling for loading and saving
project for the run time system 1. the RETAIN data for the run
time 1.
131 09.07.2007
Sourcecode download
132 09.07.2007
Timing for Sourcecode download
1.Implicit at load
Every time when you open the
PLC Project the Sourcecode will
be written down to the controller.
2.Notice at load
If the PLC Project changed, you
get a message box, when you
open the project.
3.Implicit at create boot project.
Everytime you create a
bootproject, the sourcecode will
be transfered to the controller
133 09.07.2007
Timing/Extent for Sourcecode download
1.On demand
The Sourcecode will be written
down to the controller on
demand.
Online/Sourcecode download
Extent
Sourcecode only
•The plc project will be written in
the controller
All files
•The plc project with all libaries
will be written tin the controller
134 09.07.2007
Plc project open from the controller
135 09.07.2007
Were retain and persitent data loaded successfully?
136 09.07.2007
Meaning of the flags
3 Reserved
6 Reserved
7 Reserved
137 09.07.2007
How can an access to the bootdata flags take place?
139 09.07.2007
Write Persitent Data on demand, Example:
IF ReqWritePersistent THEN
fbWritePersistent(NETID:='' , PORT:=801 , START:=TRUE , TMOUT:=T#500ms );
IF fbWritePersistent.ERR THEN
fbWritePersistent(START:=FALSE );
ReqWritePersistent:=FALSE; PLC Runtime
ELSIF NOT fbWritePersistent.BUSY THEN
fbWritePersistent(START:=FALSE );
ReqWritePersistent:=FALSE;
END_IF Further start after edge
END_IF
140 09.07.2007
Internal Libraries
Unnecessary elements:
All tasks will be deleted in the task Create and test project
configuration.
All POUs, which are not to belong
to thecontents of a library, are
removed.
All global variables will be Delete unnecessary
deleted. elements of a library
Valid: global constants, self
defined data types.
141 09.07.2007