PLC基本知識 -- 4.5 One-Shots上升下降沿(順便學英文)

One-shots / 上升沿or下降沿

A one-shot is an interesting and invaluable programming tool。 At first glance it might be difficult to figure out why such an instruction is needed。 After we understand what this instruction does and how to use it, however, the necessity will become clear。

One-shot是一種有趣的、無價的程式設計工具。乍一看,很難理解為什麼需要這樣的指令。然而,在我們理解了這個指令的作用以及如何使用它之後,必要性就變得清楚了。

A one-shot is used to make something happen for

ONLY 1 SCAN

(you do remember what a scan is, right??) Most manufacturers have one-shots that react to an OFF to ON transition and a different type that reacts to an ON to OFF transition。 Some names for the instructions could be difu/difd (differential up/down), sotu/sotd (single output up/down), osr (one-shot rising) and others。 They all, however, end up with the same result regardless of the name。

One-shot是用來讓某事只在一個掃描週期內發生(你還記得什麼是掃描吧?)。大多數品牌的PLC有兩種型別的One-shot指令,一種是在由OFF轉換成ON時發生,另一種是在由ON轉換成OFF時發生。這些指令的名稱可以是DIFU/DIFD(differential up/down)、SOTU/SOTD(single output up/down)、或者OSR(one-shot rising)等等。然而,不管名稱如何,它們最終得到的結果都是相同的。

PLC基本知識 -- 4.5 One-Shots / 上升下降沿  (順便學英文)

One-shot Instruction / One-shot 指令(上升沿指令)

Above is the symbol for a difu (one-shot) instruction。 A difd looks the same but inside the symbol it says “difd”。 Some of the manufacturers have it in the shape of a box but, regardless of the symbol, they all function the same way。 For those manufacturers that don‘t include a differential down instruction, you can get the same effect by putting a NC (normally closed) instruction before it instead of a NO(normally open) instruction。 (i。e。 reverse the logic before the difu instruction)

上面是DIFU(One-shot)指令的符號,DIFD的符號看起來是和這一樣的,但是在符號裡面寫著“DIFD”。有些品牌的PLC用的是盒子的形狀,但不管它的符號是什麼形狀,它們的功能都是一樣的。對於那些不包含DIFD(向下微分)指令的PLC,您可以透過在前面放置NC(常閉)指令而不是NO(常開)指令來獲得相同的效果(即在DIFU指令前加反邏輯)。

Let’s now setup an application to see how this instruction actually functions in a ladder。 This instruction is most often used with some of the advanced instructions where we do some things that MUST happen only once。 However, since we haven‘t gotten that far yet, let’s set up a flip-flop circuit。 In simple terms, a flip-flop turns something around each time an action happens。 Here we‘ll use a single pushbutton switch。 The first time the operator pushes it we want an output to turn on。 It will remain “latched” on until the next time the operator pushes the button。 When he does, the output turns off。

現在,讓我們來設定一個應用程式,看看這個指令實際上是如何在梯形圖中工作的。這個指令最常與一些高階指令一起使用,在這些高階指令中,我們用它來做一些必須只發生一次的事情。然而,由於我們還沒有學得那麼深,我們先設定一個觸發器電路,簡單地說,每次一個動作發生時,觸發器都會發生一個狀態變化。這裡我們將使用一個單按鈕開關,操作員第一次推它時,我們希望開啟輸出,這個輸出將一直“鎖定”在開啟狀態,直到下一次操作員按下那個單按鈕開關,輸出才會關閉。

PLC基本知識 -- 4.5 One-Shots / 上升下降沿  (順便學英文)

Here’s the ladder diagram that does just that: / 這是實現上述功能的梯形圖

Now this looks confusing! Actually it‘s not if we take it one step at a time。

現在看起來是不是覺得很混亂!事實上,如果我們一步一步來,就不是這樣的。

First Scan / 第一次掃描

Rung 1 - When NO (normally open) input 0000 becomes true DIFU 1000 becomes true。

Rung 1 - 常開觸點0000變為“真”(True)時,DIFU 1000也變為“真”(True)。

Rung 2 - NO 1000 is true, NO 1001 remains false, NC 1001 remains true, NC 1000 turns false。 Since we have a true path, (NO 1000 & NC 1001) OUT 1001 becomes true。

Rung 2 – 常開觸點1000為“真”(True),常開觸點1001為“假”(False),常閉觸點1001 為“真”(True),常閉觸點1000為“假”(False)。因為Rung 2中有一條路徑是“真”(True)【即常開觸點1000 & 常閉觸點1001】 ,所以輸出1001變成了“真”(True)。

Rung 3 - NO 1001 is true therefore OUT 0500 turns true。

Rung 3 – 常開觸點1001為“真”(True),所以輸出0500變為“真”(True)。

Next Scan / 第二次掃描

Rung 1 - NO 0000 remains true。 DIFU 1000 now becomes false。 This is because the DIFU instruction is only true for one scan。 (i。e。 the rising edge of the logic before it on the rung)

Rung 1 – 常開觸點0000仍然是“真”(True),但DIFU 1000現在變成了“假”(False),這是因為DIFU指令的“真”(True)狀態只能一個掃描週期有效(即邏輯的上升沿使Rung 1變成“真”)。

Rung 2 - NO 1000 is false, NO 1001 remains true, NC 1001 is false, NC 1000 turns true。 Since we STILL have a true path, (NO 1001 & NC 1000) OUT 1001 remains true。

Rung 2 – 常開觸點1000為“假”(False),常開觸點1001為“真”(True),常閉觸點1001為“假” (False),常閉觸點1000為“真”(True)。因為Rung 2中有一條路徑任然為“真”(True)【即常開觸點1001 & 常閉觸點1000】,所以輸出1001仍然是“真”(True)。

Rung 3 - NO 1001 is true therefore OUT 0500 remains true。

Rung 3 – 常開觸點1001是“真”(True),所以輸出0500仍然保持為“真”(True)。

100 Scan / 第100次掃描

(NO 0000 turns off / 常開觸點0000變為“假”)

After 100 scans, NO 0000 turns off (becomes false)。 The logic remains in the same state as “next scan” shown above。 (difu doesn’t react therefore the logic stays the same on rungs 2 and 3)

假設經過100次掃描後,常開觸點0000變為了“假”(False),梯形圖的邏輯任然會保持與上面所示的“第二次掃描”相同的狀態(由於DIFU沒有反應,因此邏輯狀態在Rung 2和Rung 3都保持不變)。

101 Scan / 第101次掃描

(NO 0000 turns on again / 常開觸點0000點再次變為“真”)

Rung 1 - When NO (normally open) input 0000 becomes true DIFU 1000 becomes true。

Rung 1 - 當常開觸點0000為“真”(True)時,指令DIFU 1000變為“真”(True)。

Rung 2 - NO 1000 is true, NO 1001 remains true, NC 1001 becomes false, NC 1000 also becomes false。 Since we no longer have a true path, OUT 1001 becomes false。

Rung 2 – 常開觸點1000為“真”(True),常開觸點1001為“真”(True),常閉觸點1001為“假“(False),常閉觸點1000也為“假”(False)。由於在Rung2橫檔上不再有一條路徑是“真”(True),所以輸出1001變成了“假”(False)。

Rung 3 - NO 1001 is false therefore OUT 500 becomes false。

Rung 3 – 常開觸點1001變為“假”(False),因此輸出0500變為了“假”(False)。

PLC基本知識 -- 4.5 One-Shots / 上升下降沿  (順便學英文)

In the example above, each time the operator pushes button 0000 the DIFU instruction turns on (becomes true) FOR ONE SCAN。 Notice that it turns on (becomes true) at the rising edge of input 0000。 In other words, when input 0000

initially

turns on (becomes true) the DIFU instruction is true。

在上面的例子中,每次操作員按下0000按鈕,DIFU1000指令就會變為“真(Ture)”並持續一個掃描週期。注意,DIFU1000是在輸入0000的上升沿時處於ON狀態(變為True)。換句話說,只是在輸入0000開啟(變為“真”)的

初始階段

,DIFU1000指令變為“真”(True)。

When an input initially becomes true its called the leading or rising edge。 When it initially turns off (becomes false) its called the trailing or falling edge。

當一個輸入變為“真”(True)時,那個初始階段我們稱它為上升沿;當一個輸入變為“假”(False)時,那個初始階段我們稱它為下降沿。

If after viewing the animation you still find it difficult to understand, don‘t feel bad。 You’re just an idiot and should give up!!! No not really。 Just try to remember how its scanned by the plc。 Think it through one instruction at a time from top to bottom, then left to right。 (i。e。 in this order: NO 0000, DIFU 1000, NO 1000, NO 1001, NC 1001, NC 1000, OUT 1001, NO 1001, OUT 500) While executing each instruction is it true or false?

如果看完上面的動畫演示後你仍然覺得難以理解,不要難過。你就是個白痴,應該放棄!!不,不,絕對不是,只要記住這段程式是如何被PLC掃描的,挨個指令地去想,從上到下,從左到右(即按這個順序:NO 0000,DIFU 1000,NO 1000,NO 1001,NC 1001,NC 1000,OUT 1001,NO 1001,OUT 500),看執行每一指令時它是“真”(True)還是“假”(False)。

Rung 2(it has 5 instructions) is the confusing part for most of us。 To make it easier lets break it into sections。 NO 1000 and NO 1001 are in parallel。 In other words they form an “or” circuit。 Call this section 1。 If 1000 OR 1001 is true then this mini section is true。 Next we have another section in parallel。 This section is NC 1001 and NC 1000。 Again these 2 are in parallel。 Call this section 2。 If NC 1001 OR NC 1000 is true then this section is true。 Finally, those 2 parallel sections (sections 1 and 2) are in series with each other。 This means that if section 1 AND section 2 are BOTH true then the rung is true and output 1001

must

be true。

Rung 2(它有5個指令)對我們大多數人來說是令人困惑的部分。為了使它更簡單,我們把它拆分成幾個部分:常開觸點1000和常開觸點1001是並行的,換句話說,它們形成一個“或”電路,我們將此部分稱為Section 1,如果常開觸點1000或常開觸點1001其中一個為“真”(True),那麼這個Section 1部分就為“真”(True);接下來我們來看另一個平行的部分,這個部分是常閉觸點1001和常閉觸點1000,這兩個也是平行的,我們把這部分稱為Section 2部分,如果常閉觸點1001或常閉觸點1000其中一個為“真”(True),那麼這個Section 2部分就為“真”(True)。最後,這兩個並行部分(Section 1和Section 2)彼此串聯,這就意味著,如果Section 1和Section 2兩個部分都為“真”(True),那麼Rung 2就為“真”(True),輸出1001也必須為“真”(True)。

Now its much easier to understand, isn‘t it? We also just learned about OR and AND logic, commonly called parallel and series logic。

現在它理解起來更容易了吧,不是嗎?在這裡我們還順便學了“或”(OR)和“與”(AND)邏輯,通常我們稱之為“並聯邏輯”和“串聯邏輯”。

Executing the program 1 instruction at a time makes this and any program easy to follow。 Actually a larger program that jumps around might be difficult to follow but a pencil drawing of the registers sure does help!

執行程式時一次執行一個指令使程式較容易跟蹤。實際上,一個更大的程式要這樣跳來跳去的跟蹤是很困難的,但一個圖形化暫存器檢視肯定有幫助的吧!