好的编程规范就是对一些通用的控制对象编写标准控制块,对数据处理、传递、逻辑控制实现封装,以实现代码的可重用和简化编程的目的,关于这方面的讨论,我在工控网上发表的《PLC的面向对象编程》中有介绍。 西门子的SCL语言是符合国际标准的一种PLC编程语言,其优秀的程序结构体系和运算编程适合于标准库的开发,我在工控网上发表的《在S7300/400型PLC中使用高级语言编程》中有关于这方面的介绍。
1、硬件电路设计 本文用到的变频器为ABB的ACS800系列变频器,使用其最一般的功能,电路设计类似于下图:
本设计将主接触器放在变频器之前,启动电机时先打开主接触器,然后启动变频器驱动电机,关断电机时,先控制变频器关闭,延时后主接触器关闭,在电机不运行的情况下,可节约电源,该设计可用于风机之类的控制,即不需要频繁的起停,值得说明的是由于ABB的总线通讯模块由变频器自身提供电源,当变频器断电后,可能导致总线故障,所以上面的设计对西门子的MM440没问题,但对ABB的变频器并不一定适合,所以另外一种设计方式就是将主接触器放在变频器的下方,该接触器一般由急停开关控制。 本程序将以第一种方式的设计为依据(该程序来自MM440控制程序的转换)
2、变频器的一般参数 <1>99.01:选择语言 <2>99.02:选择应用宏程序,不同的应用宏会预先定义不同的连接端子功能,而这些端子又随后可以被不同功能的参数定义,当多个参数使用同一个端子时,在这个端子信号被激活后,这多个参数功能均会被激活。 <3>99.04:选择电机控制模式DTC/SCALAR,当电机的额定电流小于变频器的额定电流的1/6时,可以使用SCALAR模式。 <4>99.05:电机的额定电压 <5>99.06:电机的额定电流 <6>99.07:电机的额定频率 <7>99.08:电机的额定转速 <8>99.09:电机的额定功率 <9>20.01:设置最小转速 <10>20.02:设置最大转速 <11>22.02:设置加速度时间1 <12>22.03:设置减速度时间1 <13>10.01/10.02:设定为COMM.CW,由外部EXT1/EXT2来控制电机电机启停(包括总线控制) <14>10.03:若希望改变电机的运转方向,可以将该参数设置为”REQUEST” <15>若该变频器的硬件设计为,主接触器位于变频器和电机之间(该设计主要用于急停控制主接触器),则主接触器的辅助常开触点可接到端子X22/5和X22/8上,用于控制变频器运行使能,可通过参数16.01来选择端子DI5(X22/5);若热敏电阻接到X22/6和X22/7上,可定义参数30.05选择”THERMISTOR”,同时必须定义参数30.04来启用热敏保护。X25(1/2/3)为继电器1输出,通过参数14.01定义其功能。
3、变频器的总线参数 <1>P98.02:fieldbus <2>P98.07:ABBDrives,andneedtomodifyinstep7hardwareconfig <3>P51.01:checkthemoduletype:ProfibusDP <4>P51.02:nodeaddress,whenthefrequencyhardwareswitchiszero,theparameterindicatetheaddressfromconfig. <5>P51.03:Baudrate,consisttothesettingofPLC <6>P51.04:PPOtype,consisttothesettingofPLC -----referencevalue-------------- <7>REF1:-20000(Dec)=-[P11.05],20000(Dec)=[P11.05];-1:-[P11.04],0:[P11.04] <8>P20.01/P20.02FORSPEEDLIMIT;P20.07/P20.08:FREQUENCYLIMIT(THESEPARAMETERSWILLEFFECTTHE''<7>''Set) <9>P22.07FOR"OFF3"TYPESTOPTIME(stopaccordingtofastestpossibledecelerationmode) <10>P11.03/P11.06FOREXEREF1/REF2SELECT,设定为COMM.REFx(表示由现场总线给定速度值)
4、关于程序块 本程序编写了四个内部速度设定点和一个外部速度设定点,手动/自动,以及报警全集成。 重要的参数介绍: <1>Enbl:设备使能,该参数用于连接安全条件,譬如急停信号 <2>EnFV:使故障传递至人机界面容许,这是因为可视化是提供给用户最详细信息的平台,在可视化界面上显示的信息一定要正确,但实际上某些故障会导致一系列其他类型的故障产生,为了只显示那些引起最初故障的根源,需要对传递至可视化的故障进行控制。最常见的就是电源故障,该故障会导致一系列其他的故障,故可以用电源检测条件来控制可视化故障。 报警分为故障和警告,故障会导致停机,而警告则不会,在本程序中使用了大量的结构,这些结构将不同类型的变量加以区分(甚至于将可视化与非可视化故障加以区分),便于用户诊断和维护程序。这种程序看起来相当复杂,但监控起来相当方便,若开发出与之对应的人机界面控件,甚至于可以使人机界面的组态高度自动化。 <3>Aon/Aoff;Mon/Moff:自动开/自动关,手动开/手动关,有些编程规范把手动/自动合在一起编写,这是因为他们有着一些共同的安全条件检测,本块已经把各种报警条件,安全条件作为单独的输入,这些输入都会导致电机的停转(而不管块是在手动,还是自动模式下),所以在使用本块时,对于Aon/Aoff;Mon/Moff输入参数,只需要编写逻辑起停条件,而不需要再次串入安全条件。 <4>本程序用到了一个全局变量:"IP_1Sec",其为间隔一秒的脉冲,用于计时,所以当想使用本块时,必须先编写间隔一秒的脉冲"IP_1Sec"
5、关于程序代码的自动化生成 西门子的SCL编辑器相对微软的编程软件而言,还相当原始,代码几乎都要手工输入,为了提高效率,可以自己开发一个辅助生成软件,譬如针对参数的定义,可以由软件自动产生,以下是本人编写的一个SCL程序代码的辅助生成工具的截图:
使用该工具,可以产生以下ACS800的程序代码的60以上。
6、程序代码(使用S7-300在ACS800变频器上已经测试过) (*Function: ========= ThisFunctionBlockcontrolsafreq.converter(ABB.ACS800)usingthefollowingcriteria:
-StartingandstoppingviaProfibus -MotorProtectionEquipment(MotorProtector,MotorTemperature,Fuses) -MotionControl(Pressure/RotationSensor/ContactorFeedback) -MaintenanceLock-OutSwitch configstep: <1>P98.02:fieldbus <2>P98.07:ABBDrives,andneedtomodifyinstep7hardwareconfig <3>P51.01:checkthemoduletype:ProfibusDP <4>P51.02:nodeaddress,whenthefrequencyhardwareswitchiszero,theparameterindicatetheaddressfromconfig. <5>P51.03:Baudrate,consisttothesettingofPLC <6>P51.04:PPOtype,consisttothesettingofPLC -----referencevalue-------------- <7>REF1:-20000(Dec)=-[P11.05],20000(Dec)=[P11.05];-1:-[P11.04],0:[P11.04] <8>P20.01/P20.02FORSPEEDLIMIT;P20.07/P20.08:FREQUENCYLIMIT(Theseparameterswilleffectthe''<7>''setting) <9>P22.07FOR"OFF3"TYPESTOPTIME(stopaccordingtofastestpossibledecelerationmode) <10>P11.03/P11.06FOREXEREF1/REF2SELECT,settingfor''COMM.REF'' <11>P10.01/P10.2:settingforCOMM.CW*)
FUNCTION_BLOCKFB250 VERSION:''1.0'' AUTHOR:parker FAMILY:Mtr VAR_INPUT//InputParameters Manu:Bool:=0;//FaultAcknowledge Auto:Bool:=0;//AutomaticMode Enbl:Bool:=0;//EnableDevice EnFV:Bool:=0;//EnableFaultstoVisu EnMV:Bool:=0;//EnableManualOperationfromVisu Ackn:Bool:=0;//FaultAcknowledge Mute:Bool:=0;//HornSilence LT:Bool:=0;//LampTest AOn:Bool:=0;//AutoOn(1-impulsesufficient) AOff:Bool:=0;//AutoOff(1-impulsesufficient) MOn:Bool:=0;//ManualOn(1-impulsesufficient) MOff:Bool:=0;//ManualOff(0-impulsesufficient) FBOn:BOOL:=0;//FeedbackMainContactorOn(1=Running) FDO:Bool:=0;//FusedDisconnectOpen(1=OK) MP:Bool:=0;//MotorProtectorFault(1=OK) WMT:Bool:=0;//MotorTempWarning(1=OK) FMT:Bool:=0;//MotorTempFault(1=OK) LOS:Bool:=0;//MaintenanceLock-OutSwitch(1=OK) ISet1:Bool:=0;//InternalSetpoint1on(1=Active) ISet2:Bool:=0;//InternalSetpoint2on(1=Active) ISet3:Bool:=0;//InternalSetpoint3on(1=Active) ISet4:Bool:=0;//InternalSetpoint4on(1=Active) CIES:Bool:=0;//ControlBitforInternalorExternalSetpoint(0=Internal/1=External) ESet:Real:=0;//ExternalSetpoint(Frequency) VFDState:Word:=0;//FromVariableFrequencyDriveStatus VFDFreq:Word:=0;//FromVariableFrequencyDriveOutputFrequency(ActualValue) END_VAR
VAR_OUTPUT//OutputParameters OFreq:Real:=0;//DriveOutputFrequency(ActualValue,usedforshow) VFDLogicCom:Word:=0;//ToVariableFrequencyDrive=>DriveLogicCommand VFDFreqCom:Word:=0;//ToVariableFrequencyDrive=>DriveFrequencyCommand On:Bool:=0;//DriveOn(MainContactor) MeOn:Bool:=0;//MessageDriveRunning/Fault MMC:Bool:=0;//MessageMotionControlFault/Warning Fault:Bool:=0;//CollectiveFault Warn:Bool:=0;//CollectiveWarning NFlt:Bool:=0;//NewFault(HornOn) NWarn:Bool:=0;//NewWarning(HornOn) END_VAR
VAR_IN_OUT//input/OutputParameters END_VAR
VAR//StaticVariables CB:STRUCT//DataStructureofControlBitsfromVisu C2254_On:Bool:=0;//ManualOnfromVisu C2251_Off:Bool:=0;//ManualOfffromVisu C2263_Auto:Bool:=0;//SwitchDevicebacktoAutomatic C2282_MSetOn:Bool:=0;//ManualSetpointOn C2283_MSetOff:Bool:=0;//ManualSetpointOff END_STRUCT; SB:STRUCT//DataStructureofStatusBitstoVisu S1252_Enbl:Bool:=0;//EnableDevice S1255_EnFV:Bool:=0;//EnableFaultstoVisu S1254_EnMV:Bool:=0;//EnableManualOperationfromVisu S1251_Auto:Bool:=0;//AutomaticMode S1257_Manu:Bool:=0;//ManualMode S1267_ManuComb:Bool:=0;//CombinedManualModeforVisu S1268_CFV:Bool:=0;//CollectiveFault(Visu) S1269_CWV:Bool:=0;//CollectiveWarning(Visu) S2251_On:Bool:=0;//DriveisOn S2324_VFDRun:Bool:=0;//VariableFrequencyDriveRunning S2327_MSetA:Bool:=0;//ManualSetpointActivated S2328_ESetA:Bool:=0;//ExternalSetpointActivated S2329_ISet1A:Bool:=0;//InternalSetpoint1Activated S2330_ISet2A:Bool:=0;//InternalSetpoint2Activated S2331_ISet3A:Bool:=0;//InternalSetpoint3Activated S2332_ISet4A:Bool:=0;//InternalSetpoint4Activated END_STRUCT; AV:STRUCT//DataStructureofFaultstoVisu A2223_FFDO:Bool:=0;//FuseDisconnectOpen A2085_FMP:Bool:=0;//MotorProtectorFault A2089_FMT:Bool:=0;//MotorTemperatureFault A2240_FLOS:Bool:=0;//MaintenanceLock-OutSwitch A2026_FVFD:Bool:=0;//VariableFrequencyDriveFault A2306_FTM:Bool:=0;//TorsionalMomentFault END_STRUCT; BV:STRUCT//DataStructureofWarningstoVisu B2089_WMT:Bool:=0;//MotorTemperatureWarning B2026_WVFD:Bool:=0;//VariableFrequencyDriveWarning END_STRUCT; AF:STRUCT//DataStructureofInternalFaults H1_FDO:Bool:=0;//FusedDisconnectOpen H1_MP:Bool:=0;//MotorProtectorFault H1_MT:Bool:=0;//MotorTemperatureFault H1_LOS:Bool:=0;//MaintenanceLock-OutSwitch H1_VFD:Bool:=0;//VariableFrequencyDriveFault END_STRUCT; BF:STRUCT//DataStructureofNewFaults(HornOn) H1_MT:Bool:=0;//MotorTemperatureWarning H1_VFD:Bool:=0;//VariableFrequencyDriveWarning END_STRUCT; AN:STRUCT//DataStructureofNewFaults(HornOn) H1_FDO:Bool:=0;//FusedDisconnectOpen H1_MP:Bool:=0;//MotorProtectorFault H1_MT:Bool:=0;//MotorTemperatureFault H1_LOS:Bool:=0;//MaintenanceLock-OutSwitch H1_VFD:Bool:=0;//VariableFrequencyDriveFault END_STRUCT; BN:STRUCT//DataStructureofNewWarnings(HornOn) H1_MT:Bool:=0;//MotorTemperatureWarning H1_VFD:Bool:=0;//VariableFrequencyDriveWarning END_STRUCT; TS:STRUCT//DataStructureofTimerSetpoints T1427_StDel:Int:=10;//Startdelayedtimersetpoint T1426_MCOff:Int:=10;//MainContactordel.offtimersetpoint T1428_Warn:Int:=2;//DelayedwarningVFDsetpoint END_STRUCT; TA:STRUCT//DataStructureofTimerActualValues T2427_StDel:Int:=0;//Startdelayedtimeractualvalue T2426_MCOff:Int:=0;//MainContactorOfftimeractualvalue T2428_Warn:Int:=0;//DelayedwarningVFDactualvalue END_STRUCT; AS:STRUCT//DataStructureofAnalogSetpoints V7381_ISet1:Real:=0.000000e 000;//InternalSetpoint1 V7382_ISet2:Real:=0.000000e 000;//InternalSetpoint2 V7383_ISet3:Real:=0.000000e 000;//InternalSetpoint3 V7384_ISet4:Real:=0.000000e 000;//InternalSetpoint4 V2324_MSet:Real:=0.000000e 000;//ManualSetpoint END_STRUCT; AA:STRUCT//DataStructureofAnalogActualValues R2319_ActFreq:Real:=0.000000e 000;//ActualFrequency R7256_ActExtSet:Real:=0.000000e 000;//ActualExternalSetpoint R2321_ActSet:Real:=0.000000e 000;//ActualSetpoint R2338_ActCurr:Real:=0.000000e 000;//ActualCurrent END_STRUCT; IM:STRUCT//DataStructureofInternalFlags H1_On:Bool:=0;//DriveOn H1_StDelExp:Bool:=0;//Startdelayedtimerexpired H1_MCOffExp:Bool:=0;//MainContactordel.offtimerexpired H1_WarnExp:Bool:=0;//DelayedwarningVFDtimerexpired END_STRUCT; IM1:STRUCT//DataStructureofStatusWordVariableFrequencyDrive H1_Bit0RDOn:Bool:=0;//READYTOSWITCHON H1_Bit1RDRun:Bool:=0;//READYTOOPERATE H1_Bit2RDRef:Bool:=0;//ENABLEOPERATION H1_Bit3Trip:Bool:=0;//FAULT H1_Bit4OFF2:Bool:=0;//1,OFF2inactive H1_Bit5OFF3:Bool:=0;//1,OFF3inactive H1_Bit6Inhib:Bool:=0;//1,SWITCH-ONINHIBITACTIVE H1_Bit7ALARM:BOOL:=0;//Warning/Alarm H1_Bit8OP:BOOL:=0;//OPERATING.Actualvalueequalsreferencevalue H1_Bit9Remote:Bool:=0;//1,Drivecontrollocation:REMOTE H1_Bit10ExeLimit:Bool:=0;//1,Actualfrequencyorspeedvalueequalsorisgreater//thansupervisionlimit. H1_Bit11:BOOL:=0;//Drive-specific H1_Bit12:Bool:=0;//Drive-specific H1_Bit13:Bool:=0;//Drive-specific H1_Bit14:Bool:=0;//Drive-specific H1_Bit15:Bool:=0;//Drive-specific END_STRUCT; IM2:STRUCT//DataStructureofCommandWordVariableFrequencyDrive H1_Bit0RDOn:Bool:=0;//ProceedtoREADYTOOPERATE H1_Bit1COn:Bool:=0;//1,Continueoperation(OFF2inactive) H1_Bit2COn:Bool:=0;//Continueoperation(OFF3inactive) H1_Bit3Enable:Bool:=0;//ProceedtoENABLEOPERATION H1_Bit4RAMPOUTZR:Bool:=0;//0,Stopaccordingtoselectedstoptype H1_Bit5RAMPHD:Bool:=0;//0,Haltramping(RampFunctionGeneratoroutputheld) H1_Bit6RAMPINZR:Bool:=0;//0,ForceRampFunctionGeneratorinputtozero H1_Bit7Reset:Bool:=0;//0->1Faultresetifanactivefaultexists.ProceedtoSWITCHON//INHIBIT H1_Bit8ICH1:BOOL:=0;//Inching1. H1_Bit9ICH2:Bool:=0;//Inching2. H1_Bit10Remote:Bool:=0;//1,Fieldbuscontrolenabled H1_Bit11:Bool:=0;//Drive-specific. H1_Bit12:BOOL:=0;//Drive-specific. H1_Bit13:Bool:=0;//Drive-specific. H1_Bit14:Bool:=0;//Drive-specific. H1_Bit15:BOOL:=0;//Drive-specific. END_STRUCT;
END_VAR
VAR_TEMP//TemporaryVariables END_VAR
(*---------------------------------------------------getStatusword/Alarmword--------------------------------------------*) IM1.H1_Bit0RDOn:=(VFDState&16#1)=16#1; IM1.H1_Bit1RDRun:=(VFDState&16#2)=16#2; IM1.H1_Bit2RDRef:=(VFDState&16#4)=16#4; IM1.H1_Bit3Trip:=(VFDState&16#8)=16#8; IM1.H1_Bit4OFF2:=(VFDState&16#10)=16#10; IM1.H1_Bit5OFF3:=(VFDState&16#20)=16#20; IM1.H1_Bit6Inhib:=(VFDState&16#40)=16#40; IM1.H1_Bit7ALARM:=(VFDState&16#80)=16#80; IM1.H1_Bit8OP:=(VFDState&16#100)=16#100; IM1.H1_Bit9Remote:=(VFDState&16#200)=16#200; IM1.H1_Bit10ExeLimit:=(VFDState&16#400)=16#400; IM1.H1_Bit11:=(VFDState&16#800)=16#800; IM1.H1_Bit12:=(VFDState&16#1000)=16#1000; IM1.H1_Bit13:=(VFDState&16#2000)=16#2000; IM1.H1_Bit14:=(VFDState&16#4000)=16#4000; IM1.H1_Bit15:=(VFDState&16#8000)=16#8000;
(*--------------------------------------------EnableDevice---------------------------------------------------------------------*) SB.S1252_Enbl:=Enbl; (*-------------------------------------------EnableFaultstoVisu-------------------------------------------------------*) SB.S1255_EnFV:=EnFV; (*-------------------------------------------fault/warncheck--------------------------------------------------------------------*) (*----------------FusedDisconnectOpenFault---------------------------*) AF.H1_FDO:=NOTFDOOR(AF.H1_FDOANDNOTAckn); AV.A2223_FFDO:=AF.H1_FDOAND(SB.S1255_EnFVOR(AV.A2223_FFDOANDNOTAckn)); AN.H1_FDO:=AF.H1_FDOAND(MuteORAN.H1_FDO); (*----------------MotorProtectorFault---------------------------*) AF.H1_MP:=NOTMPOR(AF.H1_MPANDNOTAckn); AV.A2085_FMP:=AF.H1_MPAND(SB.S1255_EnFVOR(AV.A2085_FMPANDNOTAckn)); AN.H1_MP:=AF.H1_MPAND(MuteORAN.H1_MP); (*----------------MotorTempFault---------------------------*) AF.H1_MT:=NOTFMTOR(AF.H1_MTANDNOTAckn); AV.A2089_FMT:=AF.H1_MTAND(SB.S1255_EnFVOR(AV.A2089_FMTANDNOTAckn)); AN.H1_MT:=AF.H1_MTAND(MuteORAN.H1_MT); (*----------------MaintenanceLock-OutSwitchfault---------------------------*) AF.H1_LOS:=NOTLOSOR(AF.H1_LOSANDNOTAckn); AV.A2240_FLOS:=AF.H1_LOSAND(SB.S1255_EnFVOR(AV.A2240_FLOSANDNOTAckn)); AN.H1_LOS:=AF.H1_LOSAND(MuteORAN.H1_LOS); (*----------------MotorTempWarning---------------------------*) BF.H1_MT:=NOTWMTOR(BF.H1_MTANDNOTAckn); BV.B2089_WMT:=BF.H1_MTAND(SB.S1255_EnFVOR(BV.B2089_WMTANDNOTAckn)); BN.H1_MT:=BF.H1_MTAND(MuteORBN.H1_MT);
(*--------------------FrequencyConverterWarningDelayTime---------------------------*) IF(NOTIM1.H1_Bit7ALARMOR(NOTIM.H1_On))THEN TA.T2428_Warn:=0; IM.H1_WarnExp:=0; ELSE IF(NOTIM.H1_WarnExpAND"IP_1Sec")THEN TA.T2428_Warn:=TA.T2428_Warn 1; END_IF; IM.H1_WarnExp:=TA.T2428_Warn>=TS.T1428_Warn; END_IF; BF.H1_VFD:=IM.H1_WarnExpOR(BF.H1_VFDANDNOTAckn); BV.B2026_WVFD:=BF.H1_VFDAND(EnFVOR(BV.B2026_WVFDANDNOTAckn)); BN.H1_VFD:=BF.H1_VFDAND(MuteORBN.H1_VFD); (*--------------------FrequencyConverterFault---------------------------*) AF.H1_VFD:=IM1.H1_Bit3TripOR(AF.H1_VFDANDNOTAckn); AV.A2026_FVFD:=AF.H1_VFDAND(EnFVOR(AV.A2026_FVFDANDNOTAckn)); AN.H1_VFD:=AF.H1_VFDAND(MuteORAN.H1_VFD); (*-----------CollectiveFault-------------------------------------------------------*) Fault:=AF.H1_FDO ORAF.H1_MP ORAF.H1_MT ORAF.H1_LOS ORAF.H1_VFD; (*-----------NewFaults(HornOn)-------------------------------------------------------*) NFlt:=(AF.H1_FDOANDNOTAN.H1_FDO) OR(AF.H1_MPANDNOTAN.H1_MP) OR(AF.H1_MTANDNOTAN.H1_MT) OR(AF.H1_LOSANDNOTAN.H1_LOS) OR(AF.H1_VFDANDNOTAN.H1_VFD); (*-----------CollectiveFault(Visu)-------------------------------------------------------*) SB.S1268_CFV:=AV.A2223_FFDO ORAV.A2085_FMP ORAV.A2089_FMT ORAV.A2240_FLOS ORAV.A2026_FVFD; (*-----------CollectiveWarn-------------------------------------------------------*) Warn:=BF.H1_MT ORBF.H1_VFD; (*-----------NewWarn(HornOn)-------------------------------------------------------*) NWarn:=(BF.H1_MTANDNOTBN.H1_MT) OR(BF.H1_VFDANDNOTBN.H1_VFD); (*-----------CollectiveWarn(Visu)-------------------------------------------------------*) SB.S1269_CWV:=BV.B2089_WMT ORBV.B2026_WVFD;
(*-----------EnableManualOperationfromVisu-------------------------------------------------------*) SB.S1254_EnMV:=EnMVANDManu; (*-----DriveinManualorAutomaticMode-------------------------------------------------------*) IF((((CB.C2254_OnORCB.C2251_Off)ANDEnMV)OR MOnORNOTMOff)AND Manu)THEN SB.S1257_Manu:=1; END_IF; IF((EnMVANDCB.C2263_Auto)ORAuto)THEN SB.S1257_Manu:=0; END_IF; SB.S1251_Auto:=NOTSB.S1257_Manu; (*-----DriveOn(Maincontactor)--------------------------------------------------------------------------------*) IF(((CB.C2254_OnANDEnMV)ORMOn)ANDSB.S1257_Manu)OR (AOnANDSB.S1251_Auto)THEN IM.H1_On:=1; END_IF;
(*-----DriveOff(Maincontactor)-------------------------------------------------------------------------------*) IF(((CB.C2251_OffANDEnMV)ORNOTMOff)ANDManu)OR (AOffANDSB.S1251_Auto)OR FaultOR NOTSB.S1252_EnblTHEN IM.H1_On:=0; END_IF; (*-----afterMainContactoron,DelayedStart-------------------------------------------------------------------------------*) IF(NOTIM.H1_On)THEN TA.T2427_StDel:=0; IM.H1_StDelExp:=0; ELSE IF(NOTIM.H1_StDelExpAND"IP_1Sec")THEN TA.T2427_StDel:=TA.T2427_StDel 1; END_IF; IM.H1_StDelExp:=TA.T2427_StDel>=TS.T1427_StDel; END_IF; (*-----MainContactorOffDelay-------------------------------------------------------------------------------*) IFIM.H1_OnTHEN TA.T2426_MCOff:=0; IM.H1_MCOffExp:=0; ELSE IF(NOTIM.H1_MCOffExpAND"IP_1Sec")THEN TA.T2426_MCOff:=TA.T2426_MCOff 1; END_IF; IM.H1_MCOffExp:=TA.T2426_MCOff>=TS.T1426_MCOff; END_IF; (*-----MainContactoroutput-------------------------------------------------------------------------------*) IFIM.H1_OnTHEN SB.S2251_On:=1; END_IF; IFNOTIM.H1_OnANDIM.H1_MCOffExpTHEN SB.S2251_On:=0; END_IF; On:=SB.S2251_On; (*-----ManualSetpointonfromvisu-------------------------------------------------------------------------------*) IFEnMVANDCB.C2282_MSetOnANDManuTHEN SB.S2327_MSetA:=1; END_IF; IFNOTEnMVORCB.C2283_MSetOffORAutoTHEN SB.S2327_MSetA:=0; END_IF; IFSB.S2327_MSetATHEN AA.R2321_ActSet:=AS.V2324_MSet; END_IF; (*-----CombinedManualModeforVisu-------------------------------------------------------------------------------*) SB.S1267_ManuComb:=SB.S1257_ManuORSB.S2327_MSetA; (*-----ExternalSetpoint(ActualValue)forVisu-------------------------------------------------------------------------------*) AA.R7256_ActExtSet:=ESet; (*-----ExternalSetpointon-------------------------------------------------------------------------------*) SB.S2328_ESetA:=NOTSB.S2327_MSetAANDCIES; IFSB.S2328_ESetATHEN AA.R2321_ActSet:=ESet; END_IF; (*-----InternalSetpoint1on-------------------------------------------------------------------------------*) SB.S2329_ISet1A:=((NOTSB.S2330_ISet2A&NOTSB.S2331_ISet3A&NOTSB.S2332_ISet4A)ORISet1)&NOTCIES&NOTSB.S2327_MSetA; IFSB.S2329_ISet1ATHEN AA.R2321_ActSet:=AS.V7381_ISet1; END_IF; (*-----InternalSetpoint2on-------------------------------------------------------------------------------*) SB.S2330_ISet2A:=NOTCIES&NOTSB.S2327_MSetA&NOTISet1&ISet2; IFSB.S2330_ISet2ATHEN AA.R2321_ActSet:=AS.V7382_ISet2; END_IF; (*-----InternalSetpoint3on-------------------------------------------------------------------------------*) SB.S2331_ISet3A:=NOTCIES&NOTSB.S2327_MSetA&NOTISet1&NOTISet2&ISet3; IFSB.S2331_ISet3ATHEN AA.R2321_ActSet:=AS.V7383_ISet3; END_IF; (*-----InternalSetpoint4on-------------------------------------------------------------------------------*) SB.S2332_ISet4A:=NOTCIES&NOTSB.S2327_MSetA&NOTISet1&NOTISet2&NOTISet3&ISet4; IFSB.S2332_ISet4ATHEN AA.R2321_ActSet:=AS.V7384_ISet4; END_IF; (*-----ActualFrequencysetpoint(Hz)forVISU-------------------------------------------------------------------------------*) OFreq:=AA.R2321_ActSet; (*-----Scalingofpreselectedsetpoint->FC-------------------------------------------------------------------------------*) //-20000--20000(-Parm11.05--Parm11.05);Parm11.04decidefrom0startorfrom-start IFAA.R2321_ActSet>9.990000e 001THEN VFDFreqCom:=W#16#7FFF; ELSE VFDFreqCom:=DINT_TO_WORD(ROUND((2.000000e 004/5.000000e 001)*AA.R2321_ActSet)); END_IF; (*-----Scalingofactualfrequencyvalue<-FC-------------------------------------------------------------------------------*) AA.R2319_ActFreq:=5.000000e 001*DWORD_TO_REAL(VFDFreq)/2.000000e 004;//20000=50Hz (*-----FrequencyConverterCommandWord:Start/Stop-------------------------------------------------------------------------------*) IFNOTSB.S1252_EnblTHEN VFDLogicCom:=W#16#47A;//"QuickStop"10001111010,stopinthesetpointtime(P22.07) ELSIFNOTIM.H1_OnORNOTFBOnORFaultTHEN VFDLogicCom:=W#16#47C;//"freeStop"10001111100 ELSE IFNOTIM.H1_StDelExpTHEN VFDLogicCom:=W#16#476;//Precondition"Start"10001110110 ELSE VFDLogicCom:=W#16#47F;//"Start"10001111111 END_IF; END_IF; IM2.H1_Bit7Reset:=Ackn; (*-----FrequencyConverterFaultReset-------------------------------------------------------------------------------*) IFAcknTHEN VFDLogicCom:=VFDLogicComOR16#80; ELSE VFDLogicCom:=VFDLogicComAND16#FF7F; END_IF;
(*-----VariableFrequencyDriveRunningforVisu-------------------------------------------------------------------------------*) SB.S2324_VFDRun:=On&IM1.H1_Bit8OP; (*-----ResetVisuControlBits-------------------------------------------------------------------------------*) CB.C2254_On:=0; CB.C2251_Off:=0; CB.C2263_Auto:=0; CB.C2282_MSetOn:=0; CB.C2283_MSetOff:=0; (*-----MessageRunning/Fault-------------------------------------------------------------------------------*) MeOn:=(NOT(FaultORWarn)&FBOn&On&IM1.H1_Bit8OP)OR((FaultORWarn)AND"FP_1Sec")ORLT;
END_FUNCTION_BLOCK
|