【发布时间】:2018-10-13 01:10:56
【问题描述】:
我有 PC 编程(VB/C# .Net 和 PHP)的背景,正在学校学习 PLC 编程。在最近的一次测试中,我们在哪里创建了一个功能块,它将生产线的一个元素推入一个容器中。
现在,这很简单,所以我在我的代码中添加了一个警报,如果在 10 秒内没有完成操作,将激活“推动器”(因为没有更好的词)。
我的问题是推送器立即进入警报状态,它似乎相当有问题:(所以任何答案都会给出一些指导如何更好地构建我的代码,或者弄清楚为什么它会这么快进入警报状态...
(* INIT *)
(* Drive the pusher back if its out on init *)
IF M8002 THEN
SkyvTilbake := TRUE; (* My "Function"/Step to retract the pusher *)
Ferdig := FALSE; (*Let other components know that the pushers operation has completed *)
SkyverUtMotor := FALSE; (*This is the engine output for driving the pusher out *)
SkyverInnMotor := FALSE; (* This is the engine output for driving the pusher in *)
END_IF;
(* "Aktiver" is a input to activate the pusher *)
IF Aktiver THEN
SkyvTilbake := FALSE;
SkyvUt := TRUE; (* My "Function"/Step" to push the pusher out *)
Ferdig := FALSE;
END_IF;
(* Push out step *)
IF SkyvUt AND NOT SkyvTilbake AND NOT Alarm THEN
TON_1(IN:= SkyvUt ,PT:= AlarmTid ,Q:= Alarm ,ET:= TimeLeft );
SkyverUtMotor := TRUE;
(* When sensor out activates (input), retract the pusher *)
IF SensorUte THEN
SkyvUt := FALSE;
SkyvTilbake := TRUE;
SkyverUtMotor := FALSE;
END_IF;
(* retract the pusher as long as there are no alarms *)
ELSIF SkyvTilbake AND NOT Alarm THEN
TON_2(IN:= SkyvTilbake ,PT:= AlarmTid ,Q:= Alarm ,ET:= TimeLeft );
SkyverInnMotor := TRUE;
(* When it reach the normal position, activate "Ferdig" *)
IF SensorInne THEN
SkyverInnMotor := FALSE;
SkyvTilbake := FALSE;
Ferdig := TRUE;
END_IF;
END_IF;
(* When the alarm activates, stop all the engines *)
IF Alarm THEN
SkyverUtMotor := FALSE;
SkyverInnMotor := FALSE;
END_IF;
(* RESET ALARM *)
IF Reset THEN
Alarm := 0;
SkyvTilbake := TRUE;
END_IF;
PS。测试是在 12 月中旬进行的,但我希望了解更多关于结构化文本和设计 PLC 程序的信息。此外,该代码被设计为在 Mitsubishi FXCPU 中运行,并使用 GX Works 2 编写
【问题讨论】:
标签: plc