• Non ci sono risultati.

2. - Esercitazione in aula informatica (Seconda Parte)

N/A
N/A
Protected

Academic year: 2021

Condividi "2. - Esercitazione in aula informatica (Seconda Parte)"

Copied!
26
0
0

Testo completo

(1)

Università degli Studi di Modena e Reggio Emilia Automation

Robotics and System

CONTROL Università degli Studi

di Ferrara

PLC

Example 2

Francesca Fanfoni francesca.fanfoni@unimore.it

PLC

CodeSys

(2)

Indice

Esempio in Ladder Diagram (LD)

Esempio in Structured Text (ST)

Esercitazione 1

Esercitazione 2

ARSControl@unimore.it

Esempio in Structured Text (ST)

Allocazione dei task

(3)

Un progetto

סּ Progetto si intendono tutti gli oggetti necessari per la stesura del

programma per PLC

סּ Gli oggetti sono:

– POU (Program Organization Unit),

– tipi di dato definiti dall’utente,

– la parte di visualizzazione,

– la parte di visualizzazione,

– risorse

– librerie.

POU (Program Organization Unit) può essere Function,

Function Block o Program.

סּ Un progetto in CodeSys è identificato dal nodo che

raccoglie tutti gli oggetti che sono necessari alla Application

definizione di una particolare istanza del programma PLC su un determinato dispositivo hardware (PLC, controller).

(4)

The First Project

Task 1: Handle a dummy traffic signal unit.

The red/green phases of both traffic signals alternate and we have to handle the request of pedestrian crossing to stop the traffic.

Task 2: We will insert a yellow transitional phase.

ARSControl@unimore.it

Step by step procedure

1. Create a schema solution, a new project and a new program 2. Compile a project

3. Run the simulator and transfer the project to the target 4. Configure the visualization

(5)

The First Project

Create a schema solution

Car access

GREEN LIGHT

Wait pedestrian request to stop the traffic

START

The red/green phases of both traffic signals alternate and we have to handle the request of pedestrian crossing to stop the traffic.

We have to think and design a solution draw a

ARSControl@unimore.it

stop the traffic.

Stop cars

RED LIGHT

After the pedestrian cross the road reset the state.

Pedestrian request NOT Pedestrian request

We have to think and design a solution draw a simple diagram that is directly connected to the PLC program.

In the schema have to define: - States

(6)

• LOGIC

AND serial connection of two or more contacts

OR parallel connection of two or more contacts

The First Project

Ladder diagram (LD)

ARSControl@unimore.it Negations

Jumps to skip over networks in the program, using a symbolic name of a jump label

(7)

START

• La soluzione viene implementata con 3 network •Uno stato corrisponde ad una network.

•La prima network dell’Application gestisce l’inizializzazione dell’intero sistema.

The First Project

Compiling a project and trasferring the project

AVVIAMENTO DEL SISTEMA

ARSControl@unimore.it Car access

GREEN LIGHT

Wait pedestrian request to stop the traffic.

Stop cars

RED LIGHT

After the pedestrian cross the road reset the state.

(8)

• Ladder diagram program is dived in Network

• Each network can be linked to a part of the solution schema

The First Project

Compiling a project and trasferring the project

(9)

• Ladder diagram program is dived in Network

• Each network can be linked to a part of the solution schema

The First Project

Compiling a project and trasferring the project

(10)

Global variables

סּ

Dichiarazione di un insieme di variabili globali per il

progetto.

(11)

Global Variables List (GVL)

סּ

Dichiarazione di un insieme di variabili globali per il

progetto.

(12)

Dichiarazione di una POU in ST

סּ

Aggiungere un programma in testo strutturato

all’applicazione.

(13)

Structured Text (ST)

סּ

ST is a textual language similar to “C”, or (for who might

remember it) PASCAL.

סּ

ST can be successfully used to develop complex

algorithm, data structure handling, etc.

סּ

ST has the syntactical structure of the procedural

programming languages:

programming languages:

Assignment

Choices

Iteration

(14)

Assignment

סּ

The variable on the left side should be of the same type

of the result of the expression of the right side.

סּ

on contrary, the ST compiler will introduce a variable

casting to set all the variables to the same type.

C. Fantuzzi 3. I Linguaggi di Programmazione 14

(15)

Choices

IF <Boolean_Expr_1> THEN

<code>;

ELSIF <Boolean_Expr_2> THEN

<code>;

ELSE

<code>;

END_IF

C. Fantuzzi 3. I Linguaggi di Programmazione 15

CASE <integer_expression> OF <integer_value_1> : <code>; <integer_value_2> : <code>; ... ELSE <code>; END_CASE

(16)

Iteration

REPEAT

<code>;

UNTIL

<Boolean_Expr>

END_REPEAT

;

WHILE

<Boolean_Expr>

DO

C. Fantuzzi 3. I Linguaggi di Programmazione 16

WHILE

<Boolean_Expr>

DO

<code>

END_WHILE

;

FOR

<integer_Variable>:= <initial_value>

TO

<final_value>

BY

<step>

DO

<code>

(17)

Warning

סּ

The iteration structure may violate the real time concerns

of the program.

סּ

An iteration can’t be done to wait for a external variable

changes.

(18)

ST Operators (a)

(19)

ST Operators (b)

(20)

POU in testo strutturato

Car access

START

•Variabili del programma per gestire un diagramma a stati.

•Inizializzazione del primo stato

GREEN LIGHT

Wait pedestrian request to stop the traffic.

Stop cars

RED LIGHT

After the pedestrian cross the road reset the state.

(21)

POU in testo strutturato

Car access

GREEN LIGHT

Wait pedestrian request to stop the traffic.

START

•Gli stati del sistema vengono gestiti con una struttura CASE … OF

1

Stop cars

RED LIGHT

After the pedestrian cross the road reset the state.

Pedestrian request NOT Pedestrian request

•Aggiornamento dello stato  2

(22)

Allocazione dei TASK

סּ

Il progetto principale è PLC_PRG e viene sempre

eseguito.

סּ

POU sono eseguite se sono allocate a un task periodico

סּ

Allocazione della nostra POU al task

סּ

Per definire un Task è necessario aver inserito,

sotto il

nodo application, l’oggetto Task configuration (con il

comando “Add object”> “Configurazione attività”).

Selezionando quest’ultimo ed eseguendo nuovamente il

comando “Add object” sarà possibile inserire il Task.

(23)

Allocazione dei TASK

סּ

Allocazione della nostra POU al task

essere eseguiti quello a priorità maggiore viene Priority: se più task soddisfano i criteri per

eseguito

Type: definisce la condizione che farà scattare

(trigger) l’esecuzione del task (es: ciclico con (trigger) l’esecuzione del task (es: ciclico con

intervallo fissato).

POUs: in questo pannello vengono elencati, in ordine di

esecuzione, i programmi controllati dal task.

In modalità online il Task editor fornisce informazioni sui tempi di ciclo e sullo stato dei task.

(24)

Esercizio 2

Esercizio 2: Controllo semaforo

Descrizione dell‘ applicazione:

ARSControl@unimore.it

Funzione: premendo il pulsante start inizia il ciclo semaforico.

Azione: All’attivazione del pulsante il sistema esce dallo stato “standby” ed esegue il ciclo semaforico. Il ciclo prevede 4 stati, a ciascuno dei quali corrispondono opportune uscite per i due semafori: “verde”, “verde-giallo”, “giallo-rosso”, “rosso”.

Il passaggio da uno stato all’altro è determinato da un timer

Dopo sette cicli il sistema torna nello stato di standby, nel quale tutte le luci sono spente

(25)

Esercizio 2

Esercizio 2: Controllo semaforo

Descrizione dell‘ applicazione:

ARSControl@unimore.it

Funzione: premendo il pulsante start inizia il ciclo semaforico.

Azione: All’attivazione del pulsante il sistema esce dallo stato “standby” ed esegue il ciclo semaforico. Il ciclo prevede 4 stati, a ciascuno dei quali corrispondono opportune uscite per i due semafori: “verde”, “verde-giallo”, “giallo-rosso”, “rosso”.

Il passaggio da uno stato all’altro è determinato da un timer

Dopo sette cicli il sistema torna nello stato di standby, nel quale tutte le luci sono spente

(26)

PLC

Example 2

Francesca Fanfoni francesca.fanfoni@unimore.it

PLC

CodeSys

Riferimenti

Documenti correlati

cole si sarebbe infatti proposto di rimediare alla scarsa rappresentativita` del palazzo di corte e della citta` di Ferrara nel suo complesso; ma il principio che il baricentro

The fact that an obstacle accelerates exiting from a bounded path, and that the increasing speed of the crowd results in a higher probability of traffic jam—important aspects in

Due to more complex SE spectra, the accuracy of the model describing the optical properties of silver nanoparticle arrays did not allow us to identify the surface premelting;

In particular it linearizes the system in the following way: if the input signal at the gate increases, a larger drain current will flow through the inductor, its voltage drop

The language centre, together with the Internationalisation office, are attempting to meet the needs of a growing number of academic staff who are teaching their content

Additionally, the dipole moment of trans-propargylamine was determined by Stark effect mea- surements (the values µ a = 0.586 D and µ b = 0.445 D being derived), but the very

Gli sforzi di Totila, durante il 550 e il 551, sono quindi rivolti alla conquista della Sicilia e allo spoglio delle ricchezze dei Siciliani, «gli alleati più