Professional Documents
Culture Documents
Laboratory Tutorial
Control System Technology
(ME2009)
1. INTRODUCTION
Arduino (shown in Figure 1) is an open source computer hardware and software company.
It is designed to facilitate interaction with the physical world via sensors while being able to
perform calculations and various functions. Nowadays, Arduino is fast becoming one of the
most popular microcontrollers on the market. Its ease of use, extensive software library and
most importantly, its low cost have come to make it as popular as it is today.
Many projects using the Arduino can be found on http://www.hackaday.com. In order to
start having fun with the Arduino, free software can be found at
http://arduino.cc/en/Main/Software for Macs, Windows and Linux operating systems. This
website also provides tons of easy tutorials for you to start. Tutorials can be found at
http://arduino.cc/en/Tutorial/HomePage.
In this lab, you will become familiar with the Arduino, interact with the other hardware,
e.g. led, Photoelectric Sensor, incremental rotary encoder and some of their applications. You
will learn how to use the Arduino to interface between hardware on the control system Kit 01
board (shown in Figure 2) and software (the code). You will also learn how to use a led
module to display number, detect an object by using Photoelectric Sensor and measure an angle
with an incremental rotary encoder.
2. LAB DEVICES
2.1 Arduino Uno Board
2.4 Wires
Used to connect Arduino Uno board with Control System Kit 01.
2.5 Screwdriver
Used to screwing and unscrewing (inserting and removing) screws on the Control System Kit
01.
3. PROCEDURE
3.1 Set up your Arduino Programming Environment
The Arduino programming environment needs to be set up on a machine that you have access
to. It can be a Windows PC, Mac or Linux machine and it can be a laptop or desktop. Get the
latest version free software from the website ( http://arduino.cc/en/Main/Software). You should
choose the Installer (.exe) that installs directly everything you need to use the Arduino Software
(IDE), including the drivers.
When the download finishes, proceed with the installation and please allow the driver
installation process when you get a warning from the operating system. Follow instructions to
finish the installation as shown in Figure 6
\Documents\Arduino\libraries). You can find or change the location of your sketchbook folder
at File > Preferences > Sketchbook location (shown in Figure 7)
Choose the icon Arduino on your computer to start a new Arduino program ( Sketch)
and Write a simple program name as Blink as shown in Figure 10. Press Verify button to check
your code.
Figure 12. Select your serial port, Tools>Serial Port>COM 7 (COM # depending what
COM port is free during setup)
Click upload button to upload the code to Arduino. Wait until “Done Uploading”
message status appear. The LED should blink and you have successfully installed your
Arduino.
4. REFERENCE
[4] Howtomechatronics.com, How Rotary Encoder Works and How To Use It with
Arduino, 2016. Available: https://howtomechatronics.com/tutorials/arduino/rotary-
encoder-works-use-arduino/ [Accessed: 1- May- 2018].
5. APPENDIX
5.1 Arduino Help
You will find other Arduino functions use them in your sketches at the path Help >
Reference. The structure and use of functions is fully explained.
Specification:
• Power supply: 5V • Working Current: <100mA
• Adjustable detection range: 3cm - 80cm
• Pin description: • Red - 5V • Green – GND • Yellow - Digital output
tie it to GND.
A seven-segment display is a LED module
composed of 8 LEDs. 7 of the LEDs are for
segments of one digit (shown as A to G below) and
the other LED is for the decimal point (shown
as DP below).
Figure 19. Seven- segment Led
Display module
The schematic diagram to use one 74HC595 control one digit 7 segments Led Display
module shown in Figure 20
e Q3
f Q2
g Q1
DP Q0
VCC 5V
CE, GND GND
SHCP (Clock) 4
STCP (Latch) 5
DS (Data) 6
MR 5V
Figure 20. Connect 74HC595 with one digit 7 segments Led Display and Uno board
incremental encoders provides information about the motion of the shaft, which is typically
further processed elsewhere into information such as speed, distance, and position. Rotary
encoders are used in many applications that require precise shaft unlimited rotation—including
industrial controls, robotics, rotating radar platforms.
There are many different types of rotary encoders which are classified by either Output
Signal or Sensing Technology. The particular rotary encoder that we will use in the lab
assignment is an incremental rotary encoder and it’s the simplest position sensor to measure
rotation. This rotary encoder is also known as quadrature encoder or relative rotary encoder
and its output is a series of square wave pulses.
Any of the two outputs can be used for determining the rotated position if we just count
the pulses of the signal. However, if we want to determine the rotation direction as well, we
need to consider both signals at the same time.
We can notice that the two output signals are displaced at 90 degrees out of phase from
each other. If the encoder is rotating clockwise the output A will be ahead of output B.
So if we count the steps each time the signal changes, from High to Low or from Low
to High, we can notice at that time the two output signals have opposite values. Vice versa, if
the encoder is rotating counterclockwise, the output signals have equal values. So considering
this, we can easily program our controller to read the encoder position and the rotation
direction.
REPORT
Date:………………… Group:……………… Duration: 5 class hours
Full Name Student ID Signature Grade
Task 2. Modify the Blink program to make the LED flash 5 times (0.5 seconds/time),
pause 2 seconds then flash again.
…………………………………………… ………………………………………………..
…………………………………………… ………………………………………………..
…………………………………………… ………………………………………………..
…………………………………………… ………………………………………………..
…………………………………………… ………………………………………………..
…………………………………………… ………………………………………………..
…………………………………………… ………………………………………………..
Task 7. Use Encoder library to get the pulse input of rotary encoder and show the value
on the led module
0% 25% 50% 75% 100%
Task 8. The resolution of the rotary encoder is: ……… pulse/ revolution (PPR)
Task 9. Write a program to display the integer angle (degree) of the rotary encoder. If
Photoelectric Sensor signal is “LOW”, the value will be reset to “00”
Task 10. Write a program to display the real angle (degree) of the rotary encoder. If
Photoelectric Sensor signal is “LOW”, the value will be reset to “00”
1. INTRODUCTION
In lab assignment 1, we have learned how to use Arduino to acquire various types of the
signal from a sensor such as a digital photosensor, potentiometers, incremental rotary encoder.
In this lab assignment, we will turn our attention to actuator control, which is an important part
of an automatic system.
The goal of this lab is to learn how to control a DC servo motor using the Arduino
microcontroller Mega 2560 board (shown in Figure 1) and the L298N Motor Shield driver
(shown in Figure 2). We take a look at some basic techniques for controlling DC motors. We
will use the reading from a rotary encoder attached to the back of the motor as our feedback
signal. We will learn how to design a controller for the motor, and drive the motor to a set-
point.
2. LAB DEVICES
2.1 Arduino Mega 2560 Board
2.4 Wires
Used to connect Arduino Mega board with Control System Kit 02.
2.5 Screwdriver
Used to screwing and unscrewing screws on the Control System Kit 02.
3. PROCEDURE
3.1 Set up your Arduino Programming Environment
You should set up the Arduino programming environment and Encoder Library on your PC.
You can review the guideline in Lab assignment 1 to install the software.
3.2 Wiring diagram and electrical circuit
Device Name Control System Kit 02 Arduino Mega
+5V GND 8 2 3 A0 A1 A2
Driver Shield
OUT A B
GND (8) (2) (3)
KP KD
(A0) (A2)
KI
(A1)
M1+
M1-
GND
12V
Figure 7. Wiring diagram between Mega 2560 board, a motor shield and the Kit 02
M+ M+
12V
12V M-
M-
GND GND
int pwm_value = 0;
void setup() {
pinMode(DIR1, OUTPUT);
pinMode(DIR2, OUTPUT);
}
void loop() {
pwm_value = 100; // PWM value
digitalWrite(M1,HIGH); // change the direction of DC motor
analogWrite(E1, value); //change the speed of DC motor
}
long motorPos = 0;
void setup() {
Serial.begin(115200); // setup serial
myEncoder.write(0); // reset encoder counter to 0
}
void loop() {
motorPos = myEncoder.read(); // read pulses of encoder
Serial.print("Pulses of encoder: "); // show counter on screen
Serial.println(motorPos);
}
3.5 Potentiometer
The Arduino microcontroller can read analog inputs between 0 and 5 V and generate
corresponding integer values. This is accomplished using the analogRead() function. It takes
about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is
about 10,000 times a second. We can use this function to get the analog value of a potentiometer
with the example below:
void setup() {
Serial.begin(115200); // setup serial
}
void loop() {
ADvalue = analogRead(POT1); // read AD value
Serial.print("Value of Potentiometer 1: "); // show value on screen
Serial.println(ADvalue);
}
void setup() {
Serial.begin(115200); // setup serial
pinMode(PHOTO_SENSOR, INPUT); // set the digital pin 8 as input
}
void loop() {
if (digitalRead(PHOTO_SENSOR)== LOW)
{
Serial.print("There is a obstacles ");
}
else
{
Serial.print("There is nothing ");
}
}
START
Position control
NO
START
Speed control
NO
4. REFERENCE
[4] howtomechatronics.com, How Rotary Encoder Works and How To Use It with
Arduino, 2016. Available: https://howtomechatronics.com/tutorials/arduino/rotary-
encoder-works-use-arduino/. [Accessed: 1- May- 2018].
REPORT
Date:………………… Group:……………… Duration: 5 class hours
Full Name Student ID Signature Grade
Task 2. Typing and run the example in section 3.5 Potentiometer and answers the
question below (1 point)
Potentiometer to ADC has a minimum ADC value: adc _ max .............
Potentiometer to ADC has a maximum ADC value: adc _ min .............
The resolution of AD convert of Arduino 2560 is n ......... bits
Task 3. Wire program to read signal of A and B channel of the encoder, determine the
resolution of the encoder (1 point)
Number of pulse per round of encoder : res _ encoder ............. (ppr)
Determine the equation to calculate the speed of motor if the Arduino receives pulses
in 100 milliseconds.
speed ........................................................................................ (rpm)
Task 4. Typing and run the example in section 3.3 Method control of DC motor (1 point)
Can you run the code in section successful? Yes No
Modify your code to add a value 30 to a pwm_value variable every 1 second. If the to
pwm_value > 255, it will be set to 0. (Hint: use For loop and delay function)
0% 25% 50% 75% 100%
Task 5. Use your code in task 4 then modify it to reverse the direction of rotation of motor
as having an obstacle in front of the photoelectric sensor? (1 point)
Task 6. Write a program to change the speed of motor depend on the value ADC of the
potentiometer. As we turn the potentiometer from minimum value to maximum value,
why is the speed of motor changed many times? Please fix this problem? (1 point)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
Task 7. Write a program to control the motor to the angle = 900 (1.5 point)
0% 25% 50% 75% 100%
Task 8. Write a program to control the motor rotate to angle 900 if we put an obstacle in
front of the photoelectric sensor; otherwise, the motor will return to 00 (1.5 points)
0% 25% 50% 75% 100%
Task 9. Write a program to control the speed of motor = 500 rpm (1.5 point)
0% 25% 50% 75% 100%
1. INTRODUCTION
A relay is a set of switches that are actuated when electric current passes through a coil of wire.
Nowadays, relays are used quite commonly in industrial applications. Although micro-processor
based controllers are commonly used, using relays as a controller is sometimes a reasonable solution
in sequential processes.
Objectives:
Overview the multi-purpose relay.
Have experience in wiring and testing electrical circuits.
Implement the method of sequential circuit design using relays.
2. EQUIPMENT
2.1 Devices
- 4 multi-purpose relays of 4 poles.
- 5 push buttons (one representing the ON button and the other four
representing sensor signals).
- 2 screw drivers.
2.2 Specifications:
a) Electromechanical Relays (EMR): this is a device that uses an electromagnet to provide the force to
close (or open) switch contacts, in other words, an electrically powered switch. When the
electromagnet, called the coil, is energized, it pulls down on the spring-loaded armature. Relay
contacts are described as being one of two kinds: normally open contacts (NO), which are open in
the unenergized state, and normally closed contacts (NC), which are closed in the unenergized state.
By convention, the symbol always depicts the relay in the unenergized state.
.
b) Push-button switches: these are almost always the momentary type – pressure must be
maintained to keep the switch activated. There are two configurations possible: normally open
(NO) and normally closed (NC).
Time-delay relays: they are control relays that have provisions for a delayed switching action.
Solid-state time-delay relays are used in most newer systems that require delay relays. The delay
in switching is usually adjustable, e.g. the knob is for setting the delay. These units are based on
the delay involved when (1) charging a capacitor or (2) counting high-speed clock pulses with a
digital counter: the higher the count, the longer the delay. The delay may take place when the
coil is energized or when the coil is deenergized. An arrow is used to identify the switching
direction in which the time delay takes place.
For the time-delay relays AH3-3, pin numbers are assigned as follows
3. EXPERIMENTAL CONTENTS
3.1 Time duration: 5 academic periods for each group of 4 students.
3.2 Requirements
Small bent workpieces can be produced to good advantage without the need for an eccentric or
hydraulic press by using standard commercially available components to create a basic
configuration and pneumatic components to provide the necessary motions in numerous directions.
The illustration shows a bending sequence (from I to IV). The lateral bending jaws can be activated
only after the vertical motion has been completed. The sequence control system thus requires
signals supplied by proximity switches. The finished workpiece must be pushed away from the
bending ram. In the case of full automation, the insertion of a new workpiece blank can be
combined with the ejection of a finished workpiece. This system is described in a diagram as
follows:
Cylinder A
A1
A2
LS1
LS6 LS5
Cylinder B LS2 Cylinder C
LS3 LS4
B1 B2 C2 C1
Each pneumatic cylinder is connected through a 4/3 directional valve. Therefore, there are 6
manipulated signals:
A1 = 1: Cylinder A extends.
A2 = 1: Cylinder A retracts.
B1 = 1: Cylinder B extends.
B2 = 1: Cylinder B retracts.
C1 = 1: Cylinder C extends.
C2 = 1: Cylinder C retracts.
Six limit switches are used to detect positions of the cylinders as follows:
LS1 = 1: the cylinder A is at the retracted end position.
LS2 = 1: the cylinder A is at the extended end position
LS3 = 1: the cylinder B is at the retracted end position
LS4 = 1: the cylinder B is at the extended end position
LS5 = 1: the cylinder C is at the retracted end position
LS6 = 1: the cylinder C is at the extended end position
With the diagram above, the sequence operations could be described as:
- Step 1: the cylinder A extends.
- Step 2: then the two cylinders B and C extend together.
- Step 3: when the cylinders B and C reach to the end, they retract at the same time.
- Step 4: when the cylinders B and C are retracted completely, the cylinder A starts
retracting.
The students are required to design the controller for the above system. Note that experimental
results in part 4 need to be completed and submitted to the instructor.
a) Using relays, implement a control circuit to meet the desired sequence in which push-
button switches are used as limit switches.
b) Replace the four push-button switches with four time-delay relays, respectively. Then,
revise the control circuit so that the system operates automatically when the ON button
is the pressed.
With the statement list above, the system could also be expressed in a Sequential Function Chart
(SFC) as follows
Start
ON
LS2
LS1
From the SFC, there are four steps operating in sequence. Therefore, the procedure for the design
of an event-driven sequential circuit could be applied. Basic concepts of the design are:
Use of a control relay for each step in the process.
When the process is in a given step. the control relay associated with that step is energized
and all other relays are deenergized each control relay represents a "state" of the
controller.
There is a one-to-one correspondence between steps in the process and states of the
controller, and the step numbers are used to identify the states.
Each state in the controller consists of one rung in the controller ladder diagram.
Assume that the process has three consecutive steps: step i, step j, and step k. The rung in the
ladder diagram that establishes step j in a sequential control circuit has a general form:
Where:
Rj
Coil the control relay k, representing State j
Rk
NC contact of the control relay k, terminating State j when the process is in Step k.
Ri
NO contact of the control relay i, informing State j be ready when the process is in
Step i.
Cij
the condition required to move from State i to State j.
Rj
NO contact of the control relay j, self-holding State j.
R3 R1 Button B
R2
10 2 7 11 13 14
CRj
5 9
R4 R2 Button C
R3
10 2 7 11 13 14
R3
5 9
Button E R3 Button D
R4
7 11 13 14
R4
5 9
4. Experimental results
4.1 Plot the control circuit in ladder diagram with time-delay relays as the transition condition
Comments: …………………………………………………………………………………………
Comments: …………………………………………………………………………………………
Instructor’s name:
Date: Room: Time of report:
Student’s names: Student’s IDs:
………………………………………………………… …………………..
………………………………………………………… …………………..
………………………………………………………… …………………..
………………………………………………………… …………………..
REFERENCES:
[1] R.N. Bateson, Introduction to Control System Technology, 7th Edition, Prentice Hall, 2002.
[2] Christopher T. Kilian, Modern Control Technology: Components and Systems, 2nd Edition,
Delmar Thomson Learning, 2001.
Example 1:
The drilling, countersinking and chamfering of small workpieces in medium-sized and large
batches are typical work operations in mechanical engineering. It can be well worth while to
develop special devices for these operations. In this example, the workpiece carriers consist of
high-powered pneumatic chucks which are indexed about a horizontal axis with the aid of a rotary
indexing table. Pneumatic pick-and-place units are used for loading and unloading. If the device
is used on a drilling/milling machine with a vertical working spindle, a further working operation
can be carried out in the loading position. A hydraulic cushioning cylinder can be connected up in
parallel to cushion the feed motion.
Example 2:
Certain workpieces tend to deform easily during processing and clamping. In the interests of
accuracy and to prevent deformity, these must be fitted with a temporary clamp sleeve to allow
further processing. This is achieved by using the system shown above, which is partially
automated. The clamp sleeves are first placed into a carrier by hand. The workpiece is then moved
into the clamping position against the stop of the more powerful right-hand cylinder. This is
followed by longitudinal pressing. After this, the stop cylinder retracts again, allowing the feed
cylinder in a second action to push the finished workpiece onto the outward transfer conveyor belt.
The clamp sleeves must be removed again after processing has been completed. The workpieces
are moved by hand from the conveyors to the side setdown area.