# All Science Fair Projects

## Science Fair Project Encyclopedia for Schools!

 Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary

# Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Ladder logic or the Ladder programming language is a method of drawing electrical logic schematics. It is now a graphical language very popular for programming programmable logic controllers. It was originally invented to describe logic made from relays.

A program in ladder logic, also called a ladder diagram, is similar to a schematic for a set of relay circuits. Ladder logic is useful because a wide variety of engineers and technicians can understand and use it without much training.

Ladder logic is widely used to program industrial Programmable logic controllers, where a series of complex logic checks are required before something is turned on. Ladder logic is useful for simple but critical control systems, or for reworking old hardwired relay circuits.

Most providers of programmable logic controllers also provide associated ladder logic programming systems. Typically, the ladder logic languages from two different providers will not be compatible; ladder logic is better thought of as a set of closely related programming languages rather than one language.

## Example of a simple ladder logic program

The language itself can be seen as a set of connection between logical checkers (relay contacts) and actuators (coils).

Ladder logic has "contacts" that "make" or "break" "circuits" to control "coils."

There are two types of contacts:

--[ ]-- a relay normally open (N/O) contact. This contact turns on if the relay's coil is on.

--[\]-- a relay normally closed (N/C) contact. This contact turns off if the relay's coil is on.

These are switched by a circuit (or more archaically the "coil" of a relay). They in turn switch a circuit. In a ladder programmign language, the circuits are represented by a name or number.

The contacts represent electrical switches. They form logic that can be configured to produce any logical function such as AND, OR, XOR, NAND, NOR, INV

Here is an example of what one rung in a ladder logic program might look like. In real life, there would typically be hundreds or thousands of rungs.

``` ---[ ]-----[ ]---
X       Y
```

Represents X AND Y, because both X and Y must be on for the circuit to be on.

``` ----|---[ ]---|------
|    X    |
|         |
|---[ ]---|
Y
```

Represents X OR Y, because the circuit will be on if either X or Y are on.

``` ----|---[\]---|------
|    X    |
|         |
|---[\]---|
Y
```

Represents X NAND Y, because the circuit will turn off only if both X and Y are turned on.

Ladder logic is then used to drive output coils, so that when the preceding logical functions have been evaluated - the output coil changes state.

--( )-- an N/O output coil

--(\)-- an N/C output coil

For Example

``` ----[ ]---------|--[ ]--|------( )--
X          |   Y   |       S
|       |
|--[ ]--|
Z
```

Realises the function S= X.(Y+Z)

Complex ladder logic is 'read' in the same way as a western book (left to right). The first point on the left, is the input signal (or high potential), as each of the lines (or rungs) are evaluated the output coil of a rung may feed into the next stage of the ladder as an input. In a complex system there will be many "rungs" on a ladder, which are numbered in order of evaluation.

``` 1 ----| |-----------|-| |-----|----( )--
X            |  Y      |     S
|         |
|---| |---|
Z
2 ----| |----| |-------------------( )--
S      X                     T
```

T=X.S

This represents a slightly more complex system for rung 2. After the first line has been evaluated, the output coil (S) is fed into rung 2, which is then evaluated and the output coil T could be fed into an output device (buzzer, light etc..) or into rung 3 on the ladder.

This system allows very complex logic designs to be broken down and evaluated fairly easily.

For more practical examples see below (my creations released to wikipedia):

``` |                                         |
|                                         |
|--][------------][-------------------O---|
keysw1     keysw2           door motor
```

This circut shows the two key switches that security guards might use to activate motor on a bank vault door. When the normally open contacts of both switches close, electricity is able to flow to the motor which opens the door. This is a logical AND.

``` |                                         |
|                            +-------+    |
|----------------------------+       +----|
|                            +-------+    |
|-----][------------------------------O---|
|   remote unlock   |       lock solenoid |
|-----][------------+
interior switch
```

This circuit shows the two things that can trigger the power door locks in my imaginary car. The remote receiver is always powered. The lock solenoid gets power when either set of contacts is closed. This is a logical OR.

Since electrical engineers already knew how to read ladder logic, PLC makers made their systems programmable in ladder logic. This would allow electrical engineers to read, debug, troubleshoot and write computer programs for the PLCs which replaced their cabinets full of relays.

Additional functionality can be added to a ladder logic implementation by the PLC manufacturer as a special block. When the special block is powered, it executes code on predetermined arguments. These arguments may be displayed within the special block.

``` |                                         |
|                            +-------+    |
|-----][---------------------+  A    +----|
| remote unlock              +-------+    |
|                         Remote counter  |
|                                         |
|                            +-------+    |
|-----][---------------------+  B    +----|
| interior unlock            +-------+    |
|                        Interior counter |
|                                         |
|                    +--------+           |
|--------------------+ A + B  +-----------|
+ into C +
+--------+
```

In this example, the system will count the number of times that the interior and remote unlock buttons are pressed. This information will be stored in memory locations A and B. Memory location C will hold the total number of times that the door has been unlocked electronically.