Professional Documents
Culture Documents
Section:
L62
Group No.: 8
Students’ Names IDs Grade
Submitted to:
Engr. Adewale Oseni
1
Objectives
The main objectives of this lab are to,
Introduce the students to automation systems (Mechatronics systems)
Familiarize students with the concept of pneumatic systems
Application of microcontrollers
Application of previously gained knowledge about transistors and diodes and introduction to
photo-resistors
Testing the students in building the circuits from schematic drawings
Testing the knowledge of students in programming/coding the Arduino microcontrollers
Introduction
When a measurement system cannot display all of the quantities being measured, a transducer
is used to translate the data or signal into a more user-friendly format for accurate
measurement. The transducer is a device that converts energy from one form to another, such as
electrical, magnetic, mechanical, or optical. It responds to an input, which can be a mechanical,
physical quantity, property, or state, and produces an output that can be used. Sensors detect
the process variable and reflect the instrument's output. Both sensors and transducers can be
used as input and output devices in an electronic circuit or system to measure or change its
surrounding environment. Automation systems are comprised of sensors, actuators, and
controls that can carry out tasks with little or no human involvement. There are four categories
of automation: fixed, programmable, flexible, and integrated. Fixed automation is used for single
functions without alteration, such as in repetitive manufacturing processes. Programmable
automation follows commands given by computer programs and is used in mass production
industries. Flexible automation is used for flexible production in a computer-controlled
manufacturing scenario. Integrated automation requires minimal human intervention and is
carried out solely by controllers and computers. Pneumatic systems are systems that utilize
compressed air to perform work. A typical connection for a pneumatic system involves the use
of tubes or hoses to transport the compressed air to the necessary components such as cylinders
or valves.
In this lab an automated system consisting of pneumatic (Figure 3) and electronic systems are
required to be designed. An electronic circuit must be built to interface an Arduino UNO to the
pneumatic actuators and photo-resistor sensor. Then a c-code is written to automatically sort
given pucks based on two different colors, black and white. Once the program is optimized for
faster sorting, there will be a competition between different groups and the winners will be
awarded bonus points.
3
Figure 3: Setup for automation system using pneumatic systems
4
Task 1: Read the color of an object using Photoresistor
Producer
• Build a voltage divider circuit with a photo-resistor and a 12 kΩ resistor as shown in Figure 4.
• Connect the circuit to an Arduino UNO board and upload the C code to the board
• Place a black object and a white object in front of the photo-resistor and record the range of values
for each color. You can do this by observing the values printed to the serial monitor and noting the
minimum and maximum values for each color.
• Use the recorded range of values to estimate the color intensity of other black and white objects
placed in front of the photo-resistor using the C code and the voltage divider circuit.
Then for checking, modify your code to print “White” when in the range of white and “Black”
when in the range of Black.
Hint: Use if statement,
5
int LDR_reading;
void setup()
{
Serial.begin(9600);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
digitalWrite(9, 255);
digitalWrite(10, 255);
}
void loop()
{
LDR_reading=analogRead(A3);
Serial.println (LDR_reading);
6
Discussion
Photoresistors are devices that can detect and measure the intensity of light. They are
commonly used to indicate whether light is present or not. In our first task, we wrote a
code to detect the colors white and black, and then modified it to print the
corresponding color name. The circuit we used was a voltage divider, with the
photoresistor connected to ground. As the light level increases, the output voltage from
the photoresistor decreases. This is due to the total resistance of the potentiometer
(which acts as a voltage divider) being constant, so as the resistance of the photoresistor
decreases, the resistance of the resistor increases, resulting in a variable voltage across
the photoresistor. This simple circuit allows us to measure the intensity of light using a
photoresistor and a resistor.
7
Producer
To operate the pneumatic actuators in our system, we will use NPN Transistors. Note
that since our system has two actuators, we will need to use two sets of connections for
the circuit in Figure 5, one for each actuator. The actuator at the top of the setup will be
programmed to wait for the puck to settle and then determine the color of the puck
using the code from Task 1. Based on the color detected, it will decide where the
bottom actuator should move, and in turn, move the gate to the appropriate sorting box.
Once this decision has been made, the actuator at the top will activate to push the puck
down the system into the appropriate side. To test the system, we can first replace the
pneumatic actuators with LEDs, such as a red LED for the top actuator and a blue LED
for sorting the puck. Then, we need to write the code to operate the pneumatic actuators
(or LEDs) based on the above description.
8
9
Code to turn on the LED depending on the used color
int LDR_reading;
#define Top_red 9
#define Bottom_green 10
void setup()
{
Serial.begin(9600);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
digitalWrite(Top_red, 0);
digitalWrite(Bottom_green, 0);
}
void loop()
{
LDR_reading=analogRead(A3);
Serial.println (LDR_reading);
digitalWrite(Bottom_green, HIGH);
// bottom ON mean move the cylinder forward
// so the white fall on right side
delay(4000); //give some time to settle
digitalWrite(Top_red, HIGH);
// push and give some time
delay(2000);
digitalWrite(Top_red, LOW);
//Retract back the top one
}
else if ( LDR_reading > 940 && LDR_reading < 990)
{
Serial.println ("black color");
digitalWrite(Bottom_green, LOW);
// bottom OFF mean move the cylinder backward
// so the black fall on left side
delay(4000); //give some time to settle
digitalWrite(Top_red, HIGH);
// push and give some time
delay(2000);
digitalWrite(Top_red, LOW);
//Retract back the top one
delay (100);
}
10
Discussion
The code is functioning correctly as intended. The resistors connected to the two
LEDs are necessary to reduce the voltage supplied by the Arduino UNO, as LEDs
require a lower voltage to operate. Thus, a resistor is used to decrease the voltage.
When the photo-resistor is covered by white color, only the green LED will
illuminate, and similarly, when it is covered by black color, only the blue LED will
illuminate. If nothing is covering the photo-resistor, both LEDs will remain off.
The final step is to test the circuit and code with the given pneumatic actuator in the
system. Use the photo-resistor to measure the color of the given pucks and incorporate
this information into the code to actively switch on or off the dual action actuator for
sorting. The group that can sort the pucks faster will be declared the winner and will be
awarded bonus points.
11
12
13
Conclusion
All of the goals set for this lab were met successfully. We became accustomed to
working with analog sensors and inputs. We utilized the Arduino board as a tool for
acquiring and displaying data from the sensors on the serial monitor. Through this
experiment, we gained a deeper understanding of how sensors function and had the
opportunity to enhance our coding skills.
Reference
- Lab manual
14