engi-6855 industrial control and instrumentation ...masek/6855_labs_2017.pdf · industrial control...

43

Upload: phamdang

Post on 06-Apr-2018

227 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

ENGI-6855

Industrial Control and Instrumentation

LABORATORY ASSIGNMENTS

updated on

November 21, 2017

1 LABORATORY ASSIGNMENT

1.1 Introduction

This Lab Manual covers the fundamental principles of industrial control froma practical perspective using Programmable Logic Devices. Open sourcesoftware and low cost hardware is being used. The motivation is to enableprojects without a large �nancial sacri�ce which is typical for small startupsand hobby projects. The tools are however scalable and �t projects of anysize and complexity.

1.2 PLC's

Programmable Logic Controllers (PLC's) are embedded computers or mi-crocontrollers that execute a control code repeatedly, in a cycle of few mil-liseconds to mimic the real time nature of previously hard wired relay logicbased controllers. Their development started in late 60's and early 70's withthe advent of digital hardware and their rapid and widespread use promptedan international cooperation in standardizing the programming interface.

The majority of control applications require a real time response whichis natural in hard wired relay based systems not considering the contactpicking/dropping transient time. Since a digital hardware in a PLC processesthe logic instructions sequentially it is necessary to well understand thisprocess and the timing parameters.

1.2.1 TASK [10%]

Draw a �owchart and describe the operation cycle of a PLC.

1

Page 2: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

1.3 History of ON-OFF control

The �rst electrical control element was a mechanical switch that makes orbreaks an electric circuit. Many di�erent types of switches were developedover years such as toggle switch, push button, position limit switch, thermalswitch (bimetal), pressure switch, level switch etc. Many control applicationsrequired an operator to �ip the switches to execute the logic, both combi-national and sequential. Oersted and Faraday's work on electromagnetismin early 1800's started a new era of control systems using an electromagnetas a 'memory element' as well as power level shifter and multiplexer, theelectromagnetic relay.

The relay in an element that can switch kilowatts of power while only con-suming watts or less, the feature before realized by hand operated switchesonly. Three or more parallel switch contactors can be integrated in one relaymaking it convenient for three phase applications or sequential logic. Electro-magnetic relays have not become obsolete by the advent of PLC's, however,these days they are rarely used in implementing the logic function. Moreoften they are found in PLC output modules to switch power to actuators.

Relays are electromechanical devices that have no inde�nite life span andcan only last a number of switch cycles. Contacts also deteriorate by timewhich can make the control system less reliable. This is the area wherePLC's make a large di�erence besides ease of control algorithm developmentin software and its maintenance.

1.3.1 TASK [10%]

Design a circuit for an automatic light bulb changer in ocean light beacon.

1.3.2 TASK [10%]

Describe at least two methods of suppressing relay contact arcing.

1.4 Relay logic

One of the standard PLC programming methods is Ladder Logic which isdocumented in Ladder Diagrams. Ladder logic is in fact a close represen-tation of Relay Logic which was used for a century. Relay logic can bedocumented by two slightly di�erent schematic depictions:

2

Page 3: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

1.4.1 Attached schematics

keeps the relays and their contacts attached together. This way it is easierto troubleshoot an existing control circuit or assemble a new one as thisschematics closely represents the physical circuit layout. This type of re-lay logic schematics is on the other hand more di�cult to understand thefunction.

1.4.2 Detached schematics

as name suggests detaches the contacts from the corresponding relay coilsto make the schematics more readable and the control function easy to un-derstand. The wire routing complexity can also be signi�cantly reduced indetached schematics.

1.4.3 START-STOP Control

Historically, the most common and still prevailing relay based control appli-cation is START-STOP operation of an equipment. It is also called latching,or seal-in relay circuit.

1.4.4 TASK [10%]

Draw both attached and detached schematics of START-STOP control usinga DPST relay. Which of the two is closely representing the PLC ladderdiagram?

1.5 Switches

Switches provided the simplest control since the discovery of electricity, bymaking or braking an electric circuit. For example a momentary switch orpush button was used in relaying a message by a Morse code as a seriesof dots and dashes. This kind of switch is spring loaded so when released,the switch moves into its normal state. There are two types of momentaryswitches, normally open [NO] and normally closed [NC]. The advantage ofusing a PLC in control is that both switches can be used since their type canbe easily changed in software by negation, i.e. a negated NO switch turnsinto s NC switch (NOT[NO]=[NC]).

A momentary switch can reach two possible states: a NO switch is closedwhen acted on (pushed) but becomes open as soon as it is not acted on(released). The momentary switch design can include only one switch (single

3

Page 4: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

pole [SP]) or a set of multiple switches (e.g. double pole [DP], triple pole[3P], etc) that are galvanically isolated but act simultaneously in parallel.

The momentary switch can also combine both NO and NC contacts to-gether. Such a switch is called double throw [DT] and can have the thecontacts that correspond to NO and NC switch apart or tied together whichis more common as shown in the �gure below. How many states can a DTswitch produce? (three when considering the transient state).

+----[/ ]-----o NC

o-----|

+----[ ]-----o NO

|

+-----o___|___o-----o NC

o--|

+-----o o-----o NO

The other common type is a toggle switch with a latching function(~memory). This switch can be found in every room to turn the light onand o�. There are two stable states and a transient state in between. Thepossible designs include a rocker, slider or rotary knob construction, thenspring loaded or friction based to remember (maintain) the last state whenacted on.

Specialized switches can in addition provide a coded function such ashexadecimal switch used in digital circuits, or three-way/four-way switchesused in long corridors or large rooms with multiple entrances.

Multiple switches or array of switches can also be controlled as RadioButtons. Interlockable switches as well as relays/contactors are needed inFWD/REV/STOP motor control in order to prevent a short circuit duringthe transition between states.

Three phase powered systems require at least a triple pole control el-ements such as 3PDT switch. A special switch is used to start an asyn-chronous motor in WYE-DELTA manner.

1.5.1 TASK [10%]

Draw a schematic of light control in a room with three wall switches.

4

Page 5: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

1.5.2 TASK [10%]

Draw a schematic of a three phase motor control FWD/REV using the in-terlocked 3P switch with latching function.

. ___

X o-- o----[.]----o o----[.]----o U o-----/ \

Y o-- o----[.]----o o----[.]----o V o----| M |

Z o-- o----[.]----o o----[.]----o W o-----\___/

N o-- . ________. |

G O-- ._______---o--- -----

/ \ ---

FWD /___\ REV -

1.5.3 TASK [10%]

Take a transparency foil and cut out a circle of a CD size. Pin its centreto a cardboard. Your task is to design a circular WYE-DELTA switch.First draw the location of contacts (brushes) on the cardboard; there arethree line supply brushes (X,Y,Z) and six motor terminal brushes (U1/U2,V1/V2, W1/W2). Place traces on the foil considering the movable foil toturn in 60deg increments, i.e. 0deg ~STOP, 60deg ~WYE, 120deg ~DELTA.What did you learn by designing this switch?

1.6 Boolean Logic

Switches can be used to implement a simple Boolean logic (AND, OR, XOR,. . . ). There are also switches that are not designed to be controlled by a hu-man operator but a process parameter instead such as temperature, pressure,level, �ow, position, etc. A special category is overcurrent protection thatcan �ll a separate text on its own. These switches (sensors) can be cas-caded so any of them can trip the equipment such as in situation of extremetemperature (temp), loss of coolant or oil (level), or limit position reached.

1.6.1 TASK [10%]

Design a DP3T switch controlled reversible DC motor used in elevating ahospital bed. The system includes a car battery 12V, DC motor, DPDTswitch, and two SPDT limit switches.

5

Page 6: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

1.7 OpenPLC Server & Arduino

OpenPLC program is intended to emulate a PLC on a PC. This virtualPLC uses the OpenPLC Software Stack to execute IEC 61131-3 programsand reply to MODBUS/TCP requests. Programs can be created using thePLCopen editor and then uploaded to this virtual PLC.

The OpenPLC has di�erent hardware layers to support physical devices.For instance, there is a hardware layer for the Arduino, which makes theOpenPLC controls its IO pins.

1.7.1 TASK [10%]

1. Open Arduino IDE and test the connection by uploading a blink testfrom provided examples.

2. Upload the �rmware 'OpenPLC_UNO_fw.ino' and note the pinoutcon�guration in the program's header.

3. In cygwin, start OpenPLC server; the server will be created on port8080. 'cd ~/OpenPLC_v2' and 'node server_win.js'

4. Navigate to 'PCLopen_Editor' folder in C: directory and open the pro-gram by running 'PCLopen Editor.lnk'. Then open 'Hello_World.xml'and generate ST program 'Hello_World.st'

5. Open your favourite web browser and navigate to localhost:8080, andupload 'Hello_World.st'

6. Connect a NO push button to pin #2 and LED to #7. Use the on-board 5VDC and GND and do not forget to apply a pull down 1kresistor at pin #2 to condition the case when the switch is open. Aswell, do not forget to apply a current limiting resistor of at least 330ohms to the LED circuit.

7. Demonstrate to your TA. Then change the ST program to 5sec(5000ms) TOFF delay and demonstrate to your TA.

8. Analyze the ST �le and provide some explanation of the code.

1.8 Conclude your report [10%]

6

Page 7: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

2 LABORATORY ASSIGNMENT

2.1 Introduction

In this lab, you will expand the knowledge and skills gained from the pre-vious lab, in particular, integrating more inputs using both push buttonsand toggle switches, Ladder Diagram programming, more complex Booleanlogic, and latching (seal-in) operation.

2.2 Hardware

Arduino Uno 1USB cable 1NO push button 2LED 1SPDT toggle switch 31/4W resistors

2.3 Room Light Control

In one of the previous tasks, you designed and provided a schematic of a hardwired light control using three wall switches. This time, we will program ourPLC to perform the same function.

2.3.1 TASK [10%]

Wire a single toggle switch to control the LED without using Arduino/PLC.Note you do not need to use pull down/up resistors but you still need acurrent limiting resistor for the LED (~330 ohms)

Provide schematics of the circuit.

2.3.2 TASK [10%]

Wire a pair of toggle switches to control the LED without using Ar-duino/PLC. This simulates a room light control with two wall switches.

Provide schematics of the circuit.DEMONSTRATE to your TA!

2.3.3 TASK [10%]

Interface a single toggle switch to Arduino and control the LED. Note you donot need to use a pull down resistor as you did in the case of NO push button;

7

Page 8: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

simply connect NO contact to +5V and NC contact to ground reference.Provide the interface schematics and the Ladder Diagram from the

PLCopen Editor.

2.3.4 TASK [10%]

Interface two toggle switches and control the LED to simulate a room lightcontrol with two wall switches.

Provide the interface schematics and the Ladder Diagram from thePLCopen Editor.

2.3.5 TASK [10%]

Interface three toggle switches and control the LED to simulate a room lightcontrol with three wall switches.

Provide the interface schematics and the Ladder Diagram from thePLCopen Editor.

Also provide a truth table of three inputs and one output.DEMONSTRATE to your TA!

2.4 Boolean Logic

A simple combinational logic can be implemented using wiring the inputswitches (sensors) a certain way. Parallel combination represents OR func-tion whereas Series combination represents AND function.

2.4.1 TASK [10%]

Wire two NO push buttons in AND and OR combination to control theLED. DO NOT use the Arduino/PLC!

Provide schematics of both circuits and a truth table for both.

2.4.2 TASK [10%]

Now interface the two push buttons and the LED to your Arduino. Replicatethe AND and OR function using the Ladder Diagram programming. Noteyou need to use the pull down resistors this time!

Provide schematics of the I/O interface to the board, the LD program foreach function and the truth tables. Do they match the above truth tables?

8

Page 9: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

2.4.3 TASK [10%]

Reprogram the previous task to implement the following functions:NOT(X) AND YNOT(X) OR YProvide the LD program for both and the corresponding truth tables.

What will need to change if we use a NC push button for X if we want topreserve the function?

2.4.4 TASK [10%]

Reprogram to implement the following functions:NOT( NOT(X) AND NOT(Y))NOT( NOT(X) OR NOT(Y))Provide the LD program for both and the corresponding truth tables.

Compare the truth tables with ones for AND and OR function, comment onany similarities.

2.4.5 TASK [10%]

Finally program a latching function that follows this Boolean equation:OUT = (OUT OR X) AND NOT(Y)Demonstrate to your TA's.

2.5 Conclude your report

9

Page 10: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

3 LABORATORY ASSIGNMENT

3.1 Introduction

This lab covers the fundamentals of timers and state based design. Timersare frequently used in process industries as well as objects of daily use suchas ovens, washers, dryers etc. We will use two timers, ON Delay (TON) andOFF Delay (TOF). At the end, the basic latching circuit will be made 'childproof' to prevent accidental startup of an equipment by a 'curious monkey'.

3.2 Hardware

Arduino Uno 1USB cable 1NO push button 2LED 11/4W resistors

3.3 History of a Timer Switch

Combining a clock with a switch can enable a large variety of time controlledsystems. Lighthouses often used a long vertical well to enable the weight runmirror spinner, based on the escapement mechanism of a clock. When theweight reached the bottom, a switch was thrown to indicate the lighthousekeeper to windup the system again.

Combining a regular clock with a switch was revolutionary but not ofmuch use until an automatically windup clocks were introduced. The me-chanical clock based timers operated with minimum delays of several seconds,were bulky and some did not last long due to mechanical wear.

Active components such as op amps and semiconductors in general en-abled timers to realize a range of delays from sub-second to hours or daysin one tiny device. PLC's implement the delays in software and are moreversatile in programming complex timing algorithms.

3.4 On Delay (TON) timer:

On-delay timer will wait after being energized before closing its NO contacts.When the timer is de-energized, the contacts return to their normal state.

10

Page 11: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

3.4.1 TASK [10%]

Interface a single push button to Arduino PLC with LED as output andintroduce a TON timer preset to 2 seconds. Provide the ladder diagram.

� Push the button for 5 seconds and then release. Use oscilloscope toacquire input-output timing diagram (single shot mode). Attach tothe report.

� Push and quick release the button (< 1 sec). Use oscilloscope to acquireinput-output timing diagram and attach to the report.

3.5 O� Delay (TOF) timer

O�-delay timer provides a time delay when de-energized. For example, a 5sec o�-delay timer would close its NO contacts immediately when energized,however after being de-energized, the NO contacts would remain closed for5 more seconds before returning to their normal state.

3.5.1 TASK [10%]

Change the timer to TOF preset to 3 seconds, provide LD program.

� Push and quick release the button (< 1 sec) and acquire the timingdiagram. Attach scope screen.

� Push-release-push the button in a rapid sequence (< 1 sec) and acquirethe timing diagram. Attach scope screen.

3.6 Automatic Irrigation System

Two timers can be cascaded in a loop to implement one period with outputturned ON and another period with output turned OFF. For example, agreenhouse can be automatically irrigated for 2 minutes every hour. Thereare two ways to tackle this problem: one can preset the two timers to 2minand 60min, or to 2min and 58min.

3.6.1 TASK [10%]

Design an automatic irrigation system that turns on for 2 seconds and stayso� for 5 seconds. Preset one timer to 2 seconds and the other to 5 seconds.Provide LD and a scope log.

11

Page 12: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

3.6.2 TASK [10%]

Re-design the previous system by presetting one timer to 2 seconds and theother to 7 seconds. Provide LD and a scope log.

3.7 Safe Operation of an Equipment I.

Many manufacturing processes can be dangerous to an operator and caremust be taken when designing the control of such systems. For example,a hydraulic press system prevents accidental hand injury by 'locking' bothhands on two separate switches in an enclosed well. Additional light curtaincan also be installed.

Often the two switches must be acted on simultaneously which requiresa timer as no two physical systems can occur truly at the same time. Thereis always one switch that is thrown earlier than the other. Therefore, thesimultaneous action here is understood as the two events occurring within aspeci�c time frame, say 200 milliseconds.

3.7.1 TASK [10%]

Design a START-STOP control of a press equipment using two push but-tons (momentary switches). The equipment starts to operate only when thetwo switches are pressed 'simultaneously' and keeps running as long as theswitches are held pressed, i.e. as soon as one switch is released the equipmentstops immediately.

Design the problem using a State Diagram. The two switches are yourinputs, and the motor ON/OFF your output. Describe your states and alltransitions.

3.7.2 TASK [10%]

Convert the state diagram above into state equations.

3.7.3 TASK [10%]

Program the control problem by using the state equations above. List LD.DEMONSTRATE the function to TA's.

12

Page 13: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

3.8 Safe Operation of an Equipment II.

There are many other ways how to operate an equipment safely. Even anexisting system that uses only two switches, one for starting and the otherone for stopping the equipment, can be made more secure by programming atime-sequential code on the START switch. Only the START operation canbe adapted this way! NEVER introduce a code for the STOP operation!!!

3.8.1 TASK [10%]

Design a START-STOP control of a table saw using two push buttons (mo-mentary switches). To start the operation, press START twice in a rapidsequence (<0.5s). To turn o� the saw, press STOP.

Design the problem using a State Diagram. The two switches are yourinputs, and the motor ON/OFF your output. Describe your states and alltransitions.

3.8.2 TASK [10%]

Convert the state diagram above into state equations.

3.8.3 TASK [10%]

Program the control problem by using the state equations above. List LD.DEMONSTRATE the function to TA's.

3.9 Conclude your report

13

Page 14: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

4 LABORATORY ASSIGNMENT

4.1 Introduction

The previous lab introduced the concepts of state based design which wasthen implemented in ladder logic. There is a better way to implement thestate diagrams in PLC software by using Sequential Function Charts (SFC).SFCs mimic closely state diagrams and are thus much easier to debug andmaintain. This is the main objective of this lab to practice SFCs and applythem to the problems from the last lab.

4.2 Hardware

Arduino Uno 1USB cable 1NO push button 2LED 11/4W resistors

4.3 SFC Introduction

An SFC consist of Steps (including the initial step) represented by boxesand transitions represented by links between the steps. The transition linkmay bear a crossbar symbol that represents conditions that have to be metto advance from one step to another.

4.3.1 TASK [10%] Light Control

Program Arduino PLC to control a single light (LED) by a single switch(NO push button). Make sure the con�guration is properly set; refer to thetwo screen captures below.

4.3.2 TASK [10%] Timed Light Control

Re-design the previous problem to keep the light ON for additional 2 sec-onds after the push button is released. There is a number of ways one canintroduce timers to SFCs. We haven't learned about combining SFC andLD yet, so we will use a small trick today.

Refer to the screen capture below. Introduce a new variable T1 anddeclare it as TIME as there is no TOF/TON available in the pull down menu.(In Ladder Diagram, the proper declaration of timers was automaticallyinserted when dragging the timer box on the programming canvas.)

14

Page 15: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 1: SFC for Light Control

Modify the inline code in Step1 and the transition from Step1 to Step0as shown in the image below. Compile to ST �le but DO NOT RUN YET!You have to edit the ST �le by changing TIME declaration to TOF. Thenrun the code and DEMONSTRATE to TA's.

VAR

switch AT %IX0.0 : BOOL;

led AT %QX0.0 : BOOL;

END_VAR

VAR

T1 : TOF;

END_VAR

4.4 Safe Operation of an Equipment I.

4.4.1 TASK [40%]

Re-design the START-STOP control of a press equipment using the twopush buttons (momentary switches). The equipment starts to operate onlywhen the two switches are pressed 'simultaneously' and keeps running aslong as the switches are held pressed, i.e. as soon as one switch is releasedthe equipment stops immediately. To implement the simultaneous function,use a timer preset to 500ms.

15

Page 16: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 2: Con�g for Light Control

Redraw your state diagram and implement it in SFC. DEMONSTRATEthe function to TA's and include your SFC in the report.

4.5 Safe Operation of an Equipment II.

4.5.1 TASK [40%]

Re-design the START-STOP control of a table saw using two push buttons,i.e. START and STOP momentary switches. To start the operation, pressSTART twice in a rapid sequence (<0.5s). To turn o� the saw, press STOP.

Redraw your state diagram and implement it in SFC. DEMONSTRATEthe function to TA's and include your SFC in the report.

4.6 Conclude your report

16

Page 17: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 3: SFC for Timed Light Control

5 LABORATORY ASSIGNMENT

5.1 Introduction

This lab starts using a conveyor belt system that can simulate many appli-cations such as automatic door or bottle �lling line. You will learn how touse counters and how to generate a sequence of pulses to control a steppermotor.

5.2 Hardware

Arduino Uno 1USB cable 1OTEX Process Model 1power supply 1DB25 LPT cable 1DB25 breakout terminal 1jump-wires N

17

Page 18: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

5.3 Counter - Introduction

There are two standard functions available in LD programming, up-counterand down-counter. The up-counter can be used to signal when a count hasreached a preset value. There are three inputs: CU represents the main pulseinput and only considers its raising edge to advance the counter, R representsthe reset input, and PV stands for preset value (INT). The Q output is sethigh when (CV==PV) and can be actually used to reset the counter itself.The CV is the actual value of the counter (INT). Below declaration showsthe up-counter block input and output data type. The down counter followssimilar principles.

(BOOL:CU, BOOL:R, INT:PV) => (BOOL:Q, INT:CV)

5.3.1 TASK [10%] OTEX Board Test

Test both push buttons and all four LED's on board. Implement the follow-ing program (use a block copy function to speed up your development). DONOT USE THE 'GND' PIN, use #25 pin for ground reference instead!

Figure 4: OTEX board test

Demonstrate to your TA's, they will also record the serial number of your

18

Page 19: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

OTEX board. Explain what function was just implemented.

5.3.2 TASK [10%] Up-Counter Test

Re-design the previous program to set the LED output when the counterreaches number 2 and then resets itself (plus the LED) when the counterreaches number 4.

Figure 5: Up-Counter Use

Modify the program to use the CT.Q output variable directly to resetitself. List the program.

5.3.3 TASK [20%] LEDs cycling

Alter the previous program to cycle the four LEDs in clock wise directionaccording to the listing below.

How would you modify the program to change the direction to counter-clockwise?

19

Page 20: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

5.3.4 TASK [20%] Timer - Counter Combination 1

Modify the previous program to cycle the four LEDs in clock wise directionevery 0.1 second. Note the timer resetting is using an intermediate variablewhich is updated at the end of program! Provide scope trace for two LED's.

5.3.5 TASK [20%] Timer - Counter Combination 2

Extend the program so it latches the LED cycling in CW direction whenyellow PB is acted on and in CCW direction when red PB is acted on.Provide the program and demonstrate to TA's.

5.3.6 TASK [20%] Timer - Counter Combination 3

Finally modify the above program to rotate the LED's in the following fash-ion: 1, 1-2, 2, 2-3, 3, 3-4, 4, 4-1 and so on. Provide the program anddemonstrate to TA's.

5.4 Conclude your report

20

Page 21: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

6 LABORATORY ASSIGNMENT

6.1 Introduction

This lab continues in the direction set last week and employs again theconveyor belt system. This time, a complete process simulating an automaticdoor will be developed. You will program stepper motor and photoelectriclimit sensors (switches).

6.2 Hardware

Arduino Uno 1USB cable 1OTEX Process Model 1power supply 1DB25 LPT cable 1DB25 breakout terminal 1jump-wires N

6.3 Stepper Motor

Please review the concept of driving a two phase stepper motor in unipolarand bipolar version. Note there are two possible ways: full stepping and halfstepping.

6.3.1 TASK [10%] Stepper Motor Control - Full Step Mode

In Hardware, make these connections before you start programming:

Arduino Parallel Port terminals function

#7 #2 stepper#8 #4 stepper#12 #3 stepper#13 #5 stepperGND #25 GND#2 #10 push button#3 #11 push button#4 #12 limit sensor#5 #13 limit sensor

Upload 'stepper_full.xml' and test the ST code on your board. Youshould have the motor running and the belt moving. Make sure the outputsare con�gured the way shown in the table below:

21

Page 22: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

A1 local bool %QX0.0A2 local bool %QX0.1A3 local bool %QX0.2A4 local bool %QX0.3

Analyze the code and draw the timing diagram for four stepper lines.

6.3.2 TASK [10%] Stepper Motor Control - Half Step Mode

Upload 'stepper_half.xml' and test the ST code on your board. You shouldhave the motor running and the belt moving.

Analyze the code and draw the timing diagram for four stepper lines.Discuss the di�erence between full step and half step control.

6.3.3 TASK [20%] Reversible Mode

Select the stepper mode you �nd more e�cient and modify its programto allow Clockwise and Counter Clockwise direction. Use one of the pushbuttons to move in CW direction and the other to move in CCW direction.Demonstrate to your TA's, list the code.

6.4 Photoelectric Sensor

6.4.1 TASK [20%] Oscillating Belt

Program an application of �at bed grinder where the workpiece moves left-right constantly. Position the black mark on the belt in between the twolimit sensors and move the mark in between. Demonstrate to your TA's.

6.4.2 TASK [40%] Automatic Door Control

Program a control system to operate a shop sliding door using the belt-conveyor system. Here is the description:

� To open the sliding door, a �oor mat switch on either side must beacted on; if not engaged, the door will close after 5 seconds.

� The mark on the belt will simulate the door travelling between twolimit sensors.

� After expiration of the time delay, door closing latches until the�CLOSED� position is reached.

22

Page 23: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

� If the �oor mat switch is acted on again while the door closes, doorimmediately opens again.

Provide the code and demonstrate to TA's.

6.5 Conclude your report

23

Page 24: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

7 LABORATORY ASSIGNMENT

7.1 Introduction

This lab follows up the previous two labs and employs again the conveyorbelt system. Last week a complete process simulating an automatic door wasdeveloped in Ladder Diagram. Everyone would agree that the complexity ofthis approach was di�cult to deal with and maintain. Correspondingly theTA's including the instructor were often puzzled by your control algorithm.We can do better than that.

The objective of this lab is two fold. A new programming language,Function Block Diagram (FBD), is practised alongside of prototyping own'subroutines' to hide the complexity into the background. The unifying codewill be in FBD whereas the subroutines will be implemented in SFC thatwill result in a highly 'readable' code.

7.2 Hardware

Arduino Uno 1USB cable 1OTEX Process Model 1power supply 1DB25 LPT cable 1DB25 breakout terminal 1jump-wires N

7.3 FBD

FBD programming approach is nothing new since we already used snippetsin your previous LD programs such as timer blocks, counter blocks, set-reset�ip-�ops etc. Basically the LD's contacts will be represented by (input)variables in FBD, and LD's output coils will be represented by (output)variables.

7.3.1 TASK [10%] FBD programming

In Hardware, make these connections before you start programming:

24

Page 25: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Arduino Parallel Port terminals function

#7 #6 led0#8 #7 led1#12 #8 led2#13 #9 led3GND #25 GND#2 #10 push button#3 #11 push button#4 #12 limit sensor#5 #13 limit sensor

Load the Hello_World.xml into your PLC editor and delete 'My_Program'.Recreate the Program 'My_Program', however, select the FBD language thistime. Note, if you name your program di�erently you have to visit the taskcon�guration and select the right program type under Instances.

Simply connect two local variables linked to inputs %IX0.0 (Yellow PushButton) and %IX0.1 (Red Push Button) to another local variable linked tooutput %QX0.0 (LED0) via AND function.

Run the code and provide the FBD program with the variable declarationtable.

7.3.2 TASK [10%] FBD and SFC programming

Modify the FBD program, however, �rst prototype the subrutine - SFCfunction block. Create a FUNCTION BLOCK that will be implemented inSFC according to the screenshot in 11 and fuse it with the FBD program asshown in 12

While having the FBD program highlighted, create a new 'FunctionBlock' and select the SFC language (large 'plus' sign in the bottom rightcorner).

De�ne all Input, Output and other local variables as needed. In theaction boxes associated with some steps (states), use [S] for setting and [R]for resetting a [Variable].

Test the code and explain what function was implemented. Discuss theadvantage of using the FBD/SFC code with reference to implementing thesame function in FBD language only.

7.3.3 TASK [10%] FBD/SFC programming with a Timer

SFC's transitions often rely on using timers. We did an experiment on safestarting of an equipment in Lab 4 which used the timer concept embedded in

25

Page 26: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

SFC. We will use a slightly di�erent approach this time which is illustratedin two screenshots, 13 and 14.

Test the code and explain what function was implemented. Discuss theadvantage of programming the timer outside of the SFC code with referenceto Lab 4.

7.4 Stepper Motor implementation in SFC

Stepper Motor was the part of your LD code which made your code highlyhard to read and non-transparent in Lab 6. By doing the experiment below,implementing it in SFC will simplify the code signi�cantly. First test iton the LED's, later you will rewire the connections to control the StepperMotor.

7.4.1 TASK [10%] FBD/SFC Stepper Motor Algorithm Test us-ing LED's

We are going to demonstrate the stepper motor sequence programming byblinking the four LED's. Note, in order to demonstrate the sequence slowly,the cycle time is reduced from T#50ms to T#200ms as shown in 15. Theother two screenshots in 16 and 17 illustrate the FBD and SFC code respec-tively.

Test the code and explain what function was implemented. Compare toyour Lab 6 code and discuss the advantages besides the simplicity.

7.5 Application Programming

7.5.1 TASK [50%] FBD/SFC, Timer, Stepper Motor - AutomaticDoor Control

Reprogram the Lab 6 Shop Sliding Door application using the above conceptsof FBD/SFC, Timer and the Stepper Motor Demo.

In Hardware, make these connections before you start programming:

26

Page 27: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Arduino Parallel Port terminals function

#7 #2 stepper#8 #4 stepper#12 #3 stepper#13 #5 stepperGND #25 GND#2 #10 push button#3 #11 push button#4 #12 limit sensor#5 #13 limit sensor

Provide the FBD/SFC code and demonstrate to TA's!

7.6 [10%] Conclude your report

27

Page 28: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

8 LABORATORY ASSIGNMENT

8.1 Introduction

Continuous control is a preferred type of control in many industrial processes.PLC's, although predominantly used in ON-OFF (logic) type control, canalso be used in continuous control and instrumentation. This lab will practicesome concepts from the sensors and actuators domain. We will study athermal process using a power resistor (heater) and IC temperature sensor.

8.2 Hardware

Arduino Uno 1USB cable 110ohm 5W power resistor 1TMP36G temp sensor 1TIP121 NPN power transistor 11k resistor 1jump-wires N

8.3 Analog Output

Analog output is via PWM on Arduino Pins #9 (%QW0.0), #10 (%QW0.1)and #11 (%QW0.2). Note you have to declare the output variable as UINT,unsigned integer (0~65535).

8.3.1 TASK [20%] Analog Output Test

Load the Hello_World.xml into your PLC editor and modify 'My_Program'in the language of your choice to cycle the output variable linked to #9(%QW0.0) through 0~65535.

Create a table showing the mean value (scope derived) and % duty cyclefor each increment by 5000, i.e. 0, 5000, . . . , 65000.

8.4 Analog Input

Analog inputs are located on Arduino Pins #A0~#A5 (%IW0.0~%IW0.5)and accept voltages between 0.0V and 5.0V. The voltage corresponding valueis mapped to UINT variable so that 0.0V corresponds to 0 and 5.0V corre-sponds to 65535.

28

Page 29: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

8.4.1 TASK [20%] Analog Input

Create a program to map input at #A0 (%IW0.0) to the output #9(%QW0.0).

Use power supply and vary the input between 0 and 5.0 volts (DO NOTEXCEED 5.0V!!! TEST THE POWER SUPPLY OUTPUT FIRST BE-FORE CONNECTING TO ARDUINO!)

Create a table for inputs 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 Volts and correspondingPWM duty cycle.

8.5 Thermal Process

A simple thermal process is developed in order to test the control algorithmin the next lab. A temperature sensor (TMP36G) is strapped to a 10 Ohmpower resistor that serves as a heater. The current through the power resistoris controlled by a power transistor TIP 121 (NPN).

8.5.1 TASK [20%] Thermal Process Validation

Consult the lecture notes and wire the NPN transistor in the power resistorcircuit. The resistor will be powered by 5.0VDC having the power supply setto limit the current to 0.3A. As well, limit the BASE current by 1k resistor.

Consult the data sheet for the temperature sensor and power the sensoralso by 5.0VDC.

A) Measure the sensor's output at ambient temperature by a voltmeter.B) Create a program to output 50% duty cycle. From the power supply

display, read the current and voltage.C) Record the temperature sensor's output voltage every 30 seconds until

a steady state temperature is reached. Using the conversion formulae fromthe data sheet, convert the voltages to temperature. Tabulate and plot thedata!

8.6 O�set and Span Adjustment

8.6.1 TASK [30%]

Based on the lecture notes, design O�set and Span (Gain) circuit using anop amp to scale the measured range of temperatures into 1.0~4.0V range.

{Implement the circuit and conduct the Thermal Process Validationagain.}

29

Page 30: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

8.7 [10%] Conclude your report

30

Page 31: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

9 LABORATORY ASSIGNMENT

9.1 Introduction

The thermal process introduced in the previous lab will be controlled contin-uously using Ziegler-Nichols tuning method. As the process is rather slow,the open loop "reaction curve" method is selected instead of the simplerclosed loop method. Finally the control e�ciency is analyzed in terms ofrise time, settling time and overshoot.

9.2 Ziegler Nichols Introduction

The Ziegler-Nichols tuning methods aim for a quarter-amplitude dampingresponse. The open-loop tuning rules use three process characteristics: pro-cess gain, dead time, and time constant. These are determined by doing astep test and analyzing the results. Refer to the �gure 18. More informationcan be found at http://blog.opticontrols.com/archives/477

9.2.1 TASK [40%] Process Variable - Measurement

Validate your temperature sensor o�set&span (O&S) design. Input 750mVand record the output which shall be near 1.0V. Then input 1000mV andrecord the output which shall be near 4.0V. In case of any mismatch, re-tuneyour O&S circuit.

Once the two reference points are reached, calibrate your O&S circuitby using X-Y mode of oscilloscope; input at X and output at Y. Providethe scope trace (calibration curve) and �ll the table below; provide the for-mula for calculating the temperature in degree Celsius and the INTEGERequivalent.

X: TMP36G output (O&S input) [mV] Y: O&S output [V] Temp [C] INTEGER VALUE

7508008509009501000

31

Page 32: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

9.2.2 TASK [40%] Process Gain

Develop a PLC program to drive the heater at 10% PWM and once thetemperature is settled, to change the Manipulated Variable to 50% PWMby pressing a push button (latching circuit). Provide the program printout(FBD, LD, or SFC).

Set the oscilloscope back to X-T and Y-T mode, connect the push buttonsignal to X channel and the O&S circuit output to Y channel.

Once settled at controller output (CO) of 10% PWM initiate the changeto 50% PWM by pressing the push button and wait for the Process Variable(PV) to settle out at a new value. Record the process reaction curve fromthe oscilloscope.

Calculate the process gain (G) as follows:G = {change in PV [INTEGER VALUE / UINT]} / {change in CO

[INTEGER VALUE / UINT]}

9.2.3 TASK [10%] Dead Time

Find the maximum slope on the PV response curve, refer to the �gure 18.This will be at the in�ection point (where the PV stops curving upward andbegins curving downward). Draw a line tangential to the PV response curvethrough the point of in�ection. Extend this line to intersect with the originallevel of the PV (before the step-change in CO). Take note of the time valueat this intersection.

Measure the dead time (td) as follows:td = time between the step-change in CO and the intersection described

above

9.2.4 TASK [10%] Time Constant

Calculate the value of the PV at 63% of its total change. On the PV reactioncurve, �nd the time value at which the PV reaches this level.

Measure the time constant (tau) as follows:tau = time between the end of dead time and the PV reaching 63% of

its total change

9.3 Conclude your report

32

Page 33: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

10 LABORATORY ASSIGNMENT

Continued from lab #9:

10.0.1 TASK [40%] Control Variable measurement

In order to convert the %PWM signal to voltage we need to use a low pass�lter (LPF) of gain one and corner frequency three decades below the PWMfrequency. This will provide a ripple 10−3 in magnitude with reference tothe original PWM signal magnitude, i.e. 5V * 0.001 = 5mV.

Document your �lter design. Test your �lter output at 0, 25%, 50% and100% PWM, use push button to cycle through the PWM setting. Fill thetable below:

% PWM LPF output [V]

0255075100

10.0.2 TASK [40%] P controller

Calculate settings for Controller Gain (Kc) using the Ziegler-Nichols tuningrules below.

For P control: Kc = tau / (G * td)Program your PLC to start the proportional controller upon pressing

a push button and using a setpoint of 45C (INTEGER equivalent). Listthe program (FBD, LD, or SFC). Note when the error becomes negative wecannot switch to a cooling actuator. Provide a limiter to turn any negativeerror to zero control output, 0%PWM.

Use oscilloscope to record the PWM signal (Voltage equivalent after LPF)and the temperature at O&S output. Provide the scope trace.

10.0.3 TASK [10%] Performance Analysis

Analyze the controller performance by extracting the Rise Time, SettlingTime, and % Over Shoot (tr, ts, %os). Cool down your thermal system tothe ambient temperature and increase the proportional gain twice the valueof previous gain (Kc' = 2 * Kc). Run the control loop the same way as above

33

Page 34: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

and extract new performance parameters tr', ts', %os'. Finally conduct thesame experiment for (Kc� = Kc / 2).

Provide the scope trace for the controlled variable in %PWM and andthe temperature as above for all three cases. Make sure the scope setting issame in all three runs. Compare the results.

10.1 Conclude your report

34

Page 35: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 6: LED cycling using PB

35

Page 36: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 7: LED cycling using timer

36

Page 37: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 8: LED cycling using timer

37

Page 38: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 9: Stepper Motor Control - Full Step Mode

38

Page 39: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 10: Stepper Motor Control - Half Step Mode

39

Page 40: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 11: FBD and SFC programming, SFC part

Figure 12: FBD and SFC programming, FBD part

40

Page 41: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 13: FBD and SFC programming with a Timer, SFC part

Figure 14: FBD and SFC programming with a Timer, FBD part

41

Page 42: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 15: Stepper Motor Demo, Task Con�guration

Figure 16: Stepper Motor Demo, FBD code

42

Page 43: ENGI-6855 Industrial Control and Instrumentation ...masek/6855_Labs_2017.pdf · Industrial Control and Instrumentation LABORATORY ASSIGNMENTS ... is natural in hard wired relay based

Figure 17: Stepper Motor Demo, SFC code

Figure 18: Step Test for Z-N Tuning (by Jacques Smuts)

43