PLC 中的定时器 - 结构化文本 [英] Timers in PLC - Structured Text

查看:52
本文介绍了PLC 中的定时器 - 结构化文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

定时器如何在 PLC 结构化文本 (ST) 中工作?我们如何声明它们?

How do timers work in PLC Structured Text (ST)? How do we declare them?

我一直在研究 PLC 的标准 (IEC 61131-3),他们没有谈论 ST 中的计时器.我知道绝大多数 PLC 程序员在梯形逻辑中执行它们,但在这种特殊情况下,我真的需要在 ST 中声明定时器.

I've been studying a standard of PLC (IEC 61131-3), and they do not speak about timers in ST. I know the great majority of PLC programmers do them in ladder logic, but in this particular case I really need to declare timers in ST.

我使用的是罗克韦尔 PLC.

I am using a Rockwell PLC.

推荐答案

您可以在 IDE 的帮助系统中找到有关计时器以及如何使用(声明)它的说明.例如,在 CODESYS 帮助中,您可以阅读有关标准库计时器的信息.

You can find explanations about timers and how to use (declare) it in the help system of your IDE. For example, in the CODESYS help you can read about timers of the standard library.

通常,您可以将定时器延迟 (TON) 声明为:

In general, you can declare timer-delay (TON) as:

VAR
    MY_TON: TON;
END_VAR
(* standard.library should be added to the project *)

然后就可以使用了:

MY_TON(IN:= IN_VALUE,PT:= TIME_SET);
(*IN_VALUE - is BOOL variable that activates your timer
  TIME_SET - is TIME variable*)

SOME_OUTPUT := MY_TON.Q;
(*Q - is the timer's output, and it can be used as BOOL variable. *)

您还可以使用常量来设置计时器:

You can also use constants to set up your timer:

MY_TON(IN:= True, PT:= t#5s);

作为 BOOL 变量,定时器的输出可用于 IF 和 WHILE 语句:

As a BOOL variable, the timer's output can be used in IF and WHILE statements:

IF MY_TON.Q THEN
    (*Some statements...*)
END_IF

WHILE MY_TON.Q DO
    (*Some statements...*)
END_WHILE

所有示例都在 CODESYS v3.5 SP5 和 v2.3 中运行.对于其他 IDE,可能会有细微差别.

All examples are run in CODESYS v3.5 SP5 and v2.3. For other IDEs there might be nuances.

这篇关于PLC 中的定时器 - 结构化文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆