Sensor and Actuator
Sensor and Actuator
Terminology
• Transducers convert one form of energy into another
• Sensors/Actuators are input/output transducers
• Sensors can be passive (e.g. change in resistance)
or active (output is a voltage or current level)
• Sensors can be analog (e.g. thermocouples) or
digital (e.g. digital tachometer)
Transducer types
Quantity
Input Device Output Device
being
(Sensor) (Actuator)
Measured
Light Dependant Resistor (LDR),
Lights & Lamps, LED's
Light Level Photodiode, Phototransistor, Solar
& Displays, Fiber Optics
Cell
Thermocouple, Thermistor,
Heater, Fan, Peltier
Temperature Thermostat, Resistive temperature
Elements
detectors (RTD)
Lifts & Jacks,
Force/Press Strain Gauge, Pressure Switch,
Electromagnetic,
ure Load Cells
Vibration
Potentiometer, Encoders,
Motor, Solenoid, Panel
Position Reflective/Slotted Opto-switch,
Meters
LVDT
Tacho-generator, Reflective/Slotted
AC and DC Motors,
Speed Opto-coupler, Doppler Effect
Stepper Motor, Brake
Sensors
Carbon Microphone, Piezo-electric Bell, Buzzer,
Sound
Crystal Loudspeaker
Classification of Sensors and
Actuators
• Based on physical laws
• Based on any convenient distinguishing
property
• Possible to a certain extent
Needs:
• Matching (impedances, voltages, currents, power)
• Transformations (AC/DC, DC/AC, A/D, D/A, VtoF,
etc.)
• Matching of specifications (temperature ranges,
environmental conditions, etc.)
• Alternative designs
• Etc.
Connection of
sensors/actuators
Topics:
The Arduino
Digital IO
Analog IO
Serial Communication
What is a Microcontroller
www.mikroe.com/chapters/view/1
http://spectrum.ieee.org/geek-life/hands-on/the-making-of-arduino
The Arduino Microcontroller: Atmel
ARV Atmega 328
Specification
Making-robots-with-arduino.pdf
What is the Arduino
todbot.com/blog/bionicarduino
Different Varieties of Arduino
Digital Input / Digital output
(PWM on pins 3, 5, 6, 9, 10, 11)
USB Arduino
connection Uno
Revision
7-12 volt 3
input power
(9v is
common) Power Analog input /
pins Digital input or
output
Topic 1: Meet Arduino Uno
Getting Started
• Check out: http://arduino.cc/en/Guide/HomePage
1. Download & install the Arduino environment (IDE)
2. Connect the board to your computer via the UBS
cable
3. If needed, install the drivers (not needed in lab)
4. Launch the Arduino IDE
5. Select your board
6. Select your serial port
7. Open the blink example
8. Upload the program
Try It: Connect the USB Cable
todbot.com/blog/bionicarduino
Arduino IDE
todbot.com/blog/bionicarduino
todbot.com/blog/bionicarduino
Add an External LED to pin 13
www.instructables.com
Our First Program
A Little Bit About Programming
• Code is case
sensitive
• Statements are
commands and
must end with a
semi-colon
• Comments follow a
// or begin with /*
and end with */
• loop and setup
Input/Output
1
• Digital IO is binary
valued—it’s either on 0
or off, 1 or 0
• Internally, all
microprocessors are
digital, why?
Analog to Digital Coversion
• What is analog ?
• It is continuous range of voltage values
(not just 0 or 5V)
void loop() {
// put your main code here, to run
repeatedly:
}
Bare minimum code
• setup : It is called only when the Arduino is
powered on or reset. It is used to initialize
variables and pin modes
• analogWrite(2,128);
Light Emitting Diode: LED
What is an LED?
• Light-emitting diode
• Semiconductor
• Has polarity
LED: How It Works
• When current flows
across a diode
1. Transparent
Plastic Case
2. Terminal Pins
3. Diode
Kinds of LEDs
What is the differece between
LEDs?
LED Series Resistor Circuit
How to Connect a LED:
• Requires 1.5~2.5V and 10 mA
• To prevent overloading, use resistor 470
Ω
How to Connect a LED:
Connect LED to BS2
• LED is on when P0
is high
• LED is on when P1
is low
Case Study: Blinking LED
• Pbasic program to make an LED blink
output 0
Main:
low 0
pause 1000
high 0
pause 1000
goto Main
int pin = 13;
void setup()
{
pinMode(pin, OUTPUT);
}
void loop()
{
digitalWrite(pin, HIGH);//set the LED
delay(1000);
digitalWrite(pin, LOW);//set the LED
delay(1000);
}
ATmega328 Internal Architecture
http://www.adafruit.com/index.php?main_page=popup_image&pID=50
ATmega328 Microcontroller
Pin number
Pin name
Special
function
Note the
limitations!
p. 316
Absolute Maximums
Sparkfun.com
http://www.jameco.com/
www.ledsupply.com/
http://www.oznium.com/led-strip-flat-head
What's a switch?
Measure Open and Closed
Circuits
Push Button Switches
• Pushing the button changes state
• State is reversed (return to biased positon) when button
is released
• Two types
✓ NO: normally open
✓ NC: normally closed
Continuous monitor of button
state
3v-220v
External Power
Externally Powered Device
void setup()
{
Serial.begin(9600);
}
void loop()
{
char key = keypad.getKey();
if (key != NO_KEY){
Serial.println(key);
}
}
Raspberry
Pi
Raspberry Pi
• A Raspberry Pi is a credit
card-sized computer originally
designed for education,
inspired by the 1981 BBC
Micro.
• Creator Eben Upton's goal
was to create a low-cost
device that would improve
programming skills and
hardware understanding at the
pre-university level.
What is Raspberry Pi ?
• Arguably the most popular single board
computer (SBC)
• Easy to get started with because basically
every problem is documented
• Add a computer with a OS to practically
anything • Support for a vast array of
peripherals (thanks to the Linux kernel) USB
devices, networking, displays, cameras, audio
etc.
http://www.youtube.com/watch?v=KdTwQXre1D
U
What can you do with a Pi? (not
so cool)
http://mymediaexperience.com/raspberry-pi-xbmc-with-raspbmc/
https://www.raspberrypi.org/magpi/magic-mirror/
https://github.com/foosel/OctoPrint
https://vadelmapii.com/blogi/yllapida-omaa-dropbox-kloonia-raspberry-pilla-kayttaen-owncloudia
What can you do with a Pi? (cool)
https://hackaday.io/project/1279-ramanpi-raman-spectrometer https://www.raspberrypi.org/blog/real-time-depth-perception-with-the-compute-module/
http://www.zdnet.com/article/build-your-own-supercomputer-out-of-raspberry-pi-boards/
Variations of Raspberry Pi
• Hardware platform
– Raspberry Pi Zero ($5)
– Raspberry Pi
– Raspberry Pi 2
– Raspberry Pi 3 (with Wifi + Bluetooth)
• Software platform
– Noobs
– Raspbian
– 3rd OS
– https://www.raspberrypi.org/downloads/
Raspberry Pi models
25.12.2019 96
Raspberry Pi advantages and
disadvantages
>Video cable
>Keyboard
>Wireless Adapter
>Speakers
>Pi Display
>Pi Camera
>Pi Case
Connections
GPIO
MicroSD-slot
(underneath)
4x USB 2.0
Display connector
cd Change directory
rm Remove
apt-get update Update repository list (update list of links to software downloads)
• Almost everything
• C, C++, Python2/3, Javascript (node), Ruby, Lisp, Rust…
#define DHT11_PIN 7
void setup(){
Serial.begin(9600);
}
void loop()
{
int chk = DHT.read11(DHT11_PIN);
Serial.print("Temperature = ");
Serial.println(DHT.temperature);
Serial.print("Humidity = ");
Serial.println(DHT.humidity);
delay(1000);
}
DHT 11 Sensor
1. Connect the sensor with Arduino board like picture below.
2. Download DHT11 Sensor library from
http://www.hardcopyworld.com/ngine/aduino/?wpdmdl=2388
3. Add library to Arduino IDE
DHT 11 Sensor
1. Configure serial port
2. Open Serial monitor tool
3. Copy the source from
http://www.hardcopyworld.com/ngine/aduino/index.php/archives/190
4. Compile and Upload
Temperature Sensor - TMP36
• low power
temperature
sensor outputs an
analog voltage that
is proportional to
the ambient
temperature.
(TMP35/TMP36/TMP37)
Wiring it up is very easy!
To use, connect:
• pin 1 (left) to
power (between
2.7 and 5.5V).
• pin 3 (right) to
ground.
• pin 2 to analog in
on your
microcontroller.
Temperature Sensor Circuit
Schematic
• This will be the raw value (between 0 and 1023)
divided by 205. It is divided by 205 because a
span of 1024 values occupies 5V, or 1024/5=
205 per volt.
• Once this the analog voltage is calculated, we
can find the degrees in celsius by the equation:
celiustemp= 100.0 * volts -50
• We then can find the temperature in fahrenheit
by the equation: fahrenheittemp= celiustemp *
9.0/5.0 + 32.0
Code for Temperature Sensor
Circuit
• //initializes/defines the output pin of the TMP36 temperature sensor
int outputpin= 0;
//this sets the ground pin to LOW and the input voltage pin to high
void setup()
{
Serial.begin(9600);
}
//main loop
void loop()
{
int rawvoltage= analogRead(outputpin);
float volts= rawvoltage/205.0;
float celsiustemp= 100.0 * volts - 50;
float fahrenheittemp= celsiustemp * 9.0/5.0 + 32.0;
Serial.print(celsiustemp);
Serial.println(" Celsius");
Serial.print(fahrenheittemp);
Serial.println(" Fahrenheit");
delay(300000);
}
Arduino and monochrome
LCDs
• Fixed-character LCD modules
• Graphic LCD modules
Fixed-character LCD modules
• Their size is normally measured by the number
of columns and rows of characters in the display.
• For example, the three LCDs below are 8×2,
16×2 and 20×4 characters in size:
Fixed-character LCD modules
• Most LCDs should
have a backlight of
some sort, however
you may come
across some
heavily-discounted
models on (for
example) eBay that
are not.
Interfacing these screens with
our Arduino boards
• very easy, and there are several ways to
do so. These interface types can include
• four- and eight-bit parallel.
• Three-wire, serial, I2C and SPI interfaces;
• The LCD price is usually inversely
proportional to the ease of interface
Four-bit parallel interface
There are sixteen pins on the LCD. These are usually in one row:
void loop(){
lcd.setCursor( 5 , 1);
lcd.print(“MAMA”);
lcd.cursor();
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting
begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
Three-wire LCD interface
• If you cannot spare many
digital output pins on your
Arduino, only need basic
text display and don’t
want to pay for a serial or
I2C LCD, this could be an
option for you. A 4094
shift register IC allows
use of the example
HD44780 LCD with only
three digital output pins
from your Arduino. The
hardware is connected as
such:
• use the ShiftLCD library, which you can
download from here:
• www.miselph.co.uk/arduino/ShiftLCD.zip
• Then, in the start of your sketch, add the
following line:
#include<ShiftLCD.h>
• tell the sketch which of the 4094’s pins are
conected to which digital output pins:
ShiftLCD lcd(2,3,4);
#include<ShiftLCD.h>
ShiftLCD lcd(2,3,4);
int data;
void setup()
{
lcd.begin(16,2);
lcd.print("Hello Word");
delay(3000);
}
void loop()
{
lcd.clear();
lcd.print(millis()/1000);
lcd.setCursor(1,1);
lcd.print("Miarana");
}
Graphic LCD modules
• Fortunately there are many graphic LCD
modules on the market.
• A parallel data interface and one and a
serial data interface.
Parallel interface
• Our example in this case is a 128 by 64
pixel unit with a KS0108B parallel
interface:
• By now you should be able to install a
library, so download this KS0108 library
and install it as usual
http://www.arduino.cc/playground/uploads/C
ode/ks0108GLCD.zip
Arduino Uno/Duemilanove sockets:
1. 5V
2.GND
3.centre pin of 10k ohm potentiometer
4.D8
5.D9
6.D10
7.D11
8.D4
9.D5
10.D6
11.D7
12.A0
13.A1
14.RST
15.A2
16.A3
17.A4
18.outer leg of potentiometer; connect
other leg to GND
19.5V
20.GND
• there are several functions that need to be
called in order to activate our LCD. The
first of these being:
GLCD.Init(NON_INVERTED);
#include <ks0108.h> // library header GLCD.ClearScreen(); // clear the LCD
int xc, yc = 0; for (int a=0; a<64; a++)
int d=1000; // for delay use {
GLCD.DrawHoriLine(0, a, 127, BLACK);
void setup()
{ // draws a horizontal line from xy position 0, a of length 127
GLCD.Init(NON_INVERTED); // initialise the library with pixel default as off delay(d-950);
GLCD.ClearScreen(); // clear the LCD }
randomSeed(analogRead(5)); for (int a=0; a<64; a++)
}
{
void loop() GLCD.DrawHoriLine(0, a, 127, WHITE);
{ delay(d-950);
GLCD.DrawRect(0, 0, 127, 63, BLACK); }
// draw an open rectangle that spans the extremties of the LCD GLCD.ClearScreen(); // clear the LCD
GLCD.DrawRect(10, 10, 117, 53, BLACK);
GLCD.DrawRoundRect(30, 30, 20,20, 5,BLACK);
GLCD.DrawRect(20, 20, 107, 43, BLACK);
GLCD.DrawRect(30, 30, 97, 33, BLACK); // draw a rectangle with rounded edges: x, y, width, height,
delay(d); radius of rounded edge, colour
GLCD.ClearScreen(); // clear the LCD GLCD.DrawRoundRect(60, 30, 20,20, 5,BLACK);
for (int a=1; a<20; a++) delay(d);
{
GLCD.ClearScreen(); // clear the LCD
GLCD.DrawCircle(63,31,a,BLACK);
// draws a circle with centre at 61,31; radius of a, with black pixels delay(d);
delay(d-800); GLCD.FillRect(30, 30, 30, 10, BLACK);
GLCD.DrawCircle(63,31,a,WHITE); // draws the same circle with the pixels // draws a filled rectangle: x, y, width, height, colour
off delay(d);
}
GLCD.ClearScreen(); // clear the LCD
delay(d);
GLCD.ClearScreen(); // clear the LCD for (int a=0; a<1000; a++)
for (int a=0; a<128; a++) {
{ xc=random(0,127);
GLCD.DrawVertLine(a, 0, 63, BLACK); yc=random(0, 63);
// draws a vertical line from xy position a, 0 of length 63
GLCD.SetDot(xc, yc, BLACK);
delay(d-950);
} // turn on a pixel at xc, yc);
delay(d-800); delay(2);
for (int a=0; a<128; a++) }
{ GLCD.ClearScreen();
GLCD.DrawVertLine(a, 0, 63, WHITE);
// clear the LCD
delay(d-950);
} }
• Sensor
• Pressure Sensor
• Pressure Sensor Types
• Force Sensor
• Force sensor applications
• Force sensor characteristics
• How does it work
• Sensor Testing
• Connection with Arduino
• Voltage Divider
• How to connect
• Arduino Code
• Sensor Operating
• Connection with Raspberry Pi 3
Sensor:
• A sensor is a device, whose purpose is to
detect events or changes in its
environment and send the information to
other electronics. A sensor is always used
with other electronics.
Pressure Sensor:
• A pressure sensor is a
device for pressure
measurement.
• Pressure is usually stated in
terms of force per unit area.
• A pressure sensor usually
acts as a transducer.
• It generates a signal as a
function of the pressure
imposed.
Types of Pressure Sensors
• Based on the type of applications they are
used in, pressure sensors can be
categorized into many types
Types of Pressure Sensors
• 1- Strain Gauge Type: made from different
material Copper-Nickel, Chrome-Nickel and
Nickel-Iron
• When force applied on metal length and
diameter will change but remove this force
its take his original position. It has four arms
which connect like wheat stone bridge.
• Wheatstone bridge condition
P/Q = R/S where p q r s is resistance
Voltage E = 0 ( in balance condition)
when force applied on diaphragm BF350-3AA Strain Gauge Modul
unbalance create and resistance change so
out put terminal get o/p volatile . which is
strain force, ( this voltage is directly
proportional to applied force ) . so voltmeter
shows reading of applied force
Types of Pressure Sensors
• Capacitive Pressure Sensor: A capacitor has
two metal plates and a dielectric sandwiched
between them. In capacitive pressure sensor,
one of these metal plates is permitted to move
in and out so that the capacitance between
them changes due to varying distance between
the plates. The movable plate is connected to a
diaphragm which senses the pressure and then
expands or compresses accordingly. The
movement of the diaphragm would affect the
attached metal plate’s position and capacitance
would vary.
• These sensors, though much ineffective at high
temperatures, are widely used at ambient
temperature range due to their linear output.
Types of Pressure Sensors
• Piezoelectric Pressure Sensor:
Piezoelectric crystals develop a potential
difference (i.e. voltage is induced across the
surfaces) whenever they are subjected to
any mechanical pressure. These sensors
have the crystal mounted on a dielectric Analog Piezoelectric
base so that there is no current leakage. Ceramic Vibration Sensors
Attached to the crystal is a horizontal shaft for Arduino,
to which a diaphragm is
connected. Whenever the diaphragm
senses pressure, it pushes the shaft down
which pressurizes the crystal and voltage is
produced.
Pressure Sensor Examples
• A Barometer is used in meteorology to
measure atmospheric pressure and
forecast short term changes in the
weather. Because atmospheric pressure
also varies with elevation,
a barometer can also be used as a basic
altimeter.
Pressure Sensor Examples
• Tire Pressure Monitoring Sensor is to
warn you that at least one or more tires
are significantly under-inflated, possibly
creating unsafe driving conditions.
Pressure Sensor Examples
• Water flow sensor consists of a plastic
valve body, a water rotor, and a hall-
effect sensor. When water flows through
the rotor, rotor rolls. Its speed changes
with different rate of flow. The hall-
effect sensor outputs the corresponding
pulse Signal.
Pressure Sensor Examples
• Force Sensor: A force-sensing resistor
is a material whose resistance changes
when a force, pressure or mechanical
stress is applied. They are also known as
"force-sensitive resistor" and are
sometimes referred to by the initialism
"FSR".
Force Sensor:
• Force Sensing Resistors, or FSRs, are robust
polymer thick film (PTF) devices that exhibit a
decrease in resistance with increase in force
applied to the surface of the sensor. This force
sensitivity is optimized for use in human touch
control of electronic devices such as automotive
electronics, medical systems, and in industrial and
robotics applications.
• The standard 402 sensor is a round sensor 18.28
mm in diameter. Custom sensors can be
manufactured in sizes ranging from 5mm to over
600mm.
Force sensor applications:
• Electronic Scale a balance that
generates a current proportional to the
displacement of the pan. Type
of: balance. A scale for weighing;
depends on pull of gravity.
Force sensor applications:
• An Elevator or Lift is a type of vertical
transportation that moves people or goods
between floors (levels, decks) of a
building, vessel, or other structure.
Force sensor characteristics:
• Model: FSR model 402
• Size: Diameter of 12.5mm and buffer area
of 0.02mm
• sensitivity: Infinite (Superior)
• Electricity: Less than 1mA of electrical
current.
How does it work ?
• The force sensors are majorly electronic
equipment whose underlying material can
be a force-sensing resistor. Generally,
the working principle of force sensors is
that they respond to the applied load and
weight and then transforms them into a
quantifiable output.
Sensor Testing:
• The easiest way to test the sensor is to
measure it’s resistance using ohmmeter.
• Connect the ohmmeter on the edge of the
sensor and press the sensor to see how
the pressure changes the resistance value
on the ohmmeter.
Sensor Testing:
Connection with Arduino:
• Connection Elements
Arduino
Wires FSR 402
sensor
Resistor Breadboard
Before we start:
• The force sensor is a variable resistance. The
value of this resistance varies depending on the
degree of pressure on it. It is an analogue sensor
analog which enables us to know the amount of
pressure generated on an area unit.
• So that we can read the values of this change
through the analogue outlets must be the change
inside the analogue outlets is a variable volt and
not resistance, and so we can read this type of
sensors must use a technique called voltage
divider.
Voltage Divider:
• A voltage divider is a simple circuit that
converts the high voltage to a lower
voltage.
• If we assumed that we had a Vcc voltage
source and we had two resistors R1, R2
the two resistors were connected
respectively as in the following picture:
Voltage Divider:
Voltage Divider:
• The amount of voltage on R2 resistance is
given by law:
Wires Raspberry Pi 3
FSR 402
sensor
Jaber Al Yamani
Optical Sensors and Optical
Fibers
• An optical sensor is a device that converts
light rays into electronic signals. Similar to a
photo resistor, it measures the physical
quantity of light and translates it into a form
read by the instrument.
• One of the features of an optical sensor is its
ability to measure the changes from one or
more light beams. This change is most often
based around alterations to the intensity of
the light.
Optical Sensors and Optical
Fibers
• The fiber optic sensors also called as
optical fiber sensors use optical fiber or
sensing element.
• These sensors are used to sense some
quantities like temperature, pressure,
vibrations, displacements, rotations or
concentration of chemical species.
• Fibers have so many uses in the field of
remote sensing because they require no
electrical power at the remote location and
Optical Fibers Basics
• An optical fiber is
composed of three
parts; the core, the
cladding, and the
coating or buffer.
• Optical fibers are
divided into two
groups called single
mode and multimode
Single mode Optical Fiber
• This type of optical
fiber transmits only
one mode of light.
• Single mode type of
optical fibers is much
better than multimode
optical fibers as they
have more
bandwidth and
experience fewer
losses.
• Used in applications
requiring longer
distance connections.
•
Multimode Optical Fibers
These types of
optical fibers allow
multiple modes of
light to travel along
their axis with thicker
core diameter.
• The reflection of the
waves inside the
multimode fiber
occurs at different
angles for every
mode.
• There are two types
of multimode optical
fibers: stepped index
and graded index.
Fiber Optic Sensor Principles