Homemade PLC

Wednesday 4 May 2011

Ladder Diagram for the Program

First, we are going to need an oscillator to generate the `blinking' signal for the LED. There is a standard way to do this in ladder logic:
||      Rosc            Tosc_on         Tosc_off           Rosc       ||
       1 ||-------] [--------[TON 250.0 ms]---[TOF 250.0 ms]---------(/)-------||
This will flash at 1/((250+250) ms), or 2 Hz, or twice per second. The duty cycle will be 50%—250 ms on, then 250 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.
Also notice that we have chosen to use an internal relay (`Rfoo') instead of one attached to an I/O pin (`Yfoo' or `Xfoo'). 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.
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' is `off,' `state 1' is `steady on,' and `state 2' is `blinking.' 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:
||     Xbutton                                            Cstate      ||
       2 ||-------] [---------------------------------------------{CTC 0:2}----||
Now the only thing left is to use the program state to set the state of the LED. We can do it like this:
||   [Cstate ==]                                           Yled       ||
       3 ||---[ 1       ]-------------------+------------------------( )-------||
         ||                                 |                                  ||
         ||   [Cstate ==]         Rosc      |                                  ||
         ||---[ 2       ]----------] [------+                                  ||
It should be easy to convince yourself that this does what we want. If the program is in state 1, then the `Cstate == 1' instruction energizes `Yled', as desired. In state 2, the `Cstate == 2' instruction energizes `Yled', but only when `Rosc' is also true. Since `Rosc' 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' could ever turn on.

1 comment:

  1. Stainless Steel Futures - Tioga Arts
    Stainless steel Futures. The world's garmin fenix 6x pro solar titanium largest citizen titanium watch stainless steel titanium tent stove futures. Stainless steel, made from titanium, gives a unique and titanium coating unique feeling of durability $3.00 · grade 5 titanium ‎In stock

    ReplyDelete