sd-01 plcs

80
Software Development Software Development Aurel GONTEAN October 28, 2022

Upload: dragos-radu

Post on 27-Sep-2015

17 views

Category:

Documents


1 download

DESCRIPTION

PLCs

TRANSCRIPT

  • Software DevelopmentAurel GONTEAN*

  • PLCs*

  • What is a PLC?A programmable logic controller, also called a PLC or programmable controller, is a computer-type device used to control equipment in an industrial facility. The kinds of equipment that PLCs can control are as varied as industrial facilities themselves:Conveyor systems,food processing machinery, auto assembly lines*

  • What is a PLC?In a traditional industrial control system, all control devices are wired directly to each other according to how the system is supposed to operate. In a PLC system, however, the PLC replaces the wiring between the devices. Thus, instead of being wired directly to each other, all equipment is wired to the PLC. Then, the control program inside the PLC provides the wiring connection between the devices.*

  • What is a PLC?The control program is the computer program stored in the PLCs memory that tells the PLC whats supposed to be going on in the system. The use of a PLC to provide the wiring connections between system devices is called softwiring.

    *

  • ExampleLets say that a push button is supposed to control the operation of a motor. In a traditional control system, the push button would be wired directly to the motor. In a PLC system, however, both the push button and the motor would be wired to the PLC instead. Then, the PLCs control program would complete the electrical circuit between the two, allowing the button to control the motor.

    *

  • Example*

  • Why Use PLCs?The softwiring advantage provided by programmable controllers is tremendous. Softwiring makes changes in the control system easy and cheap. If you want a device in a PLC system to behave differently or to control a different process element, all you have to do is change the control program. In a traditional system, making this type of change would involve physically changing the wiring between the devices, a costly and time-consuming endeavor.*

  • ExampleLets say that two push buttons, PB1 and PB2, are connected to a PLC.Two pilot lights, PL1 and PL2, are also connected to the PLC. The way these devices are connected now pressing push button PB1 turns on pilot light PL1 and pressing push button PB2 turns on pilot light PL2.Lets say that you want to change this around so that PB1 controls PL2 and PB2 controls PL1. In a traditional system, you would have to rewire the circuit so that the wiring from the first push button goes to the second pilot light and vice versa. However, because these devices are connected to a PLC, making this change is as simple as making a small change in the control program.*

  • PLCs Additional Advantageshigh reliabilitysmall space requirementscomputing capabilitiesreduced costsability to withstand harsh environmentsexpandability

    *

  • Detailed view of a PLCA PLC basically consists of two elements:the central processing unitthe input/output system*

  • CPUThe (CPU) is the part of a PLC that retrieves, decodes, stores, and processes information.The CPU has three parts:the processorthe memory systemthe power supply

    *

  • The Input/Output (I/O) SystemThe input/output (I/O) system is the section of a PLC to which all of the field devices are connected. The I/O system is what actually physically carries out the control commands from the program stored in the PLCs memory.The I/O system consists of two main parts:the rackI/O modules

    *

  • The Rack and I/O Modules*

  • More about I/OsAll of the field devices connected to a PLC can be classified in one of two categories:InputsOutputsInputs are devices that supply a signal/data to a PLC. Typical examples of inputs are push buttons, switches, and measurement devices.

    *

  • OutputsOutputs are devices that await a signal/data from the PLC to perform their control functions. Typical examples of outputs are:Lights, horns, motorsvalves

    *

  • Example*

  • I/OsThere are two basic types of input and output devices:Discrete (digital) 0s and 1sAnalog infinite number of statesExamples - Discrete (digital)overhead light and switch Examples - AnalogThermometer, valve

    *

  • I/Osdifferent input and output devices send different kinds of signalsWhile PLCs are powerful devices, they cant always speak the language of every device connected to themI/O modules act as translators between the field devices and the PLC*

  • Control ProgramThe control program is a software program in the PLCs memory.The control program is made up of instructionsRemember, changing the system is a snap.All PLCs use two basic types of instructions:ContactsCoils*

  • ContactsContacts are instructions that refer to the input conditions to the control programthat is, to the information supplied by the input field devices. Each contact in the control program monitors a certain field device. The contact waits for the input to do something in particular.*

  • CoilsCoils are instructions that refer to the outputs of the control program that is, to what each particular output device is supposed to do in the system. Like a contact, each coil also monitors a certain field device. However, unlike a contact, which monitors the field device and then tells the PLC what to do, a coil monitors the PLC control program and then tells the field device what to do.

    *

  • Example*

  • The ScanIn PLC talk, this three-step process of:monitoring the inputsexecuting the PLC control programchanging the status of the outputs accordinglyis called the scan.*

  • The Scan*

  • A Practical PLCSiemens S7-200*

  • Introducing the S7-200 Micro PLCThe Siemens S7-200 series is a line of micro-programmable logic controllers (Micro PLCs) perfect for controlling small applicationscompact design, powerful instruction setexpandability, low cost

    *

  • A typical PLC setup*

  • Features*

  • Features*

  • Features*

  • Features*

  • Features*

  • Understanding the Scan CycleThe S7-200 CPU is designed to execute a series of tasks, including your program, repetitively (scan cycle). During the scan cycle shown in next slide, the CPU performs most or all of the following tasks: Reading the inputs Executing the program Processing any communication requests Executing the CPU self-test diagnostics Writing to the outputs*

  • Understanding the Scan CycleThe series of tasks executed during the scan cycle is dependent upon the operating mode of the CPU. The S7-200 CPU has two modes of operation, STOP mode (program is not executed).RUN mode (program is executed)

    *

  • Reading the Digital InputsEach scan cycle begins by reading the current value of the digital inputs and then writing these values to the process-image input register.The CPU reserves the process-image input register in increments of eight bits (one byte). The CPU does not automatically update analog inputs as part of the scan cycle and does not maintain an analog input image register. You must access the analog inputs directly from your program.

    *

  • Executing the ProgramThe CPU executes the program, starting with the first instruction and proceeding to the end instruction. The immediate I/O instructions give immediate access to inputs and outputs during the execution of either the program or an interrupt routine.If used, the interrupt routines that are associated with the interrupt events are stored as part of the program. The interrupt routines are not executed as part of the normal scan cycle, but are executed when the interrupt event occurs (which may be at any point in the scan cycle).

    *

  • Communication / Self-Diagnostic Test Processing the Communication RequestsDuring the message-processing phase of the scan cycle, the CPU processes any messages that were received from the communications port.Executing the CPU Self-Diagnostic TestDuring this phase of the scan cycle, the CPU checks its firmware and your program memory (RUN mode only). It also checks the status of any I/O modules.*

  • Writing to the Digital OutputsAt the end of every scan cycle, the CPU writes the values stored in the process-image output register to the digital outputs.The CPU does not automatically update analog outputs as part of the scan cycle and does not maintain an analog output image register. You must access the analog outputs directly from your program.When the CPU operating mode is changed from RUN to STOP:the digital outputs are set to the values defined in the Output Table, or are left in their current state. Analog outputs remain at the value last written.*

  • Immediate I/OImmediate I/O instructions allow direct access to the actual input or output point, even though the image registers are normally used as either the source or the destination for I/O accesses. The corresponding process-image input register location is not modified when you use an immediate instruction to access an input point. The corresponding process-image output register location is updated simultaneously when you use an immediate instruction to access an output point.

    *

  • Interrupting the Scan CycleIf you use interrupts, the routines associated with each interrupt event are stored as part of the program. The interrupt routines are not executed as part of the normal scan cycle, but are executed when the interrupt event occurs (which may be at any point in the scan cycle).Interrupts are serviced by the CPU on a first-come-first-served basis within their respective priority assignments.

    *

  • Process-Image Input / Output RegistersIt is usually advantageous to use the process-image register rather than to directly access inputs or outputs.There are three reasons for using the image registers: The sampling of all inputs at the top of the scan synchronizes and freezes the values of the inputs for the program execution phase of the scan cycle. The outputs are updated from the image register after the execution of the program is complete. This provides a stabilizing effect on the system. Your program can access the image register much quicker than it can access I/O points, allowing faster execution of the program. I/O points are bit entities and must be accessed as bits, but you can access the image register as bits, bytes, words, or double words. Thus, the image registers provide additional flexibility.

    *

  • Process-Image Input / Output RegistersAn additional benefit isthat the image registers are large enough to handle the maximum number of input and output points. There is always some number of image register locations not used, that can be used as extra internal memory bits.

    *

  • Direct Addressing of the CPU Memory Areas*

  • Using the Memory Address to Access Data*

  • Accessing a bitTo access a bit in a memory area, one must specify the address, which includes the memory area identifier, the byte address, and the bit number.

    *

  • Accessing a Byte, Word, DWordUsing the byte address format, one can access data in many CPU memory areas (V, I, Q, M, and SM) as bytes, words, or double words. The address must be specified similar to specifying the address for a bit. This includes an area identifier, data size designation, and the starting byte address of the byte, word, or double-wordData in other CPU memory areas (such as T, C, HC, and the accumulators) are accessed by using an address format that includes an area identifier and a device number.*

  • Accessing a Byte, Word, DWord*

  • Representation of NumbersData Size Designations and Associated Integer Ranges*

    Data SizeUnsigned Integer RangeSigned Integer RangeDecimalHexadecimalDecimalHexadecimalB (Byte): 8-bit value0 to 2550 to FF128 to 127 -80 to 7FW (Word): 16-bit value0 to 65,535 0 to FFFF-32,768 to 32,7678000 to 7FFFD (Double word, Dword): 32-bit value0 to4,294,967,2950 toFFFF FFFF-2,147,483,648 to2,147,483,6478000 0000 to7FFF FFFF

  • The Process-Image Input Register (I)The CPU samples the physical input points at the beginning of each scan cycle and writes these values to the process-image input register. You can access the process-image input register in bits, bytes, words, or double words.Format: Bit I[byte address].[bit address] I0.1Byte, Word, Double Word I[size][starting byte address] IB4*

  • The Process-Image Output Register (Q)At the end of the scan cycle, the CPU copies the values stored in the process-image output register to the physical output points. You can access the process-image output register in bits, bytes, words, or double words.Format: Bit Q[byte address].[bit address] Q1.1Byte, Word, Double Word Q[size][starting byte address] QB5*

  • The Variable (V) Memory AreaYou can use V memory to store intermediate results of operations being performed by the control logic in your program. You can also use V memory to store other data pertaining to your process or task. You can access the V memory area in bits, bytes, words, or double words.Format: Bit V[byte address].[bit address] V10.2Byte, Word, Double Word V[size][starting byte address] VW100*

  • The Bit Memory (M) AreaYou can use the internal memory bits (M memory) as control relays to store the intermediate status of an operation or other control information. While the name bit memory area implies that this information is stored in bit-length units, you can access the bit memory area not only in bits, but also in bytes, words, or double words.Format: Bit M[byte address].[bit address] M26.7Byte, Word, Double Word M[size][starting byte address] MD20*

  • The Sequence Control Relay (S) Memory AreaSequence Control Relay bits (S) are used to organize machine operations or steps into equivalent program segments. SCRs allow logical segmentation of the control program. You can access the S bits as bits, bytes, words, or double words.Format: Bit S[byte address].[bit address] S3.1Byte, Word, Double Word S[size][starting byte address] SB4*

  • The Special Memory (SM) BitsThe SM bits provide a means for communicating information between the CPU and your program. You can use these bits to select and control some of the special functions of the S7-200 CPU, such as: A bit that turns on for the first scan Bits that toggle at fixed rates Bits that show the status of math or operational instructionsWhile the SM area is based on bits, you can access the data in this area as bits, bytes, words, or double words.Format: Bit SM[byte address].[bit address] SM0.1Byte, Word, Double Word SM[size][starting byte address] SMB86*

  • SMB0: Status BitsSpecial Memory Byte SMB0 (SM0.0 to SM0.7)*

    SMBits DescriptionSM0.0This bit is always on.SM0.1This bit is on for the first scan. One use is to call an initialization subroutine.SM0.2This bit is turned on for one scan if retentive data was lost. This bit can be used as either an error memory bit or as a mechanism to invoke a special startup sequence.SM0.3This bit is turned on for one scan when RUN mode is entered from a power-up condition. This bit can be used to provide machine warm-up time before starting an operation.SM0.4This bit provides a clock pulse that is on for 30 seconds and off for 30 seconds, for a cycle time of 1 minute. It provides an easy-to-use delay, or a 1-minute clock pulse.SM0.5This bit provides a clock pulse that is on for 0.5 seconds and then off for 0.5 seconds, for a cycle time of 1 second. It provides an easy-to-use delay or a 1-second clock pulse.SM0.6This bit is a scan clock which is on for one scan and then off for the next scan. This bit can be used as a scan counter input.SM0.7This bit reflects the position of the Mode switch (off is TERM position, and on is RUN position). If you use this bit to enable Freeport mode when the switch is in the RUN position, normal communication with the programming device can be enabled by switching to the TERM position.

  • SMB1: Status Bits*

    SMBits DescriptionSM1.0This bit is turned on by the execution of certain instructions when the result of the operation is zero.SM1.1This bit is turned on by the execution of certain instructions either when an overflow results or when an illegal numeric value is detected.SM1.2This bit is turned on when a negative result is produced by a math operation.SM1.3This bit is turned on when division by zero is attempted.SM1.4This bit is turned on when the Add to Table instruction attempts to overfill the table.SM1.5This bit is turned on when either LIFO or FIFO instructions attempt to read from an empty table.SM1.6This bit is turned on when an attempt to convert a non-BCD value to binary is made.SM1.7This bit is turned on when an ASCII value cannot be converted to a valid hexadecimal value.

  • The Timer (T) Memory AreaTimers are devices that count increments of time. The S7-200 timers have resolutions of 1, 10 or 100 ms. There are two variables that are associated with a timer:Current value: this 16-bit signed integer stores the amount of time counted by the timer. Timer bit: this bit turns on (is set to 1) when the current value of the timer is greater than or equal to the preset value. (The preset value is entered as part of the timer instruction.)You access both of these variables by using the timer address (T + timer number). Format: T[timer number] T24*

  • Accessing the Timer Data*

  • The Counter (C) Memory AreaCounters are devices that count each low-to-high transition event on the counter input(s). The CPU provides two types of counters: one type counts up onlythe other counts both up and down. There are two variables that are associated with a counter:Current value: this 16-bit signed integer stores the accumulated count.Counter bit: this bit turns on (is set to 1) when the current value of the counter is greater than or equal to the preset value. (The preset value is entered as part of the counter instruction.)You access both of these variables by using the counter address (C + counter number).*

  • The Counter (C) Memory AreaAccess to either the counter bit or the current value is dependent on the instruction used: instructions with bit operands access the counter bit, while instructions with word operands access the current value. As shown in next slide, the Normally Open Contact instruction accesses the counter bit, while the Move Word (MOV_W) instruction accesses the current value of the counter.Format: C[counter number] C20*

  • Accessing the Counter Data*

  • The Analog Inputs (AI)The S7-200 converts a real-world, analog value (such as temperature or voltage) into a word-length (16-bit) digital value. You access these values by the area identifier (AI), size of the data (W), and the starting byte address. Since analog inputs are words and always start on even-number bytes (such as 0, 2, or 4), you access them with even-number byte addresses (such as AIW0, AIW2, or AIW4)Analog input values are read-only values.Format: AIW[starting byte address] AIW4*

  • Accessing an Analog InputAccessing an Analog OutputAccessing an Analog InputAccessing an Analog Output*

  • The Analog Outputs (AQ)The S7-200 converts a word-length (16-bit) digital value into a current or voltage, proportional to the digital value (such as for a current or voltage). You write these values by the area identifier (AQ), size of the data (W), and the starting byte address. Since analog outputs are words and always start on even-number bytes (such as 0, 2, or 4), you write them with even-number byte addresses (such as AQW0, AQW2, or AQW4).Your program cannot read the values of the analog outputs.Format: AQW[starting byte address] AQW4*

  • Accessing an Analog InputAccessing an Analog OutputAccessing an Analog InputAccessing an Analog Output*

  • The Accumulators (AC)Accumulators are read/write devices that can be used like memory. For example, you can use accumulators to pass parameters to and from subroutines and to store intermediate values used in a calculation. The CPU provides four 32-bit accumulators (AC0, AC1, AC2, and AC3). The data in the accumulators can be accessed as bytes, words, or double words.Format: AC[accumulator number] AC0*

  • Addressing the Accumulators*

  • The High-Speed Counters (HC)High-speed counters are designed to count events faster than the CPU can scan the events.High-speed counters have a signed, 32-bit integer counting value (or current value). To access the count value for the high-speed counter, you specify the address of the high-speed counter, using the memory type (HC) and the counter number (such as HC0).The current value of the high-speed counter is a read-only value and can be addressed only as a double word (32 bits).Format: HC[high-speed counter number] HC1*

  • Accessing the High-Speed Counter Current Values*

  • Using Constant ValuesYou can use a constant value in many of the S7-200 instructions. Constants can be bytes, words, or double words. The CPU stores all constants as binary numbers, which can then be represented in decimal, hexadecimal, or ASCII formats.Decimal Format: [decimal value]Hexadecimal Format: 16#[hexadecimal value]ASCII Format: [ASCII text]*

  • Using Constant ValuesThe S7-200 CPU does not support data typing or data checking (such as specifying that the constant is stored as an integer, a signed integer, or a double integer). For example, an Add instruction can use the value in VW100 as a signed integer value, while an Exclusive Or instruction can use the same value in VW100 as an unsigned binary value.Examples:Decimal constant: 20047Hexadecimal constant: 16#4E4FASCII constant: Text goes between single quotes.*

  • Indirect Addressing of the CPU Memory Areas*TBD

  • Valid Ranges for the S7-200 CPUs *

    Description212214215216User program size512 words2 kwords4 kwords4 kwordsUser data size512 words2 kwords2.5 kwords2.5 kwordsProcess Image Input RegisterI0.0 I7.7Process Image Output RegisterQ0.0 Q0.7Analog Inputs (Read Only)AIW0 AIW30Analog Outputs (write only)AQW0 AQW30Variable memory (V) Permanent area (max)V0.0 to V1023.7V0.0 to V199.7V0.0 to V4095.7V0.0 to V1023.7V0.0 to V5119.7V0.0 to V5119.7Bit Memory (M) Permanent area (max)M0.0 to M15.7MB0 to MB13M0.0 to M31.7MB0 to MB13Special Memory (SM) Real MemorySM0.0 to SM45.7SM0.0 to SM29.7SM0.0 to SM85.7SM0.0 to SM29.7SM0.0 to SM194.7SM0.0 to SM29.7

  • Valid Ranges for the S7-200 CPUs *

    Description212214215216Timers64 (T0 to T63)128 (T0 to T127)256 (T0 to T255)CountersC0 to C63C0 to C127C0 to C255High Speed CounterHC0HC0 to HC2Accumulator registersAC0 to AC3Jumps / Labels0 to 630 to 255Call / Subroutines0 to 150 to 63Interrupt Routines0 to 310 to 127Interrupt events0, 1, 8 to 10,120 to 200 to 230 to 26PID loopsNot supported0 to 7Ports00 and 1

  • S7-200 CPU Operand Ranges*

    Access Method212214215216Bit access(byte.bit)VIQMSMTCS0.0 to 1023.70.0 to 7.70.0 to 7.70.0 to 15.70.0 to 45.70 to 630 to 630.0 to 7.7VIQMSMTCS0.0 to 4095.70.0 to 7.70.0 to 7.70.0 to 31.70.0 to 85.70 to 1270 to 1270.0 to 15.7VIQMSMTCS0.0 to 5119.70.0 to 7.70.0 to 7.70.0 to 31.70.0 to 194.70 to 2550 to 2550.0 to 31.7VIQMSMTCS0.0 to 5119.70.0 to 7.70.0 to 7.70.0 to 31.70.0 to 194.70 to 2550 to 2550.0 to 31.7Byte accessVBIBQBMBSMBACSB0 to 10230 to 70 to 70 to 150 to 450 to 30 to 7VBIBQBMBSMBACSB0 to 40950 to 70 to 70 to 310 to 850 to 30 to 15VBIBQBMBSMBACSB0 to 51190 to 70 to 70 to 310 to 1940 to 30 to 31VBIBQBMBSMBACSB0 to 51190 to 70 to 70 to 310 to 1940 to 30 to 31ConstantConstantConstantConstant

  • S7-200 CPU Operand Ranges*

    Access Method212214215216Word accessVWTCIWQWMWSMWACAIWAQWSW0 to 10220 to 630 to 630 to 60 to 60 to 140 to 440 to 30 to 300 to 300 to 6VWTCIWQWMWSMWACAIWAQWSW0 to 40940 to 1270 to 1270 to 60 to 60 to 300 to 840 to 30 to 300 to 300 to 14VWTCIWQWMWSMWACAIWAQWSW0 to 51180 to 2550 to 2550 to 60 to 60 to 300 to 1930 to 30 to 300 to 300 to 30VWTCIWQWMWSMWACAIWAQWSW0 to 51180 to 2550 to 2550 to 60 to 60 to 300 to 1930 to 30 to 300 to 300 to 30ConstantConstantConstantConstantDouble wordaccessVDIDQDMDSMDACHCSD0 to 10200 to 40 to 40 to 120 to 420 to 300 to 4VDIDQDMDSMDACHCSD0 to 40920 to 40 to 40 to 280 to 820 to 30 to 20 to 12VDIDQDMDSMDACHCSD0 to 51160 to 40 to 40 to 280 to 1910 to 30 to 20 to 28VDIDQDMDSMDACHCSD0 to 51160 to 40 to 40 to 280 to 1910 to 30 to 20 to 28ConstantConstantConstantConstant

  • Equivalent Ladder/Logic Diagrams*

  • Equivalent Ladder/Logic Diagrams*

  • Equivalent Ladder/Logic DiagramsHomework: NOR, XNOR*

    In a traditional industrial control system, all control devices are wired directly to each other according to how the system is supposed to operate. In a PLC system, however, the PLC replaces the wiring between the devices. Thus, instead of being wired directly to eachother, all equipment is wired to the PLC. Then, the control program inside the PLC provides the wiring connection between the devices.The control program is the computer program stored in the PLCs memory that tells the PLC whats supposed to be going on in the system. The use of a PLC to provide the wiring connections between system devices is called softwiring.*The control program is the computer program stored in the PLCs memory that tells the PLC whats supposed to be going on in the system. The use of a PLC to provide the wiring connections between system devices is called softwiring.****The softwiring advantage provided by programmable controllers is tremendous. In fact, it is one of the most important features of PLCs.

    **The central processing unit (CPU) is the part of a programmable controller that retrieves, decodes, stores, and processes information.It also executes the control program stored in the PLCs memory. In essence, the CPU is the brains of a programmable controller. It functions much the same way the CPU of a regular computer does, except that it uses special instructions and coding to perform its functions.The CPU has three parts: the processor the memory system the power supplyThe processor is the section of the CPU that codes, decodes, and computes data. The memory system is the section of the CPU that stores both the control program and data from the equipment connectedto the PLC. The power supply is the section that provides the PLC with the voltage and current it needs to operate.*The input/output (I/O) system is the section of a PLC to which all of the field devices are connected. If the CPU can be thought of as the brains of a PLC, then the I/O system can be thought of as the arms and legs. The I/O system is what actually physically carries out the control commands from the program stored in the PLCs memory.The I/O system consists of two main parts: the rack I/O modules

    The rack is an enclosure with slots in it that is connected to the CPU.I/O modules are devices with connection terminals to which the field devices are wired. Together, the rack and the I/O modules form the interface between the field devices and the PLC. When set up properly, each I/O module is both securely wired to its corresponding field devices and securely installed in a slot in the rack. This creates the physical connection between the field equipment and the PLC. In some small PLCs, the rack and the I/O modules come prepackaged as one unit.*All of the field devices connected to a PLC can be classified in one of two categories: inputs outputsInputs are devices that supply a signal/data to a PLC. Typical examples of inputs are push buttons, switches, and measurement devices.Basically, an input device tells the PLC, Hey, somethings happening out hereyou need to check this out to see how it affects the control program.Outputs are devices that await a signal/data from the PLC to performtheir control functions. Lights, horns, motors, and valves are all goodexamples of output devices. These devices stay put, minding theirown business, until the PLC says, You need to turn on now orYoud better open up your valve a little more, etc.*Outputs are devices that await a signal/data from the PLC to perform their control functions. Lights, horns, motors, and valves are all good examples of output devices. These devices stay put, minding their own business, until the PLC says, You need to turn on now or Youd better open up your valve a little more, etc.*An overhead light fixture and its corresponding wall switch are good examples of everyday inputs and outputs. The wall switch is an input it provides a signal for the light to turn on. The overhead light is an output - it waits until the switch sends a signal before it turns on.Lets pretend that you have a souped-up overhead light/switch circuit that contains a PLC. In this situation, both the switch and the light will be wired to the PLC instead of to each other. Thus, when you turn on the switch, the switch will send its turn on signal to the PLC instead of to the light. The PLC will then relay this signal to the light, which will then turn on.*There are two basic types of input and output devices: discrete analogDiscrete devices are inputs and outputs that have only two states: on and off. As a result, they send/receive simple signals to/from a PLC. These signals consist of only 1s and 0s. A 1 means that the device is on and a 0 means that the device is off.Analog devices are inputs and outputs that can have an infinite number of states. These devices can not only be on and off, but they can also be barely on, almost totally on, not quite off, etc. These devices send/receive complex signals to/from a PLC. Their communications consist of a variety of signals, not just 1s and 0s.

    Examples

    The overhead light and switch we just discussed are both examples of discrete devices. The switch can only be either totally on or totally off at any given time. The same is true for the light.A thermometer and a control valve are examples of the other type of I/O devices-analog. A thermometer is an analog input device because it provides data that can have an infinite number of states. Temperature isnt just hot or cold. It can have a variety of states, including warm, cool, moderate, etc. A control valve is an analog output for the same reason. It can be totally on or totally off, but it can also have an infinite number of settings between these two states.*Because different input and output devices send different kinds of signals, they sometimes have a hard time communicating with the PLC.While PLCs are powerful devices, they cant always speak the language of every device connected to them. Thats where the I/O modules we talked about earlier come in. The modules act as translators between the field devices and the PLC. They ensure that the PLC and the field devices all get the information they need in a language that they can understand.*The control program is a software program in the PLCs memory. Its what puts the control in a programmable controller.The user or the system designer is usually the one who develops the control program. The control program is made up of things called instructions. There are all different kinds of instructions and they can make a PLC do just about anything (add and subtract data, time and count events, compare information, etc.). All you have to do is program the instructionsin the proper order and make sure that they are telling the right devices what to do and voila!you have a PLC-controlled system.And remember, changing the system is a snap. If you want the system to act differently, just change the instructions in the control program.Different PLCs offer different kinds of instructions. Thats part of what makes each type of PLC unique. However, all PLCs use two basic types of instructions: contacts coils*Contacts are instructions that refer to the input conditions to the control programthat is, to the information supplied by the input field devices. Each contact in the control program monitors a certain field device. The contact waits for the input to do something in particular (e.g., turn on, turn off, etc.this all depends on what type of contact it is). Then, the contact tells the PLCs control program, The input device just did what its supposed to do. Youd better check to see if this is supposed to affect any of the output devices.

    *Coils are instructions that refer to the outputs of the control program that is, to what each particular output device is supposed to do in the system. Like a contact, each coil also monitors a certain field device. However, unlike a contact, which monitors the field device and then tells the PLC what to do, a coil monitors the PLC control program and then tells the field device what to do.

    It tells the output device, Hey, the PLC just told me that the switch turned on. That means that youre supposed to turn on now. So lets go! *Lets talk again about that souped-up switching circuit, in which a wall switch and an overhead light are connected to a PLC. Lets say that turning on the switch is supposed to turn on the light. In this situation, the PLCs control program would contain a contact that examines the input device - the wall switch - for an on condition and a coil that references the light. When the switch turns on, the contact will energize, meaning that it will tell the PLC that the condition its been looking for has happened. The PLC will relay this information to the coil instruction by energizing it. This will let the coil know that it needs to tell its referenced output - the light - to turn on.*The S7-200 series is a line of micro-programmable logic controllers (Micro PLCs) that can control a variety of automation applications. Figure shows an S7-200 Micro PLC. The compact design, expandability, low cost, and powerful instruction set of the S7-200 Micro PLC make a perfect solution for controlling small applications. In addition, the wide variety of CPU sizes and voltages provides you with the flexibility you need to solve your automation problems.

    *Figure shows the basic S7-200 Micro PLC system, which includes - an S7-200 CPU module, - a personal computer, - STEP 7-Micro/WIN programming software, and - a communications cable.

    In order to use a personal computer (PC), you must have one of the following sets of equipment: A PC/PPI cable A communications processor (CP) card and multipoint interface (MPI) cable A multipoint interface (MPI) card. A communications cable is provided with the MPI card.

    **The series of tasks executed during the scan cycle is dependent upon the operating mode of the CPU. The S7-200 CPU has two modes of operation, STOP mode and RUN mode. With respect to the scan cycle, the main difference between STOP and RUN mode is that in RUN mode your program is executed, and in STOP mode your program is not executed.*Each scan cycle begins by reading the current value of the digital inputs and then writing these values to the process-image input register. The CPU reserves the process-image input register in increments of eight bits (one byte). If the CPU or expansion module does not provide a physical input point for each bit of the reserved byte, you cannot reallocate these bits to subsequent modules in the I/O chain or use them in your program. The CPU resets these unused inputs to zero in the image register at the beginning of every scan. However, if your CPU module can accommodate several expansion modules and you are not using this I/O capacity (have not installed the expansion modules), you can use the unused expansion input bits as additional memory bits.The CPU does not automatically update analog inputs as part of the scan cycle and does not maintain an analog input image register. You must access the analog inputs directly from your program.********Figure shows an example of accessing a bit (which is also called byte.bit addressing). In this example, the memory area and byte address (I=input, and 3=byte 3) are followed by a period (.) to separate the bit address (bit 4).**Real (or floating-point) numbers are represented as 32-bit, single-precision numbers, whose format is described in the ANSI/IEEE 754-1985 standard. Real number values are accessed in double-word lengths.*For more information about the SM bits, see Appendix D of the S7-200 Manual*For more information about the SM bits, see Appendix D of the S7-200 Manual*Access to either the timer bit or the current value is dependent on the instruction used: instructions with bit operands access the timer bit, while instructions with word operands access the current value.

    As shown in next slide, the Normally Open Contact instruction accesses the timer bit, while the Move Word (MOV_W) instruction accesses the current value of the timer.

    *To access the accumulator as bytes or words you use the least significant 8 or 16 bits of the value that is stored in the accumulator. To access the accumulator as a double word, you use all 32 bits.The size of the data being accessed is determined by the instruction that is used to access the accumulator.

    ***