Interlock (engineering)

An interlock is a feature that makes the state of two mechanisms or functions mutually dependent. It may be used to prevent undesired states in a finite-state machine, and may consist of any electrical, electronic, or mechanical devices or systems. In most applications, an interlock is used to help prevent a machine from harming its operator or damaging itself by preventing one element from changing state due to the state of another element, and vice versa. Elevators are equipped with an interlock that prevents the moving elevator from opening its doors, and prevents the stationary elevator (with open doors) from moving. Interlocks may include sophisticated elements such as curtains of infrared beams, photodetectors, a computer containing an interlocking computer program, digital or analogue electronics, or simple switches and locks.
Trapped-key interlocking.
Trapped-key interlocking is a method of ensuring safety in industrial environments by forcing the operator through a predetermined sequence using a defined selection of keys, locks and switches.
It is called "trapped key" as it works by releasing and trapping keys in a predetermined sequence. After the control or power has been isolated, a key is released that can be used to grant access to individual or multiple doors.
For example, to prevent access to the inside of an electric kiln, a trapped key system may be used to interlock a disconnecting switch and the kiln door. While the switch is turned on, the key is held by the interlock attached to the disconnecting switch. To open the kiln door, the switch is first opened, which releases the key. The key can then be used to unlock the kiln door. While the key is removed from the switch interlock, a plunger from the interlock mechanically prevents the switch from closing. Power cannot be re-applied to the kiln until the kiln door is locked, releasing the key, and the key is then returned to the disconnecting switch interlock. A similar two-part interlock system can be used anywhere it is necessary to ensure the energy supply to a machine is interrupted before the machine is entered for adjustment or maintenance.
Microprocessors.
In microprocessor architecture an interlock is hardware that stalls the pipeline (inserts bubbles) when a hazard is detected until the hazard is cleared. One example of a hazard is if a software program loads data from the system bus and calls for use of that data in the following cycle in a system in which loads take multiple cycles (a load-to-use hazard).
Mechanical.
Interlocks may be strictly mechanical, as in one form of internal firearm safety, that blocks motion of the trigger, sear and/or firing pin unless the breech is properly closed & locked.
In the operation of a device such as a press or cutter that is hand fed or the workpiece hand removed, the use of two buttons to actuate the device, one for each hand, greatly reduces the possibility of operation endangering the operator. No such system is fool-proof, and such systems are often augmented by the use of cable–pulled gloves worn by the operator; these are retracted away from the danger area by the stroke of the machine. A major problem in engineering operator safety is the tendency of operators to ignore safety precautions or even outright disabling forced interlocks due to work pressure and other factors. Therefore, such safeties require and perhaps must facilitate operator cooperation.
Electrical.
Many people use generators to supplement power to a home or business in the event that main (municipal) power has gone offline. In order to safely transfer the power source from a generator (and back to the main), a safety interlock is often employed. The interlock consists of one or more switches that prevent both main power and generator power from powering the dwelling simultaneously. Without this safeguard, both power sources running at once could cause an overload condition, or generator power back-feed onto the main could cause the dangerous voltage to reach a lineman repairing the main feed far outside the building. 
An interlock device is designed to allow a generator to provide backup power in such a way that it (a) prevents main and generator power to be connected at the same time, and (b) allows circuit breakers to operate normally without interference in the event of an overload condition. Most interlock devices for electrical systems employ a mechanical device to manage the movement of circuit breakers. Some also allow for the use of padlocks to prevent someone from accidentally activating the main power system without authorization.
Security.
In high-security buildings, access control systems are sometimes set up so that ability to open one door requires another one to be closed first. Such setups are called a mantrap (access control).