PULSEGEN (FB43) Pulse Generation

: 2009-10-16

: komatic

: PIDcontrol

ICONT PULSEGEN (FB43) .

Standard Library -> PID Control Blocks -> FB43 PULSEGEN ICONT

, . STL - .

:
english - download .pdf 0.3
- .pdf 0.3

pulsegen

FUNCTION_BLOCK FB43
TITLE =" pulse generator"
AUTHOR : SIMATIC
FAMILY : ICONT
NAME : PULSEGEN
VERSION : " 1.6"
// reversed by komatic
VAR_INPUT
INV : REAL ; //input variable
PER_TM : TIME := T#1S; //period time
P_B_TM : TIME := T#50MS; //minimum pulse/break time
RATIOFAC : REAL := 1.000000e+000; //ratio factor
STEP3_ON : BOOL := TRUE; //three step signal on
ST2BI_ON : BOOL ; //two step signal for bipolar manipulated value on
MAN_ON : BOOL ; //manual mode on
POS_P_ON : BOOL ; //positiv pulse on
NEG_P_ON : BOOL ; //negativ pulse on
SYN_ON : BOOL := TRUE; //impuls output synchronisation on
COM_RST : BOOL ; //complete restart
CYCLE : TIME := T#10MS; //sample time
END_VAR
VAR_OUTPUT
QPOS_P : BOOL ; //positiv pulse on
QNEG_P : BOOL ; //negativ pulse on
END_VAR
VAR
sInvAlt : REAL ;
siZaehlPer : INT ;
siZaehlPTm : INT ;
sbPosP : BOOL := TRUE ;
END_VAR
VAR_TEMP
rCycle : REAL ; //Abtastzeit in real
rPerTm : REAL ; //Periodendauer in real
rMinPTm : REAL ; //Mindestimpulsdauer in real
rRatioFac : REAL ; //Verhltnisfaktor
Offset : REAL ; //Offset
PTm : REAL ; //Impulsdauer
PTmHlm : REAL ; //Obere Begrenzung der Impulsdauer
PTmLlm : REAL ; //Untere Begrenzung der Impulsdauer
END_VAR
BEGIN
IF COM_RST
THEN
QPOS_P:=0 ;
QNEG_P:=0 ;
siZaehlPer:=0 ;
siZaehlPTm:=0 ;
sbPosP:=1 ;
ELSE
IF MAN_ON
THEN
IF STEP3_ON
THEN
IF POS_P_ON XOR NEG_P_ON
THEN
IF POS_P_ON
THEN
QPOS_P:=1 ;
QNEG_P:=0 ;
ELSE
QPOS_P:=0 ;
QNEG_P:=1 ;
END_IF;
ELSE
QPOS_P:=0 ;
QNEG_P:=0 ;
END_IF;
ELSE
IF POS_P_ON
THEN
QPOS_P:=1 ;
QNEG_P:=0 ;
ELSE
QPOS_P:=0 ;
QNEG_P:=1 ;
END_IF;
END_IF;
siZaehlPer:=0 ;
sbPosP:=1 ;
ELSE
IF siZaehlPer<=0
THEN
rCycle:=DINT_TO_REAL(TIME_TO_DINT(CYCLE));
rPerTm:=DINT_TO_REAL(TIME_TO_DINT(PER_TM));
rMinPTm:=DINT_TO_REAL(TIME_TO_DINT(P_B_TM));
siZaehlPer:=REAL_TO_INT(rPerTm/rCycle);
IF siZaehlPer<0 THEN siZaehlPer:=0; END_IF;
IF STEP3_ON
THEN
IF INV>0.0
THEN
IF RATIOFAC>1.0
THEN
rRatioFac:=1.0/RATIOFAC;
ELSE
rRatioFac:=1.0 ;
END_IF;
sbPosP:=1 ;
ELSE
IF RATIOFAC>1.0
THEN
rRatioFac:=1.0 ;
ELSE
rRatioFac:=RATIOFAC;
END_IF;
sbPosP:=0 ;
END_IF;
Offset:=0.0 ;
ELSE
IF ST2BI_ON
THEN
IF INV<-100.0
THEN
Offset:=0.0 ;
rRatioFac:=0.0 ;
ELSE
Offset:=0.5*rPerTm;
rRatioFac:=0.5 ;
END_IF;
ELSE
Offset:=0.0 ;
IF INV<0.0
THEN
rRatioFac:=0.0 ;
ELSE
rRatioFac:=1.0 ;
END_IF;
END_IF;
sbPosP:=1 ;
END_IF;
PTm:=ABS(INV*rRatioFac*rPerTm*0.01+Offset);
IF (NOT STEP3_ON) AND ST2BI_ON THEN rRatioFac:=1.0; END_IF;
PTmHlm:=rPerTm-rMinPTm;
PTmLlm:=rMinPTm;
IF PTm>PTmHlm THEN PTm:=rPerTm; END_IF;
siZaehlPTm:=REAL_TO_INT(PTm/rCycle);
IF (PTm<>sInvAlt) AND SYN_ON AND (siZaehlPer>2)THEN siZaehlPer:=1; END_IF;
IF STEP3_ON
THEN
IF siZaehlPTm=0
THEN
QPOS_P:=0 ;
QNEG_P:=0 ;
ELSE
IF sbPosP
THEN
QPOS_P:=1 ;
QNEG_P:=0 ;
ELSE
QPOS_P:=0 ;
QNEG_P:=1 ;
END_IF;
END_IF;
ELSE
IF siZaehlPTm = 0
THEN
QPOS_P:=0 ;
ELSE
QPOS_P:=1 ;
END_IF;
QNEG_P:=NOT QPOS_P;
END_IF;
siZaehlPer:=siZaehlPer-1 ;
IF siZaehlPTm>0
THEN
siZaehlPTm:=siZaehlPTm-1 ;
ELSE
siZaehlPTm:=0 ;
END_IF;
END_IF;
END_IF;
END_IF;
sInvAlt:=INV;
END_FUNCTION_BLOCK





: 8320

:     : 2014-12-03

.
,
http://plc4good.org.ua/view_post.php?id=48#raz53
( 4 end_if)

: komatic    : 2014-12-03

, 1.1 1.6, ICONT MODCONT

:

(4000 max):

: