text:
Talk:Programmable logic controller

Pneumatic and mechanical PLC's
A few years back, when I attended school, I learned about PLC's. I was shown three industrial PLC’s: one electronic (as on the wiki), one pneumatic and one mechanical. All three had the same functionality and could handle both digital and analogue I/O signals (by voltage, pressure and force). They are terribly obsolete today, but they are in my opinion very interesting and worth mentioning. Unfortunally I know very little about the pneumatic and mechanical PLC’s, perhaps someone does and whishes to add it? —Preceding unsigned comment added by 87.208.51.83 (talk) 22:21, 15 February 2011 (UTC)

Programming PLC
There is some info missing: PLC can be programmed not only in ladder languages or C, but there is a galore of possibilities:  ladder logic (mentioned), structural languages - mostly C (mentioned), low-level languages- assembler, basic, block languages, like FBD, PD, FUP..., sequential function charts.  However, I don't feel wise enough to write more :D

There seems to be quite a few inaccuacies with this article. For one, complex programs need not always be done by a ELECTRICAL Engineer (It states Industrial Engineer). There are many highly skilled PLC programmers who are not Electrical Engineers. ProdigalSon

Also the IEC-1138 standard is not relevant to the topic, the actual one is IEC-61131-3; but there is no "structured C" there at all.

History
There seems to be some confusion about the history of the PLC. The present article seems to indicate that GM was the driving force behind the development of the PLC. However, in this article - http://www.barn.org/FILES/historyofplc.html, Dick Morley, its inventor, seemed to have had in mind the machine tool industry when he first envisioned it. Can anyone clarify this issue? Which came first - GM's proposal for a PLC or the PLC itself that neatly fit into GM's needs?

Also: The term PC for 'Programmable Controller' was used until ~1981 with the introduction of the IBM PC. 'PC' then became 'PLC' to differentiate from the ubiquitous Personal Computer...

Also: the article says; "PLC and Programmable Logic Controller are registered trademarks of the Allen-Bradley Company". How can this be? 193.202.109.254 14:38, 25 October 2007 (UTC)
 * The article no longer claims this, which I think is a serious omission, but I'll leave it to AB to police their IP. I don't know about "Programmable Logic Controller" but "PLC" is clearly labeled as an AB trademark in all their literature.  I took care to avoid using that term in my own software ladder logic implementation, back in the 80's.  Learjeff (talk) 20:06, 25 June 2014 (UTC)

 * Also, the article claims automobile production lines used drum sequencers (?) that sounds like bull shit to me.

 * No, it's true. However drum sequencer in this context means a thing like a cam timer with a rotating drum, not an 808 or a 303. Andy Dingley (talk) 07:39, 9 July 2010 (UTC)

AB has a patent on the "Programmable Logic Controller", abbreviated PLC. http://www.plcdev.com/allen_bradley_plc_patent_3942158_by_dummermuth

 * Of course, it expired long ago, though they probably have plenty of patents on subsequent innovations. Learjeff (talk) 20:06, 25 June 2014 (UTC)

Jharris693 (talk) 15:21, 11 January 2008 (UTC)

Simple and representative
We don't need to document all methodologies used for each brand of PLC. We all have our favorite system and after a while it seems like the One True Way. I programmed ZWorld controllers in C(more or less) to control gas flows. If you controlled cutting machines using GE Fanucs, everything has a slightly different feel. We don't need to document the different feels in this page. For example, I just whittled down a big mess regarding the labels we use for digital input values: On/Off, 1/0, T/F, 24VDC/0VDC. Any of these is valid. Including them all just confuses the un-initated reader. You control motors, I control valves but we don't need to list everything that is a digital output to communicate the idea of Digital Output. Same with programming languages, UIs, data storage, networking... Can we keep it simple and representative please? -- TomCerul 05:38, 21 July 2005 (UTC)

I'm chopping down the examples again. Please go easy edits which are essentially "and technology X". After a few of those, the sentence is no longer readable. TomCerul (talk) 20:23, 9 October 2009 (UTC)

Examples
Okay folks, we know PLC programming is full of millions of details regarding how things can go horribly wrong. What examples should we use? My choice has been
 * 1. DI/DO
 * 2. AI/AO
 * 3. Should we add an HMI example?
 * 4. And now I'm thinking we should add an example and section describing the level of the complexity inherent to industrial control/PLC programming. Perhaps:"Now change the controlled fluid to gasoline. Extensive safety precations must be implemented. Overfill, vapor detection, catch pan liquid detector, exhaust monitoring, controller air pressure monitoring..."

I want to make most of the article clear enough for a layman. TomCerul 15:41, 1 September 2005 (UTC)

Since PLCs are never installed without a lot of accompanying electrical interfacing, some pictures of typical electrical control cabinets would help give PLC installations some context.

In the water level controller sample program shown in the page high level and low level float switches are open (input low) when water is above them and vice versa. That means for the fill valve to be latched open both inputs should be high. But this sample program shows both input should be low for the valve to be latched. Can anyone check? — Preceding unsigned comment added by 78.100.16.35 (talk) 10:10, 12 December 2013 (UTC)

Communication Protocols
Could someone please comment on what standards for serial and or network communication exist? Thanks.
 * OK. Spalding 03:04, 15 July 2006 (UTC)

== comm methods: add USB

Newer Methods
I would like comments on newer technology if any is replacing this.

Trademark
I notice that Programmable logic controller has chosen to use asterisks to denote that PLC is a registered trademark of Allen-Bradley, and Unix has chosen to use the extended ASCII registered trademark character. I'll let you guys duke it out, but we really shouldn't have two standards.--Superluser 00:35, 19 April 2007 (UTC)

I removed the "®" based on Manual of Style (trademarks). -- Mark @ DailyNetworks  talk  02:12, 28 May 2007 (UTC)

I had noticed Siemens and other manufacturers use the term "PLC". I checked with the United States Patent and Trademark Office and searched Allen-Bradley. I did not find PLC or Programmable Logic Controller registered to Allen-Bradley. I did find PLC-2 (registration number 1103007), PLC-3 (registration number 1228339), and PLC-5 (registration number 1709845). -- Mark @ DailyNetworks  talk  02:28, 28 May 2007 (UTC)

PLC compared with other control systems
There is not much explanation on PLC capability in delivering high speed output and receiving high speed input. This will allow PLC to control AC servo motor. This link might be helpful.
 * http://yourplctrainer.com

Tatau1234 (talk) 06:28, 11 December 2008 (UTC)

microprocessors
how they operate and thier functions —Preceding unsigned comment added by 41.220.2.117 (talk) 13:30, 24 November 2007 (UTC)

arduino and family ? — Preceding unsigned comment added by 85.149.55.85 (talk) 10:04, 25 December 2019 (UTC)

Digital and analog signals example
I changed the wording of this example a bit to be more clear. Am I wrong in thinking that it should be two series float switches (a logical AND gate) rather than two parallel float switches (a logical OR gate)? Schreineradam (talk) 15:03, 13 February 2008 (UTC)

Origin of name
"PLC" from its original inception stood for "Process Local Controller" - somewhere along the line this has been changed by common usage to "Programmable Logic Controller" 81.151.17.6 (talk) 11:13, 21 August 2008 (UTC)
 * Got a reference? I've never heard of that story and the first time I got my mitts on a PLC was in 1980. Of course, credentials mean nothing on the Wikipedia. All the old Allen-Bradley literature that I had access to, called it "Programmable logic controller" and some of that went back to the mid '70s- pretty early on in the scheme of these things. As a check on my sanity, Google returns exactly 5 hits on the exact phrase "process local controller" and none of them are in an industrial automation context.  "Process control" usually meant analog loops in the old days, and PLCs weren't even usable for analog quantities for many years. --Wtshymanski (talk) 15:16, 21 August 2008 (UTC)

Suppliers
That suppliers section is somewhat of a concern. It really doesn't fit with WP:NOT (business directory) and its a magnet for everyone to create and link spam in the article namespace. User A1 (talk) 13:19, 3 November 2008 (UTC)

External Link Suggestion
Please consider adding the following website link. Reason: A comprehensive tutorial on programmable logic controller (PLC) operation and programming.
 * PLC Complete Tutorial

Thank you.--41.234.63.19 (talk) 23:17, 10 February 2009 (UTC)

 * This link has been removed by multiple editors multiple times. If you disagree with the removal of the link, there are processes you can voluntairily follow to obtain a third opinion User A1 (talk) 10:11, 11 February 2009 (UTC)

After reading the external article, I have the impression that it is an advertisement for a particular brand of PLC (Omron) and not simply a generic tutorial on the operation of PLCs. The article does do a good job of explaining PLC operation and programming language, but it does only concentrate on one brand. I vote for excluding the link on the basis that it is sales pitch. —Preceding unsigned comment added by Athabaska-Clearwater (talk • contribs) 16:02, 11 February 2009 (UTC)

The page that would be linked in this case consists of two frames. The left one shows Google ads and the right one shows a page from a different domain (a chapter from a book, not even the table of contents). Thus it does seem pointless to link to the page that simply adds advertisements to another one, when we can link to the one without those advertisements instead (External links includes "5. [...] or to web pages with objectionable amounts of advertising. [...]").

That leaves another question: should the page with the book (Nebojsa Matic "Introduction to PLC controllers") - http://www.mikroe.com/en/books/plcbook/plcbook.htm - be linked? As noted by Athabaska-Clearwater, it might still have some disadvantages... However, it might be a reliable source (there seems to be a conference paper - Peter H.M. Jacobs, Alexander Verbraeck, William Rengelink "Emulation with DSOL", "Winter Simulation conference 2005" - that cites what appears to be the same book, although the URL seems to have changed) - probably users watching Reliable sources/Noticeboard can be consulted with to decide if it's really the case. And if it really is, we might wish to use this book as a source, as it looks like this article does not cite any sources at the moment... --Martynas Patasius (talk) 18:00, 11 February 2009 (UTC)

 * I agree with the comments above by both Martynas Patasius and Athabaska-Clearwater, but at this time will not (due to real-life constraints) be adding the book as a reference in the article. To be clear, I have no objections to the direct use of the book at all, if it can be linked as a PDF. User A1 (talk) 01:05, 12 February 2009 (UTC)

Dubious
It is stated on Functionality that a PC can replace a PLC "in some applications". This statement may imply that there are no (severe) trade-offs when doing so, hence I tagged it dubious. 201.37.106.228 (talk) 14:24, 15 March 2009 (UTC)

I buy it. PC's would do a great job controlling Christmas lights. TomCerul (talk) 20:20, 9 October 2009 (UTC)

 * Beckhoff Automation argues that their PC-based TwinCAT product can replace PLCs in quite a wide range of applications. — Wdfarmer (talk) 23:49, 28 February 2010 (UTC)

Page protection
Page protection has once again been applied to deal with excessive adspam by User:Cartiman and his various sockpuppets. Apologies for the inconvenience. Euryalus (talk) 10:48, 26 March 2009 (UTC)

Suppliers section
Hello, I'm kinda getting tired of continually sifting the wheat from the chaff when users are making edits to the "Suppliers" section. This section is a magnet for WP:COI edits, and doesn't really do much for increasing the reader's understanding of PLCs. I propose removing this section entirely, this article gets enough COI vandalism as is, and anything we can do to reduce the frequency of this would be nice. However I note that last time I removed it (without discussion) it was reinstated in a short time, hence this discussion. Can we have a discussion of the merits of this section, and whether it should be removed? User A1 (talk) 07:12, 9 May 2009 (UTC)

Hi as a person not familiar with PLC's one of the things I was looking for was the suppliers of the PLC units. So if this was removed it wouldn't be helpful for those like me looking for this sort of information. Looks like the problem is the vandalism not the section. ZedZzizz (talk) 03:33, 14 May 2009 (UTC)
 * Wikipedia is NOT. This is the exact use that it should *not* be used for. If you want to find suppliers you should use a business directory User A1 (talk) 05:23, 14 May 2009 (UTC)
 * Ive pulled it. This discussion has been up for two weeks, which I feel is sufficient to have recieved any feedback. I cannot see any reason that is inline with WP policy to keep this section. User A1 (talk) 02:05, 23 May 2009 (UTC)

I don't understand the diagram in Programmable logic controller
Why are there two "Fill Valves"? I thought only the high level and low level switches are meant to be the inputs, so why is there a "Fill Valve" input? Also, isn't the high level switch meant to be a cutoff?-- Alasdair 12:57, 25 September 2009 (UTC)

 * That isn't an input, it is the output being used as a contact. The purpose is to "latch" the "Fill Valve" output on. Without this, the output would turn off (or worse - jitter) when the water level raises above the low level switch. Krushia (talk) 14:26, 26 September 2009 (UTC)

 * Well now that you made me take a belated look at it, the second to the last paragraph in that example section is wrong with respect to the example.  The hysteresis comes from the float switch configuration, not the PLC.  And a hysteresis response to a discrete input is not applicable/possible.  North8000 (talk) 00:22, 1 May 2012 (UTC)

 * I fixed it. The fix now makes it a bit off topic, but looks close enough. North8000 (talk) 02:26, 1 May 2012 (UTC)

 * Took a closer look and did additional work elsewhere on the example. North8000 (talk) 02:58, 1 May 2012 (UTC)

 * It's been a long time since I've worked on this article and I see that someone has broken the description of the inverse logic inputs. The article before was correct. The way the rung works is if both inputs are off then the 'normally closed' contacts "in the rung" will be closed and the output will turn on. [No, that is incorrect. If the physical level switches are both closed, that will send a TRUE signal to the PLC. If you invert that with a "NC" instruction, then the result is FALSE, so your fill valve will not turn on. But if you do not invert the TRUE, but use a NO PLC instruction (which is not the same as the physical switch) to "read" the physical switches, then the fill valve will turn on and fill the tank. See this test using the LogixPro simulator http://www.plctalk.net/qanda/showthread.php?p=569570&posted=1#post569570 by Lancie01] Also the article as written seems to confuse the contacts on the switches and the contacts in the rung. I'll put in a better description and fix this when I get a chance. Since this seems to get changed every so often I'll put in some references to terms like 'normally closed' and 'normally open' and 'inverse logic'. Although I did PLC programming and system design for many years I understand the wikipedia requirement of using references to published documents.-Crunchy Numbers (talk) 02:27, 10 May 2012 (UTC)
 * It was correct both before and after the changes I made. (except for the "hysteresis" error noted above) The difference is that before my changes it was only partially and confusingly explained for a person trying to learn something from this; I fixed that. "Normally closed" and "normally open" would be confusing and ambiguous terms to use here for the float switch contacts because the equipment based meanings for those terms are the opposite of the general control scheme here because this is a fill type application. Ditto and even more so for the term "reverse logic" . Sincerely, North8000 (talk) 11:21, 10 May 2012 (UTC)

 * I think the example description and diagram do not match. The description states that the high and low level switches turn on when the level drops, but the diagram appears to turn on the fill valve only when both are both contacts return true for the off condition, ie when the floats are in their open condition and the tank is full. I have only recently started learning about plcs and ladder logic and am far from expert in it, but I think my analysis is correct. I will leave it to someone more experienced to verify and make any necessary changes — Preceding unsigned comment added by 78.152.205.202 (talk) 12:08, 21 October 2012 (UTC)
 * Not following your question / point.  Could you clarify?   In particular "true for the off condition"  Sincerely, North8000 (talk) 19:01, 21 October 2012 (UTC)
 * The float sensors (as described in the text) give a signal when the water level is below the sensor. To start pumping, the level must be below both. Andy Dingley (talk) 19:29, 21 October 2012 (UTC)
 * I propose moving the example code to ladder logic. Krushia (talk) 04:38, 22 October 2012 (UTC)
 * Ok, the fill valve is turned on when it preceded by a line of true conditions on the ladder rung. If we ignore the fill valve latch, the program will interrogate the low and high level switches, and since they are shown as [/](what I have been taught to refer to as EXAMINE FOR OFF), the program will interpret them as true if they are off(ie open) and false if they are on(ie closed). However the example as written states that the switches are closed(ie on) when the level is low, so the program will find two false conditions (since it is looking for off) and the valve will not open. This can be simply rectified by altering the notation for both Low Level and High Level on the diagram from [/] to [ ]. Hopefully this is clearer. Regards — Preceding unsigned comment added by 78.152.205.202 (talk) 22:04, 22 October 2012 (UTC)

 * Still not following, but it sounds like both the root of the problem and the freedom for the proposed solution is the ambiguity of the [/] and [] contact symbols for float switches since float switches do not have an unambiguous "normal" state. But the diagram does follow the somewhat normal convention where the lower liquid level condition is called the "normal" state.  But this application (being "pump in" rather than "pump out")  is the reverse of the normal float switch application, making the "normal" state not so "normal".   Long story short, I don't agree that there is an error, but have no objection to changing those two symbols as you propose.  North8000 (talk) 22:16, 22 October 2012 (UTC)

There is a perfectly unambiguous convention for switches; the position on the diagram is the "on the shelf", non-operated, position (ANSI Y32.2 clause 4.3). The ANSI/IEEE and IEC standards also contain conventions for switches that are normally open but held closed by the process, or reverse. --Wtshymanski (talk) 14:09, 23 October 2012 (UTC)
 * That convention would dictate showing the float switches as normally closed (as they currently are). The fact that that "normal" position is "abnormal" for this particular application I think caused some confusion for the individual who wrote, but I think that that convention is a good idea and also follows the most common practice.  North8000 (talk) 14:52, 23 October 2012 (UTC)
 * Ok, to clarify (I am the one that raised the question). My confusion, it seems to me, arises from the possibility that although the diagram appears like a fragment of ladder code, it is maybe a kind of quasi wiring diagram, hence your concern with adhering to conventions re the representation of different types of switches. As a piece of ladder code, it would not behave correctly, for the reason that I have already outlined. This confusion is understandable since we are talking about PLCs, most of which are coded using ladder logic. If it is intended to be a ladder code fragment it needs the change I suggested, if not it needs to be clearer exactly what the diagram's purpose is.
 * PS: I apologise if my formatting (indents etc) is wrong, I am new to this. RegardsTrooperman94 (talk) 21:34, 23 October 2012 (UTC)
 * I think that I understand now.  It is not clear whether the float switch symbols on the diagram represent the real world devices or symbols in a software program. And if its the latter, that representation might not be correct.  North8000 (talk) 10:40, 24 October 2012 (UTC)
 * We probably need to explain that the symbols on the ladder diagram are operating on holding register bits in the PLC memory, not the actual contact status of the field device. You need to know what "power on the PLC input" means to the process - does it signify "level above the float switch/button held down/limit switch operated" or the reverse? Since this is a fruitful source of bugs in new PLC programs, the point probably wants some expansion. --Wtshymanski (talk) 13:44, 24 October 2012 (UTC)

In the water level controller sample program shown in the page high level and low level float switches are open (input low) when water is above them and vice versa. That means for the fill valve to be latched open both inputs should be high. But this sample program shows both input should be low for the valve to be latched. Can anyone check? — Preceding unsigned comment added by 78.100.32.30 (talk) 10:38, 12 December 2013 (UTC)

 * We are using some terms and symbols that are inherently ambiguous or confusing in the case at hand.   Namely "normally"  and the meanings of representations in the PLC of "normally" open and "normally" closed contacts.   We are  also using an example (pump to full) which is the reverse of the more common pump application which is "pump to empty".  IMHO your post was correct until it said "But this sample program shows both input should be low for the valve to be latched." which is not the case.  We should probably change the example to one where the real word devices have a clear and intuitive "normal" state (e.g devices that spring to that position, are in that position when the system in the application is at rest), and where they are and are represented as normally open contacts.  I think that that would solve the eternal confusion with this example.   North8000  (talk) 12:19, 12 December 2013 (UTC)

I dont really see PLC caring about whether a contact is physically NO or NC, or if it is pump to full or pump to empty, or spring to position or anything like that. In the description section it is said "In ladder diagram, the contact symbols represent the state of bits in processor memory, which corresponds to the state of physical inputs to the system. If a discrete input is energized, the memory bit is a 1, and a "normally open" contact controlled by that bit will pass a logic "true" signal on to the next element of the ladder." So if the input contacts are physically closed the corresponding input address is high, and have a 1 bit in the internal memory, which happens when the tank is empty as per the description. So that should have been the condition for latching the valve, right? — Preceding unsigned comment added by 176.203.50.177 (talk) 15:06, 12 December 2013 (UTC)

 * My thoughts were about how to make a simpler/ clearer example, not about this example. The best place to start the conversation in the areas that you are discussing is the physical system without PLC terminology and contact terminology.  There are two switches at different heights. (the names of the switches are "low level" and "high level") the contact on each is closed when the level is below the level setpoint of the switch. And of course, the physical reality is that when the low one is closed, the high one is "already" closed, and when the high one is open, the low one is "already" open). And let's start  the description when it at its highest state when both switches are open.  Then:
 * The liquid starts getting used and the level starts dropping
 * The liquid drops below the level of the "high" level switch. The switch closes, but nothing else happens
 * The liquid continues to drop
 * The liquid drops to the setpoint of the "low level" switch
 * The low level switch closes
 * The control system turns on the pump, and closes a control system contact which is in parallel with the low level switch. This is called "latching" because it goes into a state where the low level switch closure is no longer needed to keep the pump on, i.e. it is unable to "break" the circuit because it has been "bypassed" by the control system contact which is in paralell with it.
 * The pump raises the level of the liquid.
 * The "low level" switch opens, but such has no effect and so the pump continues to raise the level of the liquid
 * The level rises through the setpoint of the "high level switch". This "breaks" the circuit and shuts the pump off and the control system also opens the latching contact.
 * So there's a description of the physical reality of the system and what the control system needs to do. Next is the more confusing part, which is how to represent the physical and software implementation using a PLC. Sincerely,  North8000  (talk) 15:30, 12 December 2013 (UTC)

I guess you are putting across the actual physical logic for a layman (when the water level is low both switches are "Normally Closed" which condition should energize the fill valve) with no introduction to the ladder logic programming. In that case I guess this is a good idea, but still I think it is better to clarify this in the article page not to confuse those who know a little ladder logic programming. — Preceding unsigned comment added by 176.203.50.177 (talk) 17:09, 12 December 2013 (UTC)
 * I agree with you 100%.  My post above was only to describe the absolutely unambiguous part as only a piece of the answer.   North8000  (talk) 18:12, 12 December 2013 (UTC)

mounting standard
Do PLCs clip onto a DIN rail, or do they use some other mounting standard? --68.0.124.33 (talk) 03:30, 26 October 2010 (UTC)
 * Yes. --Wtshymanski (talk)

Somebody keeps taking out the history of PLC's and substituting the History of Modicon
Please stop doing this. North8000 (talk) 15:52, 18 July 2011 (UTC)

PLC vs. What you can use a PLC at
This article is focused on PLC usage rather than explaining what a PLC really is, or moreover, what a PLC is made of. — Preceding unsigned comment added by 86.125.236.87 (talk) 21:49, 30 April 2012 (UTC)

 * It's certainly not perfect, but I think it is focused on providing the common useful information. A PLC is made of nearly all of the parts used to build any type of electronic equipment (resistors, capacitors, printed circuit boards, integrated circuits, transistors, diodes etc.) plus sometimes a few that are electromechanical equipment. IMHO the former is not very unique/informative regarding PLC's.   North8000 (talk) 03:03, 1 May 2012 (UTC)

PLC vs PAC?
In the See Also section there is a link called "". This is confusing for two reasons: 1. Nowhere else in the article the acronym PAC is mentioned, let alone explained or spelled out. 2. The chart itself contradicts the article. For example it claims that programming is only possible via ladder logic while the article gives four more possibilities (under http://en.wikipedia.org/wiki/Programmable_logic_controller#Programming_2 ).

82.198.218.209 (talk) 14:34, 11 June 2014 (UTC)

3.8 Simulation
There seem to be some parts in this paragraph missing. The sentence "...incorrectly it can result in lost ols such as..." just doesn't make any sense. Perhaps some inadvertently deleted or copied parts? 192.35.17.13 (talk) 14:01, 2 April 2015 (UTC)

Good catch. Fixed sentence as per earlier version.Goatboy22 (talk) 01:08, 3 April 2015 (UTC)

Hard real time only ?
I'm afraid that there is a problem with the phrase
 * A PLC is an example of a "hard" real-time system since output results must be produced in response to input conditions within a limited time, otherwise unintended operation will result.

As far as i understand, a PLC could be used in a soft real time system, meaning a system where not meeting a deadline won't cause a total system failure, only a (possible) degrading of the system service quality.

Of course, due to its cost, a PLC is more useful in a hard real time system, but as far as i can see, there's nothing that would prohibit their use in systems with other real time requirements.

Thanks, --Hgfernan (talk) 20:55, 19 March 2016 (UTC)

Proposed new section: PLC Viruses
Given the fairly recent emergence of Stuxnet, which infected PLCs, I think that there should be an entire new section that discusses specific viruses and the vulnerabilities they exploited. The only thing that was on the page now was a brief 3-line mention of security, which couldn't cover all the issues that have arisen. Thanks, Gluons12 (talk) 19:03, 7 May 2016 (UTC)

Large amount of April 11th, 2017 additions
I think that there are numerous problems with the April 11th additions but I was hesitant to revert en-masse. It noted a problem with a particular vendor, and the complaint looks implausible. The descriptions of timers look confusing and missing important pieces at best, and in conflict with standard timers at worst, and it appears that the terminology may be specific to one vendor. The counter section seems to base itself on vendor-specific terminology. In the up/down counter area it conflicts with the common "up/down" (bi-directional) counter-specialized input on PLC's which utilizes a quadrature input, not separate "up" and "down" inputs. There is only once source used, off line and lacking in specifics with no info with respect to publishing, except possibly naming today's date as a publishing date.  North8000  (talk) 18:43, 11 April 2017 (UTC)

Invented When? By Whom?
So, this was invented in 1968, then sent back in time for the IBM 1800 to come after in 1964?

Honestly, this article has a huge bias problem toward only certain application. I guess controlling a nuclear power plant doesn't count. — Preceding unsigned comment added by 73.222.236.165 (talk) 07:14, 13 February 2018 (UTC)

 * With respect to this question, PLC is basically a term used for combining the attributes described in the first paragraph. Because of that I think it's fuzzy / eye-of-the-beholder on when the first one was or who invented it.North8000 (talk) 12:11, 13 February 2018 (UTC)

 * PLCs are not the same thing as process control - they have merged in recent years, but not until the 1990s. The IBM 1800 was not a PLC. Andy Dingley (talk) 12:22, 13 February 2018 (UTC)

Rockwell and Allen-Bradley
reverted this change where I try to clarify what "Rockwell (Allen-Bradley)" means. The edit comment on the revert was "Confusing and possibly misleading. They Allen Bradley became prominent and leading in PLC's when it was not Rockwell." I have reverted that revert. What the ref says about Rockwell is, "Also involved was Odo Struger of Allen-Bradley, now Rockwell Automation. Rockwell became the PLC leader in the US through good marketing and development of strong distribution channels...". I think my version is more true to the ref. The original version has the problematic "Rockwell (Allen-Bradley)" phrase and also I think it is further from what North8000 claims happened than my version. I'm sure what I put up there can be improved further but I think my contribution was an improvement on what we had originally. ~Kvng (talk) 00:56, 11 December 2018 (UTC)
 * The reference made a misleading statement.   AB had moved into the PLC lead prior to being Rockwell. But Wikipedia goes by sources, not wiki editor's knowledge.   So I agree that the misleading statement can stay in.  No biggee, and thanks for your work. North8000 (talk) 11:41, 11 December 2018 (UTC)
 * Misleading is a generous assessment. I'm not sure this source is reliable. ~Kvng (talk) 02:34, 12 December 2018 (UTC)
 * Regarding actual reliability (not wp:rs) I think that the source is overall pretty reliable on the topic but that that particular sentence was misleading or wrong. <b style="color: #0000cc;">North8000</b> (talk) 13:22, 12 December 2018 (UTC)

Proposed merge with I/O module
Newly created page that has some useful information on PLCs. The contents of the article do not match with its title, so the info should be merged into the PLC article and the new page redirected. Bensci54 (talk) 17:31, 23 January 2019 (UTC)
 * Oppose I/O modules have a more general relation to microcontrollers. not just PLCs. Andy Dingley (talk) 17:38, 23 January 2019 (UTC)
 * I left my comments at the other article. <b style="color: #0000cc;">North8000</b> (talk) 18:31, 23 January 2019 (UTC)
 * There's nothing worth merging there. What is at I/O module is only about the PLCish kind and seems redundant with what we describe here. Hypothetically there are usages other than PLCs, but the concept doesn't seem to be strong enough to support a free-standing article instead of a paragaph in the arious places I?O modules are used. It's a generic concept, breaking systems down into modules...I/O is just one possible way to break down functions of a system. --Wtshymanski (talk) 19:51, 23 January 2019 (UTC)
 * I agree. But I guess "merge" could be a diplomatic and easy way to say "delete".  <b style="color: #0000cc;">North8000</b> (talk) 22:44, 23 January 2019 (UTC)

has completed this by redirecting I/O module to Programmable logic controller, "nothing referenced to merge, topic already discussed at target" ~Kvng (talk) 13:02, 10 June 2019 (UTC)
 * Support - True that I/O module is a term that can be applied elsewhere, however, all the current content in I/O module applies to Programmable logic controller and there is no need for a separate article on this topic. If we get more generic material on the I/O module topic in the future, the redirect left by the merge can be turned into a WP:DAB page or otherwise expanded. ~Kvng (talk) 16:18, 26 January 2019 (UTC)
 * support Per my discussion here and there. <b style="color: #0000cc;">North8000</b> (talk) 18:56, 26 January 2019 (UTC)

Programmable automation controller
added these two external links. I have moved them here for now. The article doesn't (yet) cover PACs. This doesn't appear to be covered elsewhere in the encyclopedia. Maybe someone wants to add coverage and use these as references. ~Kvng (talk) 13:21, 30 August 2019 (UTC)
 * What’s the Difference Between a PLC and PAC?
 * PLC
 * I'm skeptical. It appears that is it a general term with many uses.   The two links were to one specific company which purports to say it is a distinct class based on programming language. <b style="color: #0000cc;">North8000</b> (talk) 18:55, 30 August 2019 (UTC)
 * It's been a while since this discussion, but I'll include few points of my own. From what I understand the PAC term hasn't really caught on with PLC vendors, and to me it seems that many devices currently on market sold as PLCs do include some/many features of PACs. So I think at this point it's very difficult to differentiate the two. Term was apparently defined by an advisory group in 2001. Perhaps back then this difference was much more relevant, but became irrelevant before becoming popular. -- DistilledBacon (talk) 16:06, 3 December 2019 (UTC)

Three new top level tags put on today
I don't think that any such top level tags are warranted. A short/medium length article with 23 references, written in wording that is pretty friendly to non-experts. As far as "OR" the tagger should which part they believe is O/R. <b style="color: #0000cc;">North8000</b> (talk) 19:59, 11 February 2020 (UTC)

 * I added this tags mainly as a response to the lates series of edits, but even before there were problems. About half of all statements lack any reference. At first, I just wanted to tag them inline, but there's quite many of them. I don't always question their validity, but the source is still welcome. When it comes to WP:OR, section  Programmable logic relay (PLR) comes to my mind as it seems to come from personal knowledge or opinion.  When it comes to being too technical – it's not bad, but it uses jargon in places that I feel it can be avoided. I also dislike this bit: Examples of this would be an output address could be called “O”, “Y”, or “Q”. Some models of PLC have addressing in tables to organize data (N:7, DB12.DBW0), whereas other models permit you to use free text entry in a “Tag” format (ThisTagHere). Logic and process flow would operate the same between the differing models should the correct equivalent programming is entered. — K4rolB (talk) 21:28, 11 February 2020 (UTC)
 * I think that those are all excellent and valid points. Except "more references" is pablum that can be said about 99% of articles, and this one looks mid-range regarding that.   But I still don't think that they rise to the level of top level tags.   I'd say lets improve it in some of those areas and then remove the top level tags. <b style="color: #0000cc;">North8000</b> (talk) 14:37, 12 February 2020 (UTC)
 * Well, we could probably argue for a long time about how serious the problems really are, but you're right. I didn't want to sound conceited. If I had time on my hands to just fix it, I would have done it. But now, with problems stated and discussion started, I will try to tackle some. — K4rolB (talk) 20:30, 12 February 2020 (UTC)
 * Cool.  I fixed a couple of things to start. <b style="color: #0000cc;">North8000</b> (talk) 14:05, 13 February 2020 (UTC)

 * WP:TAGBOMBING is not particularly productive. Thanks for highlighting specific areas needing improvement here on the talk page. I often review prior talk page comments (even very old ones) when making improvements. ~Kvng (talk) 14:40, 16 February 2020 (UTC)

Article copyedit
I decided to work on some problems I saw in the article and it quickly became quite a big copyedit. I didn't want to just slap it on top of the existing article and it would be hard to add it in parts if it has to still make sense so I decided to create a workpage for it and ask for your opinions. It's very much work-in-progress but these are the main changes and logic behind them: All in all, lots of text was moved around, merged and divided. Again, I'm waiting for some constructive criticism before I commit to changing the actual article. — K4rolB (talk) 18:13, 26 February 2020 (UTC)
 * Overview was divided between lead section and invention and early development, because it fits there, and from [WP:MOS] standpoint, lead section should be an overview.
 * removed everything that wasn't invention or development from invention and early development. Future is there just for a moment, until I know what to do with info under it. Ignore it. I've read and improved all the references in the mentioned section and some unsourced info has found its reference! Also, I see that some part of history is missing and it should be completed, because at this point it kind of contradicts itself (Dick Morley created PLC in 1968, and Odo Josef Struger worked on it in 1958-60?)
 * At least until I got a better understanding of it, I decided to put two subsections there: Modicon and Allen-Bradley as two independent paths of development. I think that until there is a Modicon article, that part may contain additional info about the company, but it's not the case with A-B.
 * There were, I think, 4 places where IEC 61131-3 was explained. I'm in process of consolidating all of it under Programming.
 * PLC topics was divided between existing sections, or new were created. I'm not satisfied with it yet.
 * PLC compared with other control systems got subsections to make it more readable.

 * Kudos for the work.  From my standpoint, the big question is what, if anything, is being removed from the article.  Few have the time to do a compare-and-contrast wit a totally rewritten article or to review what happened when large changes are made in one day.  Suggest modifying the article incrementally spread over days.  <b style="color: #0000cc;">North8000</b> (talk) 18:59, 26 February 2020 (UTC)

 * I understand that, that's why I made a changelog. I will try to put rework in batches when it's more ready. Right now I just wanted to show the overall direction. I try not to remove anything at this point. I tag things I have problem with. There are some things I would like to see removed as they might be outside of scope of the article or wikipedia. I will keep them now and discuss them later. – K4rolB (talk) 21:00, 26 February 2020 (UTC)

 * I agree with that making these changes incrementally makes it easier for other editors to review and discuss. There are other advantages to working on the live article. Nevertheless, I have compared your new version to the existing article and I didn't see any obvious objectionable changes. I did not spend enough time with it to be convinced that the changes are a net improvement but the changes you describe above satisfy that and I will WP:AGF. ~Kvng (talk) 15:10, 1 March 2020 (UTC)

Rollbacks
In case anyone was wondering why there are two rollbacks in the history, I had accidentally hit the Rollback button while viewing on a mobile device. KD5TVI (talk) 00:35, 23 September 2020 (UTC)

IMO we should delete or pare the list of "PLC manufacturers"
IMO the list should be reduced or deleted. It has gotten bloated with companies that are not really in that business. If it were limited to the top 5 or top 10 (and the section already has sources for that) that might be useful. But this list isn't and Wikipedia is not a business directory. <b style="color: #0000cc;">North8000</b> (talk) 19:48, 6 January 2021 (UTC)
 * I agree and I'm going to make proper changes — K4rolB (talk) 21:38, 7 January 2021 (UTC)
 * Cool. <b style="color: #0000cc;">North8000</b> (talk) 22:21, 7 January 2021 (UTC)

title: Talk:Programmable logic controller


text:
How Green Was My Valley

How Green Was My Valley is a 1939 novel by Richard Llewellyn, narrated by Huw Morgan, the main character, about his Welsh family and the mining community in which they live. The author had claimed that he based the book on his own experiences, but this was found to be untrue after his death; Llewellyn was English-born and spent little time in Wales, though he was of Welsh descent. Llewellyn gathered material for the novel from conversations with local mining families in the village of Gilfach Goch, in southeast Wales.

In the United States, Llewellyn won the National Book Award for favourite novel of 1940, voted by members of the American Booksellers Association.

Plot summary
The novel is set in South Wales during the reigns of Queen Victoria and King Edward VII. It tells the story of the Morgans, a respectable mining family of the South Wales Valleys, through the eyes of the youngest son, Huw Morgan.

Huw's academic ability sets him apart from his elder brothers and enables him to consider a future away from the dangerous coal mines. He loses his opportunity because of fighting with a schoolmaster who punishes children for speaking Welsh. His five brothers and his father are miners. After his eldest brother, Ivor, is killed in a mining accident, Huw moves in with his sister-in-law, Bronwen, with whom he has always been in love.

One of Huw's three sisters, Angharad, marries Iestyn Evans, the wealthy mine owner's son – whom she does not love – and the marriage is an unhappy one. She never overcomes her romantic relationship with Merddyn Gruffydd, a local minister, who had declined to marry her because of his poverty.

Huw's father is later killed in a mine disaster. After everyone Huw has known either dies or moves away, and the village is reduced to a contaminated shell, and the house is being destroyed by a slag heap, he too decides to leave, and tells the story of his life just before going away.

Characters
The Older Morgans:
 * Gwilym Morgan, Huw's father: wants things done properly, with attention to manners, and a minding of one's own business
 * Beth Morgan, Huw's mother: devoted to her children and husband, uneducated, struggles with her temper
 * Bronwen Morgan, Huw's sister-in-law: a gentle, insightful woman to whom Huw goes when he is troubled or wants to learn information that the adults hold from him. She is the mother of young boys, Gareth and Taliesin.
 * Ivor Morgan, Huw's eldest brother, marries Bronwen, sides with the father against the strike, defends sister Angharad against Iestyn Evans' initial familiarity.

The Middle Brothers: These are Huw's young adult brothers. Ianto goes to London to find work early in the book, but returns unhappily; Owen and Gwilym do the same later.

 * Ianto Morgan, Huw's second-oldest brother
 * Davy Morgan, a leader in the miners' union, marries Ethelwyn Rowlands
 * Owen Morgan, an inventor, often found in the shed behind the house working on an engine
 * Gwilym Morgan (junior), married to Marged

The Younger Morgans:
 * Angharad Morgan, Huw's sister, marries Iestyn Evans
 * Ceridwen Morgan, Huw's sister, marries Blethyn Llywarch
 * Huw Morgan, the Narrator
 * Olwen Morgan, Huw's youngest sister

Other characters:
 * Merddyn Gruffydd, the preacher who is loved by Angharad, helps Huw recover from his illness, and is supportive of the Morgans.
 * Iestyn Evans, an arrogant dandy, son of the mine owner, who courts Angharad. According to Young Gwilym, "a purse-proud ninny"
 * Master Elijah Jonas-Sessions, a harsh teacher who makes Huw's life miserable. He is pro-English, and ashamed of his Welsh heritage
 * Ceinwen Phillips, a manipulative young girl in love with Huw
 * Abishai Elias the Shop, enemy of the Morgan family
 * Dai Bando, Huw's boxing teacher
 * Cyfartha Lewis, Dai's close friend

First printing
The first edition was published in 1939 by Michael Joseph Ltd, London. The first printing included a limited edition run of 200, numbered and signed by Richard Llewellyn. The original print run also included a glossary covering Welsh words and terms at the end of the book.

Sequels
The author continued the story of Huw Morgan's life in three sequels:
 * Up, into the Singing Mountain (1960) – Huw emigrates to the Welsh colony in Patagonia, Argentina
 * Down Where the Moon is Small (1966) – Huw's life in Argentina
 * Green, Green My Valley Now (1975) – Huw returns to Wales

Adaptations
The 1941 Hollywood film adaptation, which was highly successful, had a cast that included Walter Pidgeon, Maureen O'Hara, Anna Lee, Roddy McDowall (as Huw), Donald Crisp, and Barry Fitzgerald. None of the leading players was Welsh (though Welsh actor Rhys Williams made his screen debut in the film in a minor role). Directed by John Ford, How Green Was My Valley was selected for preservation in the United States National Film Registry. How Green Was My Valley is available on DVD from 20th Century Fox as part of their 20th Century Fox Studio Classics collection.

The book has twice been adapted by the BBC for television, in 1960 and 1975. The 1960 adaptation featured Eynon Evans, Rachel Thomas and Glyn Houston. The 1975 production, scripted by Elaine Morgan, starred Stanley Baker, (Dame) Siân Phillips, and Nerys Hughes.

The novel was adapted as a Broadway musical, called A Time for Singing, which opened at the Broadway Theatre, New York, on 21 May 1966. The music was by John Morris; book and lyrics were by Gerald Freedman and John Morris. The production was directed by Mr. Freedman, and it starred Ivor Emmanuel, Tessie O'Shea, Shani Wallis, and Laurence Naismith.

A stage version, adapted by Shaun McKenna was performed at the Theatre Royal in Northampton in 1990. It marked the stage debut of Aled Jones as the teenage Huw. It was directed by Michael Napier Brown and designed by Ray Lett.

In 2017, the book was also adapted as a short film, parts of which are shown in the music video for the song Pleader by the band alt-J.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

title: How Green Was My Valley


text:
Shor's algorithm

Shor's algorithm is a quantum algorithm for finding the prime factors of an integer. It was developed in 1994 by the American mathematician Peter Shor. It is one of the few known quantum algorithms with compelling potential applications and strong evidence of superpolynomial speedup compared to best known classical (non-quantum) algorithms. On the other hand, factoring numbers of practical significance requires far more qubits than available in the near future. Another concern is that noise in quantum circuits may undermine results, requiring additional qubits for quantum error correction.

Shor proposed multiple similar algorithms for solving the factoring problem, the discrete logarithm problem, and the period-finding problem. "Shor's algorithm" usually refers to the factoring algorithm, but may refer to any of the three algorithms. The discrete logarithm algorithm and the factoring algorithm are instances of the period-finding algorithm, and all three are instances of the hidden subgroup problem.

On a quantum computer, to factor an integer $$ N $$, Shor's algorithm runs in polynomial time, meaning the time taken is polynomial in $$ \log N $$, where $$N$$ is the size of the integer given as input. Specifically, it takes quantum gates of order $$ O \! \left((\log N)^{2} (\log \log N) (\log \log \log N) \right) $$ using fast multiplication, or even $$ O \! \left((\log N)^{2} (\log \log N) \right) $$ utilizing the asymptotically fastest multiplication algorithm currently known due to Harvey and Van Der Hoven, thus demonstrating that the integer factorization problem can be efficiently solved on a quantum computer and is consequently in the complexity class BQP. This is significantly faster than the most efficient known classical factoring algorithm, the general number field sieve, which works in sub-exponential time: $$ O \! \left(e^{1.9 (\log N)^{1/3} (\log \log N)^{2/3}} \right) $$.

Feasibility and impact
If a quantum computer with a sufficient number of qubits could operate without succumbing to quantum noise and other quantum-decoherence phenomena, then Shor's algorithm could be used to break public-key cryptography schemes, such as

 * The RSA scheme
 * The Finite Field Diffie-Hellman key exchange
 * The Elliptic Curve Diffie-Hellman key exchange

RSA is based on the assumption that factoring large integers is computationally intractable. As far as is known, this assumption is valid for classical (non-quantum) computers; no classical algorithm is known that can factor integers in polynomial time. However, Shor's algorithm shows that factoring integers is efficient on an ideal quantum computer, so it may be feasible to defeat RSA by constructing a large quantum computer. It was also a powerful motivator for the design and construction of quantum computers, and for the study of new quantum-computer algorithms. It has also facilitated research on new cryptosystems that are secure from quantum computers, collectively called post-quantum cryptography.

Physical implementation
Given the high error rates of contemporary quantum computers and too few qubits to use quantum error correction, laboratory demonstrations obtain correct results only in a fraction of attempts.

In 2001, Shor's algorithm was demonstrated by a group at IBM, who factored $$ 15 $$ into $$ 3 \times 5 $$, using an NMR implementation of a quantum computer with seven qubits. After IBM's implementation, two independent groups implemented Shor's algorithm using photonic qubits, emphasizing that multi-qubit entanglement was observed when running the Shor's algorithm circuits. In 2012, the factorization of $$ 15 $$ was performed with solid-state qubits. Later, in 2012, the factorization of $$ 21 $$ was achieved. In 2016, the factorization of $$ 15 $$ was performed again using trapped-ion qubits with a recycling technique. In 2019, an attempt was made to factor the number $$ 35 $$ using Shor's algorithm on an IBM Q System One, but the algorithm failed because of accumulating errors. However, all these demonstrations have compiled the algorithm by making use of prior knowledge of the answer, and some have even oversimplified the algorithm in a way that makes it equivalent to coin flipping. Furthermore, attempts using quantum computers with other algorithms have been made. However, these algorithms are similar to classical brute-force checking of factors, so unlike Shor's algorithm, they are not expected to ever perform better than classical factoring algorithms.

Theoretical analyses of Shor's algorithm assume a quantum computer free of noise and errors. However, near-term practical implementations will have to deal with such undesired phenomena (when more qubits are available, Quantum error correction can help). In 2023, Jin-Yi Cai showed that in the presence of noise, Shor's algorithm fails asymptotically almost surely for large semiprimes that are products of two primes in. These primes $$p$$ have the property that $$p-1$$ has a prime factor larger than $$p^{2/3}$$, and have a positive density in the set of all primes. Hence error-correction will be needed to be able to factor all numbers with Shor's algorithm.

Algorithm
The problem that we are trying to solve is: given an odd composite number $$ N $$, find its integer factors.

To achieve this, Shor's algorithm consists of two parts:

 * 1) A classical reduction of the factoring problem to the problem of order-finding. This reduction is similar to that used for other factoring algorithms, such as the quadratic sieve.
 * 2) A quantum algorithm to solve the order-finding problem.

Classical reduction
A complete factoring algorithm is possible if we're able to efficiently factor arbitrary $$ N $$ into just two integers $$ p $$ and $$ q $$ greater than 1, since if either $$ p $$ or $$ q $$ are not prime then the factoring algorithm can in turn be run on those until only primes remain.

A basic observation is that, using Euclid's algorithm, we can always compute the GCD between two integers efficiently. In particular, this means we can check efficiently whether $$ N $$ is even, in which case 2 is trivially a factor. Let us thus assume that $$ N $$ is odd for the remainder of this discussion. Afterwards, we can use efficient classical algorithms to check if $$ N $$ is a prime power. For prime powers, efficient classical factorization algorithms exist, hence the rest of the quantum algorithm may assume that $$ N $$ is not a prime power.

If those easy cases do not produce a nontrivial factor of $$ N $$, the algorithm proceeds to handle the remaining case. We pick a random integer $$ 2 \leq a < N $$. A possible nontrivial divisor of $$ N $$ can be found by computing $$ \gcd(a, N) $$, which can be done classically and efficiently using the Euclidean algorithm. If this produces a nontrivial factor (meaning $$ \gcd(a, N) \ne 1 $$), the algorithm is finished, and the other nontrivial factor is $ \frac{N}{\gcd(a,N)} $. If a nontrivial factor was not identified, then that means that $$ N $$ and the choice of $$ a $$ are coprime, so $$a$$ is contained in the multiplicative group of integers modulo $N$, having a multiplicative inverse modulo $$N$$. Thus, $$a$$ has a multiplicative order $$ r $$ modulo $$N$$, meaning

a^{r} \equiv 1 \bmod N $$ and $$r$$ is the smallest positive integer satisfying this congruence.

The quantum subroutine finds $$r$$. It can be seen from the congruence that $$ N $$ divides $$ a^{r} - 1 $$, written $$ N \mid a^{r} - 1 $$. This can be factored using difference of squares:$$ N \mid (a^{r/2} - 1)(a^{r/2} + 1)$$ Since we have factored the expression in this way, the algorithm doesn't work for odd $$ r $$ (because $$ a^{r/2} $$ must be an integer), meaning the algorithm would have to restart with a new $$ a $$. Hereafter we can therefore assume $$ r $$ is even. It cannot be the case that $$ N \mid a^{r/2} - 1 $$, since this would imply $$ a^{r/2} \equiv 1 \bmod N $$, which would contradictorily imply that $ \frac{r}{2} $ would be the order of $$ a $$, which was already $$ r $$. At this point, it may or may not be the case that $$ N \mid a^{r/2} + 1 $$. If it is not true that $$ N \mid a^{r/2} + 1 $$, then that means we are able to find a nontrivial factor of $$ N $$. We compute$$ d = \gcd(N, a^{r/2} - 1) $$If $$ d = 1 $$, then that means $$ N \mid a^{r/2} + 1 $$ was true, and a nontrivial factor of $$ N $$ cannot be achieved from $$ a $$, and the algorithm must restart with a new $$ a $$. Otherwise, we have found a nontrivial factor of $$ N $$, with the other being $ \frac{N}{d} $, and the algorithm is finished. For this step, it is also equivalent to compute $$ \gcd(N, a^{r/2} + 1) $$; it will produce a nontrivial factor if $$ \gcd(N, a^{r/2} - 1) $$ is nontrivial, and will not if it's trivial (where $$ N \mid a^{r/2} + 1 $$).

The algorithm restated shortly follows: let $$ N $$ be odd, and not a prime power. We want to output two nontrivial factors of $$ N $$.1. Pick a random number $ 1 < a < N $.

2. Compute $ K=\gcd(a,N) $, the greatest common divisor of $ a $ and $ N $.

3. If $ K \neq 1 $, then $K$ is a nontrivial factor of $ N $, with the other factor being $\frac{N}{K}$ and we are done.

4. Otherwise, use the quantum subroutine to find the order $ r $ of $a$.

5. If $ r $ is odd, then go back to step 1.

6. Compute $g = \gcd(N, a^{r/2} + 1)$. If $g $ is nontrivial, the other factor is $\frac{N}{g}$, and we're done. Otherwise, go back to step 1.It has been shown that this will be likely to succeed after a few runs. In practice, a single call to the quantum order-finding subroutine is enough to completely factor $$N$$ with very high probability of success if one uses a more advanced reduction.

Quantum order-finding subroutine
The goal of the quantum subroutine of Shor's algorithm is, given coprime integers $$ N $$ and $$ 1< a<N $$, to find the order $ r $ of $a$ modulo $N$, which is the smallest positive integer such that $$a^r \equiv 1 \pmod N$$. To achieve this, Shor's algorithm uses a quantum circuit involving two registers. The second register uses $$ n $$ qubits, where $$ n $$ is the smallest integer such that $$ N\le 2^n $$, i.e., $$ n = \left \lceil {\log_2N} \right \rceil $$. The size of the first register determines how accurate of an approximation the circuit produces. It can be shown that using $$ 2n + 1 $$ qubits gives sufficient accuracy to find $$ r $$. The exact quantum circuit depends on the parameters $$a$$ and $$N$$, which define the problem. The following description of the algorithm uses bra–ket notation to denote quantum states, and $$\otimes$$ to denote the tensor product, rather than logical AND.

The algorithm consists of two main steps:

 * 1) Use quantum phase estimation with unitary $$U$$ representing the operation of multiplying by $$a$$ (modulo $$N$$), and input state $$|0\rangle^{\otimes 2 n + 1}\otimes|1\rangle$$ (where the second register is $$|1\rangle$$ made from $$n$$ qubits). The eigenvalues of this $$U$$ encode information about the period, and $$|1\rangle$$ can be seen to be writable as a sum of its eigenvectors. Thanks to these properties, the quantum phase estimation stage gives as output a random integer of the form $$\frac{j}{r} 2^{2n + 1}$$ for random $$j=0,1,...,r-1$$.
 * 2) Use the continued fractions algorithm to extract the period $$r$$ from the measurement outcomes obtained in the previous stage. This is a procedure to post-process (with a classical computer) the measurement data obtained from measuring the output quantum states, and retrieve the period.

The connection with quantum phase estimation was not discussed in the original formulation of Shor's algorithm, but was later proposed by Kitaev.

Quantum phase estimation
In general the quantum phase estimation algorithm, for any unitary $$U$$ and eigenstate $$|\psi\rangle$$ such that $$U|\psi\rangle=e^{2\pi i\theta} |\psi\rangle$$, sends input states $$|0\rangle|\psi\rangle$$ to output states close to $$|\phi\rangle|\psi\rangle$$, where $$\phi$$ is an integer close to $$2^{2n + 1} \theta$$. In other words, it sends each eigenstate $$|\psi_j\rangle$$ of $$U$$ to a state close to the associated eigenvalue. For the purposes of quantum order-finding, we employ this strategy using the unitary defined by the action$$U|k\rangle = \begin{cases} |ak \pmod N\rangle & 0 \le k < N, \\ |k\rangle & N \le k < 2^n.\end{cases}$$The action of $$U$$ on states $$|k\rangle$$ with $$ N \leq k < 2^n $$ is not crucial to the functioning of the algorithm, but needs to be included to ensure the overall transformation is a well-defined quantum gate. Implementing the circuit for quantum phase estimation with $$U$$ requires being able to efficiently implement the gates $$ U^{2^j} $$. This can be accomplished via modular exponentiation, which is the slowest part of the algorithm. The gate thus defined satisfies $$U^r=I$$, which immediately implies that its eigenvalues are the $$r$$-th roots of unity $$\omega_r^k=e^{2\pi ik/r} $$. Furthermore, each eigenvalue $$\omega_r^j$$ has an eigenvector of the form $|\psi_j\rangle=r^{-1/2}\sum_{k=0}^{r-1}\omega_r^{-kj}|a^k\rangle $, and these eigenvectors are such that$$\begin{align} \frac{1}{\sqrt{r}} \sum_{j = 0}^{r - 1} |\psi_j\rangle &= \frac{1}{r} \sum_{j = 0}^{r - 1} \sum_{k = 0}^{r - 1} \omega_r^{jk}|a^k\rangle \\ &= |1\rangle + \frac{1}{r} \sum_{k = 1}^{r - 1} \left(\sum_{j = 0}^{r - 1} \omega_r^{jk} \right) |a^k\rangle =|1\rangle, \end{align} $$

where the last identity follows from the geometric series formula, which implies $\sum_{j = 0}^{r - 1} \omega_r^{jk} = 0$.

Using quantum phase estimation on an input state $$|0\rangle^{\otimes 2 n + 1}|\psi_j\rangle$$ would then return the integer $$2^{2n + 1} j/r $$ with high probability. More precisely, the quantum phase estimation circuit sends $$|0\rangle^{\otimes 2 n + 1}|\psi_j\rangle$$ to $$|\phi_j\rangle|\psi_j\rangle $$ such that the resulting probability distribution $$p_k \equiv|\langle k|\phi_j\rangle|^2     $$ is peaked around $k=2^{2n + 1} j/r $, with $p_{2^{2n+1}j/r}\ge \frac{4}{\pi^2} \approx 0.4053 $. This probability can be made arbitrarily close to 1 using extra qubits.

Applying the above reasoning to the input $$|0\rangle^{\otimes 2 n + 1}|1\rangle$$, quantum phase estimation thus results in the evolution$$|0\rangle^{\otimes 2 n}|1\rangle = \frac{1}{\sqrt{r}} \sum_{j = 0}^{r - 1} |0\rangle^{\otimes 2 n} |\psi_j\rangle \to \frac{1}{\sqrt{r}} \sum_{j = 0}^{r - 1} |\phi_j\rangle|\psi_j\rangle. $$Measuring the first register, we now have a balanced probability $$1/r$$ to find each $$|\phi_j\rangle$$, each one giving an integer approximation to $$2^{2 n + 1} j/r$$, which can be divided by $$2^{2n + 1}$$ to get a decimal approximation for $$j/r$$.

Continued fraction algorithm to retrieve the period
Then, we apply the continued fractions algorithm to find integers $b$ and $c$, where $\frac{b}{c}$  gives the best fraction approximation for the approximation measured from the circuit, for $b, c < N$  and coprime $b$  and $c$. The number of qubits in the first register, $$2n + 1$$, which determines the accuracy of the approximation, guarantees that$$\frac{b}{c} = \frac{j}{r}$$given the best approximation from the superposition of $|\phi_j\rangle$ was measured (which can be made arbitrarily likely by using extra bits and truncating the output). However, while $b$ and $c$  are coprime, it may be the case that $j$  and $r$  are not coprime. Because of that, $b$ and $c$  may have lost some factors that were in $j$  and $r$. This can be remedied by rerunning the quantum order-finding subroutine an arbitrary number of times, to produce a list of fraction approximations$$\frac{b_1}{c_1}_{\textstyle ,} \; \frac{b_2}{c_2}_{\textstyle ,} \ldots \vphantom{\frac{b_1}{c_1}}_{\textstyle ,} \; \frac{b_s}{c_s}$$where $s$ is the number of times the subroutine was run. Each $c_k$ will have different factors taken out of it because the circuit will (likely) have measured multiple different possible values of $j$. To recover the actual $r$ value, we can take the least common multiple of each $c_k$ :$$\mathrm{lcm}(c_1, c_2, \ldots, c_s)$$The least common multiple will be the order $r$  of the original integer $a$  with high probability. In practice, a single run of the quantum order-finding subroutine is in general enough if more advanced post-processing is used.

Choosing the size of the first register
Phase estimation requires choosing the size of the first register to determine the accuracy of the algorithm, and for the quantum subroutine of Shor's algorithm, $$2n + 1$$ qubits is sufficient to guarantee that the optimal bitstring measured from phase estimation (meaning the $$|k\rangle$$ where $k / 2^{2n + 1}$ is the most accurate approximation of the phase from phase estimation) will allow the actual value of $$r$$ to be recovered.

Each $$|\phi_j\rangle$$ before measurement in Shor's algorithm represents a superposition of integers approximating $$2^{2 n + 1} j/r$$. Let $$|k\rangle$$ represent the most optimal integer in $$|\phi_j\rangle$$. The following theorem guarantees that the continued fractions algorithm will recover $$j/r$$ from $$k/2^{2 {n} + 1}$$:

As $$k$$ is the optimal bitstring from phase estimation, $$k/2^{2 {n} + 1}$$ is accurate to $$j/r$$ by $$2n + 1$$ bits. Thus,$$\left\vert\frac{j}{r} - \frac{k}{2^{2n + 1}}\right\vert \leq \frac{1}{2^{2 {n} + 1}} \leq \frac{1}{2N^2} \leq \frac{1}{2r^2}$$which implies that the continued fractions algorithm will recover $$j$$ and $$r$$ (or with their greatest common divisor taken out).

The bottleneck
The runtime bottleneck of Shor's algorithm is quantum modular exponentiation, which is by far slower than the quantum Fourier transform and classical pre-/post-processing. There are several approaches to constructing and optimizing circuits for modular exponentiation. The simplest and (currently) most practical approach is to mimic conventional arithmetic circuits with reversible gates, starting with ripple-carry adders. Knowing the base and the modulus of exponentiation facilitates further optimizations. Reversible circuits typically use on the order of $$n^3$$ gates for $$n$$ qubits. Alternative techniques asymptotically improve gate counts by using quantum Fourier transforms, but are not competitive with fewer than 600 qubits owing to high constants.

Period finding and discrete logarithms
Shor's algorithms for the discrete log and the order finding problems are instances of an algorithm solving the period finding problem.. All three are instances of the hidden subgroup problem.

Shor's algorithm for discrete logarithms
Given a group $$G$$ with order $$ p $$ and generator $$ g \in G $$, suppose we know that $$ x = g^{r} \in G $$, for some $$ r \in \mathbb{Z}_p $$, and we wish to compute $$ r $$, which is the discrete logarithm: $$ r = {\log_{g}}(x) $$. Consider the abelian group $$ \mathbb{Z}_{p} \times \mathbb{Z}_{p} $$, where each factor corresponds to modular addition of values. Now, consider the function

f \colon \mathbb{Z}_{p} \times \mathbb{Z}_{p} \to G \;;\; f(a,b) = g^{a} x^{- b}. $$

This gives us an abelian hidden subgroup problem, where $$ f $$ corresponds to a group homomorphism. The kernel corresponds to the multiples of $$ (r,1) $$. So, if we can find the kernel, we can find $$ r $$. A quantum algorithm for solving this problem exists. This algorithm is, like the factor-finding algorithm, due to Peter Shor and both are implemented by creating a superposition through using Hadamard gates, followed by implementing $$ f $$ as a quantum transform, followed finally by a quantum Fourier transform. Due to this, the quantum algorithm for computing the discrete logarithm is also occasionally referred to as "Shor's Algorithm."

The order-finding problem can also be viewed as a hidden subgroup problem. To see this, consider the group of integers under addition, and for a given $$ a\in\mathbb{Z}$$ such that: $$ a^{r}=1$$, the function

f \colon \mathbb{Z}\to \mathbb{Z} \;;\; f(x) = a^{x},\; f(x+r) = f(x). $$ For any finite abelian group $$G$$, a quantum algorithm exists for solving the hidden subgroup for $$G$$ in polynomial time.

title: Shor's algorithm


text:
Talk:Shor's algorithm

Encryption schemes not vulnerable to quantum computing
"Many public key cryptosystems, such as RSA, will become obsolete if Shor's algorithm is ever implemented in a practical quantum computer."

Are there any encryption systems that would not be obsolete if a quantum computer becomes practical? That would be useful information to add here, if anyone knows. I have been trying to look this information up but nothing so far, anyone have any clues?--ShaunMacPherson 22:06, 12 Apr 2004 (UTC)

One time pads would be unaffected. Richard Farmbrough.
 * This is briefly discussed at quantum computer. At the present time, only factorisation and discrete log based ciphers are known to be seriously affected (if a QC of sufficient size could be built). A quantum computer could be used to attack a symmetric cipher, but it's speed up is "only" to take the square root of the number of steps. This is a huge speed up for typical block ciphers, but is trivially defeated by doubling the key size. There exists a standard, thoroughly studied method to double the key size of any block cipher, namely triple encryption. Further, the most common key size used today - 128 bits - would only be reduced to a work factor of the order of $$2^{64}$$, which is still quite a tough job unless the information is extremely valuable. And the AES already has 192 and 256 bit modes built in. So, at our present level of knowledge, QC poses essentially no threat to symmetric encryption. Securiger 07:40, 6 Oct 2004 (UTC)

 * The first few lines of the description of the algorithm state that the number N cannot be the power of a prime (say P^Q). How difficult would it be to implement an encryption scheme that raised a prime number to a prime exponent? That would seem to solve the problem as well, wouldn't it? -- TheLastWordSword (talk) 22:21, 9 January 2014 (UTC)
 * A power of prime, and any other perfect power for that matter, is trivial to factor by taking roots up to the log-base-2-of-Nth root of N, a polynomial time operation.--Jasper Deng (talk) 06:48, 19 October 2023 (UTC)

Nature article
In "Experimental realization of Shor's quantum factoring algorithm using nuclear magnetic resonance" (p. 883-884), the IBM team appears to make a clear claim to have constructed a quantum computer: "In the experiment, an ensemble of independent quantum computers rather than a single quantum computer was used…"

They are also clear about their state preparation: "The desired initial state of the seven qubits is $$|\psi_1>$$ |0000001> (Fig. 1). However, experimentally we start from thermal equilibrium. The density matrix is then given by $$\rho_{th}=e^{H_0/k_BT}/2^7,$$ with $$k_BT >>\hbar\omega_i$$ at room temperature so each spin is in a statistical mixture of |0> and |1> (Fig. 3a). We converted $$\rho_{th}$$ into a 7-spin effective pure state $$\rho_1$$ via temporal averaging…"

There may be doubts about the nature of the calculation, but I think it's clear that the team did claim to build a quantum computer. CRGreathouse (t | c) 17:46, 4 June 2008 (UTC)

 * Lear from nature, and you will nothing to learn. —Preceding unsigned comment added by Weekwhom (talk • contribs)

Archive and other stuff
So I've gone ahead and archived most of the rest of the posts on this page. There were multiple long discussions, many from literally 15 years ago, ~2006-2008, and I figured they weren't worth keeping. @Qq8, @Luca Innocenti, I noticed you two were talking on one the of the older posts, but the discussion wasn't really relevant to the older post, so I figured I could archive it, and you guys could make a new post. Your guyses edits to the page have been very good! The page looks a lot better than when I first saw it.

A few months ago in April, I made a drastic series of edits to the page, pretty much wiping out most of the algorithm explanation and replacing it with the baseline of what the article is right now, which is largely based off the quantum phase estimation formulation of the algorithm. The explanation for the quantum subroutine of the algorithm from before seemed mostly like giberish, so I just decided to get rid of it. I meant to look into it at some point, to see if there was some value there, but I haven't bothered, so if anybody else wants to look into that, go right ahead :)

Also, it may be a good idea to include information on the original formulation of Shor's algorithm without phase estimation. I think the original body of this article explained it that way (but again it was pretty bad). Tapeworms27 (talk) 23:41, 5 August 2023 (UTC)

 * Also should we update the Wikiproject template quality levels? I'd like to think that the article has been improved a lot. I'm not familiar with assessing that, so that's a thing that could be done if anybody wants to. Tapeworms27 (talk) 23:43, 5 August 2023 (UTC)
 * @Tapeworms27 thanks! I mostly agree with your changes, and archiving most of the old discussions here which were either stale or outdated with the current version of the wiki anyway.
 * I'm not very familiar with quality assessment levels, but having had a quick look at Content assessment, I'm not so sure I'd rate the current version of this page as more than C. I think there's still plenty that can be done, both in quality of writing for some of the sections, and in additional content to add. For example, adding how the algorithm works out in an explicit toy example would help a lot digesting the material. Also some additional detail about the number of qubits required in the first register is needed: currently the article just says "2n is sufficient" without saying why.   Luca (talk) 20:58, 6 August 2023 (UTC)

Simple Animation of Shor's
https://www.youtube.com/watch?v=nvk8xU2BNnY Doug youvan (talk) 15:34, 13 February 2024 (UTC)

title: Talk:Shor's algorithm