回复:有奖【微分享】“说说我用过的功能块”

Zane

版主 西门子1847工业学习平台

  • 帖子

    21349
  • 精华

    403
  • 被关注

    1502

论坛等级:至圣

注册时间:2003-06-06

钻石 钻石 如何晋级?

发布于 2014-04-16 21:31:37

151楼

quote:以下是引用szy868在2014-04-16 10:27:49的发言:
我也贴一个自己编写使用的功能块,油泵站双泵启停控制,具备现场/远方、手动/自动启停,故障切换,定时切换,计时功能,SCL语言。

//电机选择开关位置判断
IF "M1Select" THEN
IF "M2Select" THEN
"DBForAlarm".MotorSWError := true;
ELSE
"DBForInternalControl".SelMark1 := true;
"DBForInternalControl".SelMark2 := false;
"DBForInternalControl".AutoStatus := false;
END_IF;
ELSE
IF "M2Select" THEN
"DBForInternalControl".SelMark1 := false;
"DBForInternalControl".SelMark2 := true;
"DBForInternalControl".AutoStatus := false;
ELSE
"DBForInternalControl".SelMark1 := false;
"DBForInternalControl".SelMark2 := false;
"DBForInternalControl".AutoStatus := true;
END_IF;
END_IF;

//使用定时器判断两台泵是否为非自动切换时的停运状态
"DBForM1AndM2StopTimer".TON(IN:=(NOT "KM1NO" AND NOT "KM2NO"),
PT:=100ms);

//泵站自动运行状态的判断
IF "DBForInternalControl".AutoStatus AND ("KM1NO" OR "KM2NO" ) THEN
"DBForInternalControl".PSAutoRunMarker := true;
ELSE
IF "DBForInternalControl".AutoStatus THEN
IF "DBForM1AndM2StopTimer".Q THEN
"DBForInternalControl".PSAutoRunMarker := false;
END_IF;
ELSE
"DBForInternalControl".PSAutoRunMarker := false;
END_IF;
END_IF;

//1#泵电机启动命令,包括:
//1、现场手动选择启动;
//2、现场自动选择启动;
//3、泵站自动运行状态下,定时切换启动;
//4、泵站自动运行状态下,工作泵故障自动切换启动。此类自动启动的故障包括:过热、进口滤器堵塞、运行压力低。
//5、远方启动命令;
IF "StartSBNO" AND ( "DBForInternalControl".SelMark1
OR ( "DBForInternalControl".AutoStatus AND (NOT "KM2NO") AND "DBForInternalControl".TotalRunTime1 <= "DBForInternalControl".TotalRunTime2))
OR ( "DBForInternalControl".AutoStatus AND "DBForDataDown".StartM1 )
OR "DBForInternalControl".PSAutoRunMarker AND ( ("DBForInternalControl".MotorAutoSwtichPattern AND "DBForInternalControl".CurrentRunTime2 >= "DBForInternalControl".SingleWorkTimeSV )
OR "DBForAlarm".FR2Alarm
OR "DBForAlarm".FilterClogAlarm2
OR "DBForAlarm".PumpRunPressLowAlarm2 ) THEN
"DBForInternalControl".StartPump1 := true;
ELSE
"DBForInternalControl".StartPump1 := false;
END_IF;

//1#泵电机停止命令
//工作泵工作出现故障,停止工作泵。包括电机过热、进口滤器堵塞、工作油压低、工作油压高、油位低。
IF ( NOT "StopSBNC" AND NOT "DBForInternalControl".SelMark2 )
OR ( "DBForInternalControl".AutoStatus AND "DBForDataDown".StopM1 )
OR ( "DBForInternalControl".PSAutoRunMarker AND "KM2NO" AND "DBForInternalControl".MotorAutoSwtichPattern AND "DBForInternalControl".CurrentRunTime1 >= "DBForInternalControl".SingleWorkTimeSV )
OR "DBForAlarm".FR1Alarm
OR "DBForAlarm".FilterClogAlarm1
OR "DBForAlarm".OilLeverLowAlarm
OR "DBForAlarm".PumpRunPressLowAlarm1
OR "DBForAlarm".PressHighAlarm
THEN
"DBForInternalControl".StopPump1 := true;
ELSE
"DBForInternalControl".StopPump1 := false;
END_IF;

//2#泵电机启动命令,包括:
IF "StartSBNO" AND ( "DBForInternalControl".SelMark2
OR ( "DBForInternalControl".AutoStatus AND (NOT "KM1NO") AND "DBForInternalControl".TotalRunTime2 < "DBForInternalControl".TotalRunTime1))
OR ( "DBForInternalControl".AutoStatus AND "DBForDataDown".StartM2 )
OR "DBForInternalControl".PSAutoRunMarker AND ( ("DBForInternalControl".MotorAutoSwtichPattern AND "DBForInternalControl".CurrentRunTime1 >= "DBForInternalControl".SingleWorkTimeSV )
OR "DBForAlarm".FR1Alarm
OR "DBForAlarm".FilterClogAlarm1
OR "DBForAlarm".PumpRunPressLowAlarm1 ) THEN
"DBForInternalControl".StartPump2 := true;
ELSE
"DBForInternalControl".StartPump2 := false;
END_IF;

//2#泵电机停止命令
IF ( NOT "StopSBNC" AND NOT "DBForInternalControl".SelMark1 )
OR ( "DBForInternalControl".AutoStatus AND "DBForDataDown".StopM2 )
OR ( "DBForInternalControl".PSAutoRunMarker AND "KM1NO" AND "DBForInternalControl".MotorAutoSwtichPattern AND "DBForInternalControl".CurrentRunTime2 >= "DBForInternalControl".SingleWorkTimeSV )
OR "DBForAlarm".FR2Alarm
OR "DBForAlarm".FilterClogAlarm2
OR "DBForAlarm".OilLeverLowAlarm
OR "DBForAlarm".PumpRunPressLowAlarm2
OR "DBForAlarm".PressHighAlarm
THEN
"DBForInternalControl".StopPump2 := true;
ELSE
"DBForInternalControl".StopPump2 := false;
END_IF;

//1#泵控制命令输出
IF NOT "DBForInternalControl".StopPump1 AND ("DBForInternalControl".StartPump1 OR "KM1NO" ) THEN
"StartM1" := true;
ELSE
"StartM1" := false;
END_IF;

//2#泵控制命令输出
IF NOT "DBForInternalControl".StopPump2 AND ("DBForInternalControl".StartPump2 OR "KM2NO" ) THEN
"StartM2" := true;
ELSE
"StartM2" := false;
END_IF;

//创建1min定时器脉冲
"DBForOneMinPulseTimer".TON(IN:=NOT "FirstScan",
PT:=60s,
Q=>"FirstScan");


//累计1#泵运行时间
IF "KM1NO" THEN
IF "FirstScan" THEN
"DBForInternalControl".TotalRunTime1 := "DBForInternalControl".TotalRunTime1 + 1;
"DBForInternalControl".CurrentRunTime1 := "DBForInternalControl".CurrentRunTime1 + 1;
END_IF;
ELSE
"DBForInternalControl".CurrentRunTime1 := 0;
END_IF;

//累计2#泵运行时间
IF "KM2NO" THEN
IF "FirstScan" THEN
"DBForInternalControl".TotalRunTime2 := "DBForInternalControl".TotalRunTime2 + 1;
"DBForInternalControl".CurrentRunTime2 := "DBForInternalControl".CurrentRunTime2 + 1;
END_IF;
ELSE
"DBForInternalControl".CurrentRunTime2 := 0;
END_IF;

//1#接触器位置指示
IF "DBForTDExchange".TestLamp OR "KM1NO" THEN
"M1RunningLamp" := true;
ELSE
"M1RunningLamp" := false;
END_IF;

//2#接触器位置指示
IF "DBForTDExchange".TestLamp OR "KM2NO" THEN
"M2RunningLamp" := true;
ELSE
"M2RunningLamp" := false;
END_IF;

//计算电机总运行计时显示
"DBForTDExchange".TotalRunningDays1 := "DBForInternalControl".TotalRunTime1 / 1440;
"DBForTDExchange".TotalRunningDays2 := "DBForInternalControl".TotalRunTime2 / 1440;
"DBForTDExchange".TotalRunningHours1 := "DBForInternalControl".TotalRunTime1 / 60 - "DBForTDExchange".TotalRunningDays1 * 24;
"DBForTDExchange".TotalRunningHours2 := "DBForInternalControl".TotalRunTime2 / 60 - "DBForTDExchange".TotalRunningDays2 * 24;
//计算电机当前运行计时显示
"DBForTDExchange".CurrentRunningHours1 := "DBForInternalControl".CurrentRunTime1 / 60;
"DBForTDExchange".CurrentRunningHours2 := "DBForInternalControl".CurrentRunTime2 / 60;
"DBForTDExchange".CurrentRunningMinutes1 := "DBForInternalControl".CurrentRunTime1 - "DBForTDExchange".CurrentRunningHours1 * 60;
"DBForTDExchange".CurrentRunningMinutes2 := "DBForInternalControl".CurrentRunTime2 - "DBForTDExchange".CurrentRunningHours2 * 60;

恕我直言,这个梯形图语句表解决问题就够了。
Zane 注册自动化系统工程师 Always save before download
评论
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-300/400

共有54756条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
X 图片
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。