Trasformare programmi LD in programmi ST

Se desiderate trasformare il vostro programma LD in un programma ST, tenete presente quanto segue:

1. Rete con uscita normale

Programma LD

Codice programma ST

Note

Y0 := X0 AND X1 OR X2 AND NOT X3;
 

Altra possibilità:

IF X0 AND X1 OR X2 AND NOT X3 THEN
	Y0:=TRUE;
ELSE 
	Y0:=FALSE;
END_IF;

Stesso comportamento, ma richiede più risorse.

NOTA

Un circuito WHILE causerebbe un errore tempo di scansione con conseguente errore watchdog.

2. Rete con uscita Set o Reset

Programma LD

Codice programma ST

 
IF X0 AND X1 THEN
	Y0 := TRUE;
END_IF;
IF X2 AND NOT X3 THEN
	Y0 := FALSE;
END_IF;
 

3. Rete con flag impulsivo (fronte di salita/discesa)

Programma LD

Codice programma ST

Note

(* rising edge *)
IF	X0 AND NOT X0_Old THEN
	Count:=Count+1;
END_IF;
X0_Old:=X0;
(* falling edge *)
IF	NOT X1 AND X1_Old THEN
	Count:=Count-1;
END_IF;
X1_Old:=X1;

Interrogazione esplicita del rilevamento di fronte senza funzione o Function Block.

Altra possibilità:

(* rising edge *)
R_TRIG_X0( CLK:= X0 );
IF	R_TRIG_X0.Q THEN
	Count:=Count+1;
END_IF;
(* falling edge *)
F_TRIG_X1( CLK:= X1 );
IF	F_TRIG_X1.Q THEN
	Count:=Count-1;
END_IF;

Utilizzo delle istanze di Function Block R_TRIG o F_TRIG della IEC standard library.

Altra possibilità:

(* rising edge *)
IF	DF(X0) THEN
	Count:=Count+1;
END_IF;
(* falling edge *)
IF	DFN(X1)  THEN
	Count:=Count-1;
END_IF;

Utilizzo delle funzioni di base DF o DFN.

L'ultima revisione: 2020-10-12Feedback su questa paginaPanasonic hotline