Somma fra dati BCD
Questa istruzione FP somma due dati BCD specificati da s1 e s2 se il trigger EN è TRUE. Il risultato viene memorizzato in d.
Ingresso
Uscita
Somma
Istruzioni F corrispondenti: F40_BADD Addizione BCD a 4 cifre, F41_DBADD Addizione BCD a 8 cifre
Tutte le variabili di ingresso e uscita utilizzate per programmare questa funzione sono state dichiarate nell'intestazione del POU. La stessa intestazione del POU è utilizzata per tutti i linguaggi di programmazione.
VAR
bStart: BOOL:=FALSE;
(*activates the function*)
dwSummand1: DWORD:=16#12342000;
(*summand at input s1 is added to summand at input s2*)
dwSummand2: DWORD:=16#00003678;
dwResult: DWORD;
(*result after 0->1 leading
edge from start:
16#12345678*)
END_VAR
Quando la variabile bStart passa da FALSE a TRUE, la funzione viene eseguita.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
B(B_F,FP_ADD_BCD!,,15,1,23,6,,?DEN?D@'s1'?Ds2?AENO?Cd);
B(B_CONTACT,,bStart,8,2,10,4,R);
B(B_VARIN,,dwSummand1,13,3,15,5,);
B(B_VARIN,,dwSummand2,13,4,15,6,);
B(B_VAROUT,,dwResult,23,3,25,5,);
L(1,3,8,3);
L(10,3,15,3);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF DF(bStart) then
FP_ADD_BCD(dwSummand1, dwSummand2, dwResult);
END_IF;