<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1258797953614713212</id><updated>2024-11-08T07:34:51.218-08:00</updated><title type='text'>Homemade PLC</title><subtitle type='html'>Make you own</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://homemadeplc.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://homemadeplc.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>BlogZz</name><uri>http://www.blogger.com/profile/12122711927790037123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1258797953614713212.post-3707850943426968418</id><published>2011-05-04T12:04:00.000-07:00</published><updated>2011-05-04T12:06:32.557-07:00</updated><title type='text'>Download ldmicro ( Ladder Logic) Software</title><content type='html'>&lt;a href=&quot;http://cq.cx/dl/ldmicro.exe&quot;&gt;Click Here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Low Cos programmer&lt;br /&gt;
&lt;a href=&quot;http://electronics-diy.com/avr_programmer.php&quot;&gt;http://electronics-diy.com/avr_programmer.php&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://homemadeplc.blogspot.com/feeds/3707850943426968418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/download-ldmicro-ladder-logic-software.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/3707850943426968418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/3707850943426968418'/><link rel='alternate' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/download-ldmicro-ladder-logic-software.html' title='Download ldmicro ( Ladder Logic) Software'/><author><name>BlogZz</name><uri>http://www.blogger.com/profile/12122711927790037123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1258797953614713212.post-5705914462632947093</id><published>2011-05-04T11:52:00.001-07:00</published><updated>2011-05-04T11:55:19.442-07:00</updated><title type='text'>Creating HEX File</title><content type='html'>o now we are fairly sure that the program works. At this point we     are ready to generate actual code, and try it in the micro. First,     exit simulation mode by choosing Simulate -&amp;gt; Simulation Mode, or by     pressing Escape.      &lt;br /&gt;
Next we must choose a microcontroller. We decided earlier that we     would be using a PIC16F876, so choose Settings -&amp;gt; Microcontroller -&amp;gt;     Microchip PIC16F876 28-PDIP or 28-SOIC. We also have to tell LDmicro     what kind of crystal we will be using, and what the cycle time will     be. Choose Settings -&amp;gt; MCU Parameters, and fill in our clock speed     of 20&amp;nbsp;MHz. Leave the cycle time at 10&amp;nbsp;ms; that will usually     be a good value.&lt;br /&gt;
Now we can assign pins to our inputs and outputs. Double-click     `Xbutton&#39; in the list at the bottom of the screen, and choose pin     14 of the PIC, which corresponds to MCU port RC3. (There is usually     no reason for you to care which port you are using; just look at     the pin number.)&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAnMzANuDaOWQQTtDl2SVUBjb8z3it4jK15mj04fPbZcVw8uqKue9zWs44vWRn65D9NkO3nRqNDkQm52OS40mlNMbE7H8jiPTshB0MO9e69uUB7zKbv_VVrPKTGYB-gQiv_WsF17vbblJp/s1600/ldtut-assigning-io-pin.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;547&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAnMzANuDaOWQQTtDl2SVUBjb8z3it4jK15mj04fPbZcVw8uqKue9zWs44vWRn65D9NkO3nRqNDkQm52OS40mlNMbE7H8jiPTshB0MO9e69uUB7zKbv_VVrPKTGYB-gQiv_WsF17vbblJp/s640/ldtut-assigning-io-pin.png&quot; width=&quot;640&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;Click `OK,&#39; and then repeat the process for `Yled&#39;, which you     can see from the schematic should go to pin 15. The other elements     in the list are internal variables and bits in memory, so there is     no need to assign pins to them. LDmicro will allocate memory for them     when you compile.&lt;br /&gt;
So now you are ready to compile. Choose Compile -&amp;gt; Compile,     and specify where you want to put the IHEX file. Then use whatever     PIC programming equipment you have available to load that into your     device, and you are ready to try it out.&lt;br /&gt;
This completes my tutorial. It is possible to write much more     complex programs than that, of course. A program this simple uses     only a very small fraction of your processor&#39;s memory, so there is     room for many more rungs of logic. LDmicro also offers specialised     instructions, for things like arithmetic, analog (A/D) inputs, PWM,     and even text output to a character-based LCD. Consult the manual     for details&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homemadeplc.blogspot.com/feeds/5705914462632947093/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/creating-hex-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/5705914462632947093'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/5705914462632947093'/><link rel='alternate' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/creating-hex-file.html' title='Creating HEX File'/><author><name>BlogZz</name><uri>http://www.blogger.com/profile/12122711927790037123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAnMzANuDaOWQQTtDl2SVUBjb8z3it4jK15mj04fPbZcVw8uqKue9zWs44vWRn65D9NkO3nRqNDkQm52OS40mlNMbE7H8jiPTshB0MO9e69uUB7zKbv_VVrPKTGYB-gQiv_WsF17vbblJp/s72-c/ldtut-assigning-io-pin.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1258797953614713212.post-9017593886622267547</id><published>2011-05-04T11:50:00.000-07:00</published><updated>2011-05-04T11:56:24.684-07:00</updated><title type='text'>Simulation</title><content type='html'>Now we are ready to simulate our circuit. Choose Simulate -&amp;gt;     Simulation Mode. The display will change; the ladder diagram will     appear mostly greyed, but you won&#39;t see anything changing with     time. That is because the PLC is not yet cycling. To start it cycling,     choose Simulate -&amp;gt; Start Real-Time Simulation. Now you will see things     happening: the oscillator is obviously running, but the LED (`Yled&#39;)     is still off, which is what we want, because no one has pressed the     button yet. To simulate pressing the button, double-click the text     `Xbutton&#39; in the list at the bottom of the screen. You have now     simulated bringing the pushbutton input high; this is what would     happen if someone depressed (but did not yet release) the pushbutton.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR_hG2UswuKZsBaBBOBN-IscafrruAqMHdgQlPkgtIOVyi-WDNiL2RskGpkkPCLKXW6EtHl-FkFToTL-SG0csig7j1UIEHMdcPSBXDKsszEdzWZJVlzdVl5bH6faLaAfj3wNqJ_bQPYwwv/s1600/ldtut-simulation-just-clicked.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;556&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR_hG2UswuKZsBaBBOBN-IscafrruAqMHdgQlPkgtIOVyi-WDNiL2RskGpkkPCLKXW6EtHl-FkFToTL-SG0csig7j1UIEHMdcPSBXDKsszEdzWZJVlzdVl5bH6faLaAfj3wNqJ_bQPYwwv/s640/ldtut-simulation-just-clicked.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homemadeplc.blogspot.com/feeds/9017593886622267547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/simulating-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/9017593886622267547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/9017593886622267547'/><link rel='alternate' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/simulating-program.html' title='Simulation'/><author><name>BlogZz</name><uri>http://www.blogger.com/profile/12122711927790037123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR_hG2UswuKZsBaBBOBN-IscafrruAqMHdgQlPkgtIOVyi-WDNiL2RskGpkkPCLKXW6EtHl-FkFToTL-SG0csig7j1UIEHMdcPSBXDKsszEdzWZJVlzdVl5bH6faLaAfj3wNqJ_bQPYwwv/s72-c/ldtut-simulation-just-clicked.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1258797953614713212.post-5239137901719568783</id><published>2011-05-04T11:40:00.001-07:00</published><updated>2011-05-04T11:40:42.917-07:00</updated><title type='text'>Ladder Diagram for the Program</title><content type='html'>First, we are going to need an oscillator to generate the     `blinking&#39; signal for the LED. There is a standard way to do     this in ladder logic:&lt;br /&gt;
&lt;pre style=&quot;font-size: 13px; padding-bottom: 10px; padding-top: 10px;&quot;&gt;||      Rosc            Tosc_on         Tosc_off           Rosc       ||
       1 ||-------] [--------[TON 250.0 ms]---[TOF 250.0 ms]---------(/)-------||&lt;/pre&gt;This will flash at 1/((250+250)&amp;nbsp;ms), or 2&amp;nbsp;Hz, or twice per second. The     duty cycle will be&amp;nbsp;50%—250&amp;nbsp;ms on, then 250&amp;nbsp;ms off. This     circuit     can make any kind of oscillator, with whatever period or duty cycle     you require, so it is a good one to remember.&lt;br /&gt;
Also notice that we have chosen to use an internal relay (`Rfoo&#39;)     instead of one attached to an I/O pin (`Yfoo&#39; or `Xfoo&#39;). This     makes sense, because there is no particular reason to bring that     signal out to a pin. LDmicro will automatically assign memory for     the internal relay.&lt;br /&gt;
Our program will have three states: off, steady on, and     blinking. The program should change its state on each rising edge     of the signal from the pushbutton. This is a good application for a     circular counter. We will say that `state 0&#39; is `off,&#39; `state 1&#39; is     `steady on,&#39; and `state 2&#39; is `blinking.&#39; The counter counts 0, 1, 2,     0, 1, 2, ..., so if we just let the rung-in condition of the counter     be the pushbutton input, then everything will work like we want:&lt;br /&gt;
&lt;pre style=&quot;font-size: 13px; padding-bottom: 10px; padding-top: 10px;&quot;&gt;||     Xbutton                                            Cstate      ||
       2 ||-------] [---------------------------------------------{CTC 0:2}----||&lt;/pre&gt;Now the only thing left is to use the program state to     set the state of the LED. We can do it like this:&lt;br /&gt;
&lt;pre style=&quot;font-size: 13px; padding-bottom: 10px; padding-top: 10px;&quot;&gt;||   [Cstate ==]                                           Yled       ||
       3 ||---[ 1       ]-------------------+------------------------( )-------||
         ||                                 |                                  ||
         ||   [Cstate ==]         Rosc      |                                  ||
         ||---[ 2       ]----------] [------+                                  ||&lt;/pre&gt;It should be easy to convince yourself that this does what     we want. If the program is in state 1, then the `Cstate == 1&#39;     instruction energizes `Yled&#39;, as desired. In state 2, the `Cstate     == 2&#39; instruction energizes `Yled&#39;, but only when `Rosc&#39; is also     true. Since `Rosc&#39; is oscillating, that means that the LED will blink,     as desired. Finally, in state 0, neither of the equals instructions     will be true, so there is no way that `Yled&#39; could ever turn on.</content><link rel='replies' type='application/atom+xml' href='http://homemadeplc.blogspot.com/feeds/5239137901719568783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/ladder-diagram-for-program.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/5239137901719568783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/5239137901719568783'/><link rel='alternate' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/ladder-diagram-for-program.html' title='Ladder Diagram for the Program'/><author><name>BlogZz</name><uri>http://www.blogger.com/profile/12122711927790037123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1258797953614713212.post-2204941142380925709</id><published>2011-05-04T11:38:00.000-07:00</published><updated>2011-05-04T11:38:03.749-07:00</updated><title type='text'>Microcontroller Selection and Schematic</title><content type='html'>We will be using a PIC16F876, which is easily available from     Digikey or other online distributors. It comes in a number of different     packages; I chose a DIP.&lt;br /&gt;
Note that as of Nov 2009, the PIC16F876 is no longer recommended for     new design. This means that it will probably get discontinued at some     point in the next few years. You may prefer to instead use a PIC16F886,     which is pin-compatible. If you do, then make sure to specify the correct     part when you compile, since the &#39;F886 is not code-compatible.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0T6zLS5hq5EiIbo1YMJDllLVz4SR82gnC07dcO1WaKNCVNgOtm8DjTelpqkJLXPfriBFiS8Oh5r6U_vt1Df9HWmCa3JlGWHo5Rzl7VyOoH8sAPWSPaLIwYlnqtxHiJiNSRkAo-nPPNxTe/s1600/ldtut-schematic.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;315&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0T6zLS5hq5EiIbo1YMJDllLVz4SR82gnC07dcO1WaKNCVNgOtm8DjTelpqkJLXPfriBFiS8Oh5r6U_vt1Df9HWmCa3JlGWHo5Rzl7VyOoH8sAPWSPaLIwYlnqtxHiJiNSRkAo-nPPNxTe/s400/ldtut-schematic.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This is our schematic:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The microcontroller (IC1) is part number PIC16F876-20I/SP-ND at      Digikey. Almost any three-terminal     resonator (U1) will do; you might try a 535-9356-ND or an X909-ND.&lt;br /&gt;
The only thing that might confuse you is that the pushbutton goes     to Vdd, and there is a pull-down. You might be more used to seeing     a pushbutton to ground with a pull-up. For TTL, this mattered. For     modern CMOS it does not, and I find this `active HIGH&#39; arrangement     less confusing than the traditional `active LOW&#39; circuit.&lt;br /&gt;
Also, I chose to use a ceramic resonator with internal capacitors,     U1, instead of a crystal and two ~20&amp;nbsp;pF caps. A crystal would     work just as well and it would be more accurate, but it would be a     little bit more expensive, and you would need more parts.&lt;br /&gt;
You could build this circuit in many different ways. I built it on     a solderless breadboard, and it ended up looking like this:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmhIvqIOxpEldYXJtmIuNFexVFSpyEKHdkDNdr-QtXS2pGXjOnk7ee12mKzZtzRbb8nSwQpGtFzQzY_IDMyRgv5_QDZ0xgc-aRrhOAJppZogrtgxa978qTo9XjgFPDMg65BqB447HdzwVB/s1600/ldtut-breadboard.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;268&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmhIvqIOxpEldYXJtmIuNFexVFSpyEKHdkDNdr-QtXS2pGXjOnk7ee12mKzZtzRbb8nSwQpGtFzQzY_IDMyRgv5_QDZ0xgc-aRrhOAJppZogrtgxa978qTo9XjgFPDMg65BqB447HdzwVB/s400/ldtut-breadboard.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://homemadeplc.blogspot.com/feeds/2204941142380925709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/microcontroller-selection-and-schematic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/2204941142380925709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/2204941142380925709'/><link rel='alternate' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/microcontroller-selection-and-schematic.html' title='Microcontroller Selection and Schematic'/><author><name>BlogZz</name><uri>http://www.blogger.com/profile/12122711927790037123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0T6zLS5hq5EiIbo1YMJDllLVz4SR82gnC07dcO1WaKNCVNgOtm8DjTelpqkJLXPfriBFiS8Oh5r6U_vt1Df9HWmCa3JlGWHo5Rzl7VyOoH8sAPWSPaLIwYlnqtxHiJiNSRkAo-nPPNxTe/s72-c/ldtut-schematic.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1258797953614713212.post-406552067000350721</id><published>2011-05-04T11:32:00.000-07:00</published><updated>2011-05-04T11:32:42.600-07:00</updated><title type='text'>How It Works (Introduction)</title><content type='html'>PLCs are often programmed in ladder logic. This is because PLCs     originally replaced relay control systems, and forty years later, we     still haven&#39;t quite let go. A PLC, like any microprocessor, executes     a list of instructions in sequence. Ladder logic tools abstract     this; you can program the PLC by wiring up relay contacts and coils     on-screen, and the PLC runtime will simulate the circuit that you&#39;ve     drawn. Some of the relay contacts can be tied to input signals from     the real world; some of the coils can be tied to outputs. That way     you can make your simulated circuit interact with other devices,     and actually control things. That is the point.&lt;br /&gt;
Actually it&#39;s more general than that, because you can incorporate     timers and counters and arithmetic operations that you couldn&#39;t     (easily) perform with just relays. The circuit concept is still     useful though, partly just because it&#39;s intuitive, but also because     it abstracts the concurrency issues. It looks like this:&lt;br /&gt;
&lt;pre style=&quot;font-size: 13px; padding: 3px 0px 10px;&quot;&gt;||       Xa               Xb              Yout       ||
       1 ||-------] [------+-------] [------+-------( )-------||
         ||                |                |                 ||
         ||                |       Xc       |                 ||
         ||                +-------]/[------+                 ||&lt;/pre&gt;This is a simple piece of combinational logic. There are three     input terms, Xa, Xb, and Xc. There is one output term, Yout. The     expression is Yout := Xa and (Xb or (not Xc)). This makes sense     if you think of Xa and Xb as normally open relay contacts, Xc as     normally closed relay contacts, and Yout as a relay coil. Of course     it gets more complicated than that:&lt;br /&gt;
&lt;pre style=&quot;font-size: 13px; padding: 3px 0px 10px;&quot;&gt;||                                                   ||
         ||                                      Asetpoint    ||
       1 ||-------------------------------------{READ ADC}----||
         ||                                                   ||
         ||                                    Atemperature   ||
         ||-------------------------------------{READ ADC}----||
         ||                                                   ||
         ||                                                   ||
         ||                                                   ||
         ||                                                   ||
         ||                        {SUB  min_temp  :=}        ||
       2 ||------------------------{ Asetpoint - 20  }--------||
         ||                                                   ||
         ||                        {ADD  max_temp  :=}        ||
         ||------------------------{ Asetpoint + 20  }--------||
         ||                                                   ||
         ||                                                   ||
         ||                                                   ||
         ||                                                   ||
         ||[Atemperature &amp;gt;]                       Yheater     ||
       3 ||[ max_temp     ]+------------------------(R)-------||
         ||                |                                  ||
         ||     Xenable    |                                  ||
         ||-------]/[------+                                  ||
         ||                                                   ||
         ||[Atemperature &amp;lt;]      Xenable          Yheater     ||
         ||[ min_temp     ]--------] [--------------(S)-------||
         ||                                                   ||
         ||                                                   ||
         ||                                                   ||
         ||                                                   ||
         ||                       {SUB  check_temp  :=}       ||
       4 ||-----------------------{ Asetpoint - 30    }-------||
         ||                                                   ||
         ||                                                   ||
         ||                                                   ||
         ||                                                   ||
         ||[Atemperature &amp;gt;]                       Yis_hot     ||
       5 ||[ check_temp   ]-------------------------( )-------||
         ||                                                   ||
         ||                                                   ||
         ||                                                   ||
         ||------[END]----------------------------------------||
         ||                                                   ||
         ||                                                   ||&lt;/pre&gt;This is for a simple thermostat. There are two analog inputs; one     of them is for the setpoint, so that it might, for example, be connected to     a pot that the user turns to select the desired temperature. The other     provides the temperature measurement; it might be a semiconductor     temperature sensor, or a platinum RTD with suitable interfacing     circuitry. There is a digital output, Yheater. That might control     a heating element, through a suitable switch (a TRIAC, or a relay,     or a solid-state relay, or whatever).  &lt;br /&gt;
We close the loop with a simple hysteretic (bang-bang)     controller. We have selected plus or minus 20 ADC units     of hysteresis. That means that when the temperature falls below     (setpoint - 20), we turn on the heater, and when it climbs above     (setpoint + 20), we turn the heater off.&lt;br /&gt;
I chose to add a few small frills. First, there is an enable     input: the heater is forced off when Xenable is low. I also added an     indicator light, Yis_hot, to indicate that the temperature is within     regulation. This compares against a threshold slightly colder than     (setpoint - 20), so that the light does not flicker with the normal     cycling of the thermostat.&lt;br /&gt;
This is a trivial example, but it should be clear that the language     is quite expressive. Ladder logic is not a general-purpose programming     language, but it is Turing-complete, accepted in industry, and, for     a limited class of (mostly control-oriented) problems, surprisingly     convenient.</content><link rel='replies' type='application/atom+xml' href='http://homemadeplc.blogspot.com/feeds/406552067000350721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/how-it-works-introduction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/406552067000350721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/406552067000350721'/><link rel='alternate' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/how-it-works-introduction.html' title='How It Works (Introduction)'/><author><name>BlogZz</name><uri>http://www.blogger.com/profile/12122711927790037123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1258797953614713212.post-6548894575301976957</id><published>2011-05-04T11:28:00.000-07:00</published><updated>2011-05-04T11:28:16.251-07:00</updated><title type='text'>Quick summary</title><content type='html'>This is a Microcontroller Based PLC that starts with a ladder     diagram and generates native PIC16 or AVR code. Features include:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;digital inputs and outputs&lt;/li&gt;
&lt;li&gt;timers (TON, TOF, RTO)&lt;/li&gt;
&lt;li&gt;counters (CTU, CTD, `circular counters&#39; for use like a sequencer)&lt;/li&gt;
&lt;li&gt;analog inputs, analog (PWM) outputs&lt;/li&gt;
&lt;li&gt;integer variables and arithmetic instructions&lt;/li&gt;
&lt;li&gt;easy-to-use serial communications, to a PC, LCD, or other device &lt;/li&gt;
&lt;li&gt;shift registers, look-up tables&lt;/li&gt;
&lt;li&gt;EEPROM variables, whose values are not forgotten when you lose power&lt;/li&gt;
&lt;li&gt;simulator, to test your program before you generate PIC/AVR code&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://homemadeplc.blogspot.com/feeds/6548894575301976957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/quick-summary.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/6548894575301976957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1258797953614713212/posts/default/6548894575301976957'/><link rel='alternate' type='text/html' href='http://homemadeplc.blogspot.com/2011/05/quick-summary.html' title='Quick summary'/><author><name>BlogZz</name><uri>http://www.blogger.com/profile/12122711927790037123</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>