方向逻辑PLC

发布于 2024-08-19 01:48:26 字数 138 浏览 2 评论 0原文

如何使用 PLC 梯形图确定输入方向?意思是,如何保存之前的状态?

输入的先前状态。我需要确定光束被激活的方向……向前或向后。如果它们被反向激活,则执行一项操作。如果它们向前激活,请执行不同的操作。输入标记为 1 到 6。法线方向为 1 到 6。

How do you determine direction of inputs using ladder diagrams with a PLC? Meaning, how do you save the previous state?

Previous state of inputs. I need to determine direction that photobeams were activated.. forward or reverse. If they are activated in reverse, perform one action. If they are activated forwards, perform a different action. Inputs labeled 1 through 6. Normal direction is 1 through 6.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鸩远一方 2024-08-26 01:48:26

这是梯形逻辑中锁存器的简单实现:

|-----[ ]-----+-----------------( )--------|
|    input    |                output      |
|             |                            |
|-----[ ]-----'                            |
     output

这是您可以重置输出的一个:

|-----[ ]-------------+---------( )--------|
|    input            |        output      |
|                     |                    |
|-----[ ]-----[/]-----'                    |
    output   reset

它们构成了梯形逻辑中内存的基本构建块。我不确定,但这就是您要找的吗?

通常,实现梯形逻辑的语言将具有实现存储器的更高级别元素,例如 D 和 T 触发器。阅读梯形图逻辑实现的文档以查看它们是否可用。

好的,从您的评论来看,您想要的是:

// Pseudocode:
// a = sensor 1
// b = sensor 2

if (a) {
    a_triggered = true;
}

if (b) {
    if (!a_triggered) {
        REVERSE_DETECTED();
    }
    else {
        a_triggered = false;
    }
}

这假设传感器靠近在一起,以便转换为 10->11->01,这样当项目同时触发时,您无法检测到行进方向传感器。以声明方式编写此内容:

a_triggered = (a || a_triggered) && !(b_triggered && !b);
b_triggered = (b || b_triggered) && a_triggered;
reverse_detected = b && !a_triggered;

这意味着:

|-----[ ]---------+-----[/]--------( )--------|
|      a          |      c     a_triggered    |
|                 |                           |
|-----[ ]---------'                           |
|  a_triggered                                |
|                                             |
|-----[ ]---------+-----[ ]--------( )--------|
|      b          | a_triggered  b_triggered  |
|                 |                           |
|-----[ ]---------'                           |
|  b_triggered                                |
|                                             |
|-----[ ]----------[/]-------------( )--------|
|  b_triggered      b               c         |
|                                             |
|-----[ ]----------[/]-------------( )--------|
|      b      a_triggered   reverse_detected  |

现在您可以使用反向检测到的信号来执行您想要的操作。如果你的梯形语言有锁存器,你可以这样做更干净:

|                             _________       |
|-----[ ]--------------------|set latch|------|
|      a                     |         |      |
|-----[ ]--------------------|clear    |      |
|      c                     |_________|      |
|                            a_triggered      |
|                             _________       |
|-----[ ]--------------------|set latch|------|
|      b                     |         |      |
|-----[/]--------------------|clear    |      |
|  a_triggered               |_________|      |
|                            b_triggered      |
|                                             |
|-----[ ]----------[/]-------------( )--------|
|  b_triggered      b               c         |
|                                             |
|-----[ ]----------[/]-------------( )--------|
|      b      a_triggered   reverse_detected  |

Here's a simple implementation of a latch in ladder logic:

|-----[ ]-----+-----------------( )--------|
|    input    |                output      |
|             |                            |
|-----[ ]-----'                            |
     output

and here's one where you can reset the output:

|-----[ ]-------------+---------( )--------|
|    input            |        output      |
|                     |                    |
|-----[ ]-----[/]-----'                    |
    output   reset

These form the fundamental building blocks for memory in ladder logic. I'm not sure but is this what you're looking for?

Usually a language implementing ladder logic will have higher level elements that implement memory such as D and T flip-flops. Read the documentation of your ladder logic implementation to see if they're available.

OK, from your comments it looks like what you want is:

// Pseudocode:
// a = sensor 1
// b = sensor 2

if (a) {
    a_triggered = true;
}

if (b) {
    if (!a_triggered) {
        REVERSE_DETECTED();
    }
    else {
        a_triggered = false;
    }
}

This assumes the sensors are close together such that the transition is 10->11->01 such that you can't detect the travel direction while the item is triggering both sensors. Writing this declaratively:

a_triggered = (a || a_triggered) && !(b_triggered && !b);
b_triggered = (b || b_triggered) && a_triggered;
reverse_detected = b && !a_triggered;

Which translates to:

|-----[ ]---------+-----[/]--------( )--------|
|      a          |      c     a_triggered    |
|                 |                           |
|-----[ ]---------'                           |
|  a_triggered                                |
|                                             |
|-----[ ]---------+-----[ ]--------( )--------|
|      b          | a_triggered  b_triggered  |
|                 |                           |
|-----[ ]---------'                           |
|  b_triggered                                |
|                                             |
|-----[ ]----------[/]-------------( )--------|
|  b_triggered      b               c         |
|                                             |
|-----[ ]----------[/]-------------( )--------|
|      b      a_triggered   reverse_detected  |

Now you can use the reverse detected signal to do what you want. If your ladder language has latches you can do this cleaner:

|                             _________       |
|-----[ ]--------------------|set latch|------|
|      a                     |         |      |
|-----[ ]--------------------|clear    |      |
|      c                     |_________|      |
|                            a_triggered      |
|                             _________       |
|-----[ ]--------------------|set latch|------|
|      b                     |         |      |
|-----[/]--------------------|clear    |      |
|  a_triggered               |_________|      |
|                            b_triggered      |
|                                             |
|-----[ ]----------[/]-------------( )--------|
|  b_triggered      b               c         |
|                                             |
|-----[ ]----------[/]-------------( )--------|
|      b      a_triggered   reverse_detected  |
倒带 2024-08-26 01:48:26

使用 DirectLogic 可编程控制器,有一个差分输入可以使这变得非常容易。我敢打赌大多数 PLC 都有类似的指令。

然而,如果您使用 DirectLogic PLC,它们的 RLL-Plus 阶段编程将是梯形逻辑领域内“状态”编程的更清晰的实现。

当输入从低电平变为高电平时,正差分将用于执行输出逻辑。它仅适用于一个周期,因此您可能需要接合锁存器或使用“设置”。这取决于光电管重叠:

|
|----] _| [------] [----------------------( set )---|
|      1          2         |       reverse detected
|                           |
|----] _| [------] [--------|
|      2          3         |  
|                           |
|----] _| [------] [--------|
|      3          4         |  
|                           |
|----] _| [------] [--------|
|      4          5         |
|                           |
|----] _| [------] [--------|
|      5          6         
|
|

在这种情况下,如果 2 开启且 1 变高,则设置或锁存反向检测位。如果您关心这些事情,则对每个可能的反转(2 变高而 3 开启)输入逻辑进行或操作会将其保持在单个梯级。

我不清楚光电管是否有重叠。如果不重叠,我可能会这样做更像 slebetman 的答案:

|
|----]|_ [-------------------------------( set )---|
|      2                                2 exited
|                           
|----]|_ [-------------------------------( set )---|
|      3                             |  3 exited
|                                    |
|                                    |---( rst )---|
|                                       2 exited
|
|
|----]|_ [-------------------------------( set )---|
|      4                             |  4 exited
|                                    |
|                                    |---( rst )---|
|                                       3 exited
|
|
|----]|_ [-------------------------------( set )---|
|      5                             |  5 exited
|                                    |
|                                    |---( rst )---|
|                                       4 exited
|
|
|----]|_ [-------------------------------( set )---|
|      6                             |  6 exited
|                                    |
|                                    |---( rst )---|
|                                       5 exited
|
|
|----] _| [------] [----------------------( set )---|
|      1      2 exited      |       reverse detected
|                           |
|----] _| [------] [--------|
|      2      3 exited      |  
|                           |
|----] _| [------] [--------|
|      3      4 exited      |  
|                           |
|----] _| [------] [--------|
|      4      5 exited      |  
|                           |
|----] _| [------] [--------|
|      5      6 exited      
|                           

来自 手册

与正微分指令对串联的常开触点与梯级中的另一个触点进行逻辑与运算。触点的状态将保持打开状态,直到关联的图像寄存器点进行“关闭”到“打开”的转换,并在一次 CPU 扫描期间将其关闭。此后,它保持打开状态,直到另一次从关闭到开启的转换。

Using the DirectLogic programmable controllers, there is a differential input that would make this very easy. I would be willing to bet that most PLC's have similar instructions.

However, if you are using DirectLogic PLC's, their RLL-Plus stage programming would be a much clearer implementation of "stateful" programming within the ladder logic realm.

The positive differential would be used to execute output logic when the input goes from low to high. It is only true for one cycle, so it is possible you would need to engage a latch or utilize a "set". This depends on the photocells being overlapping:

|
|----] _| [------] [----------------------( set )---|
|      1          2         |       reverse detected
|                           |
|----] _| [------] [--------|
|      2          3         |  
|                           |
|----] _| [------] [--------|
|      3          4         |  
|                           |
|----] _| [------] [--------|
|      4          5         |
|                           |
|----] _| [------] [--------|
|      5          6         
|
|

In this case, if 2 is on, and 1 goes high, you set or latch the reverse detection bit. Or'ing the input logic with each possible reversal ( 2 goes high while 3 is on) would keep this down to a single rung if you care about such things.

I wasn't clear on whether or not there is overlap in the photocells. If not overlapping, I might do this more like slebetman's answer:

|
|----]|_ [-------------------------------( set )---|
|      2                                2 exited
|                           
|----]|_ [-------------------------------( set )---|
|      3                             |  3 exited
|                                    |
|                                    |---( rst )---|
|                                       2 exited
|
|
|----]|_ [-------------------------------( set )---|
|      4                             |  4 exited
|                                    |
|                                    |---( rst )---|
|                                       3 exited
|
|
|----]|_ [-------------------------------( set )---|
|      5                             |  5 exited
|                                    |
|                                    |---( rst )---|
|                                       4 exited
|
|
|----]|_ [-------------------------------( set )---|
|      6                             |  6 exited
|                                    |
|                                    |---( rst )---|
|                                       5 exited
|
|
|----] _| [------] [----------------------( set )---|
|      1      2 exited      |       reverse detected
|                           |
|----] _| [------] [--------|
|      2      3 exited      |  
|                           |
|----] _| [------] [--------|
|      3      4 exited      |  
|                           |
|----] _| [------] [--------|
|      4      5 exited      |  
|                           |
|----] _| [------] [--------|
|      5      6 exited      
|                           

From the Manual:

The And Positive Differential instruction logically ANDs a normally open contact in series with another contact in a rung. The status of the contact will be open until the associated image register point makes an Off- to-On transition, closing it for one CPU scan. Thereafter, it remains open until another Off-to-On transition.

戴着白色围巾的女孩 2024-08-26 01:48:26

对于仅两个传感器 i0 和 i1

O3 = OFF => 前进方向

O3 = ON => 反向

下面的梯形图显示了逻辑:

梯形图

For just two sensors i0 and i1

O3 = OFF => forward direction

O3 = ON => reverse direction

The following ladder diagram shows the logic:

ladder diagram

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文