SENSOR &
ACTUATOR
Where do we use sensor and actuator?
• To implement process control (your embedded
system project), the system must collect data from
and transmit signals to the production process
• Components required to implement the interface:
• Sensors to measure continuous and discrete
process variables
• Actuators to drive continuous and discrete
process parameters
• Devices for ADC and DAC
• I/O devices for discrete data
DEFINITION
SENSORS & ACTUATORS
SENSORS
SENSORS
Sensor is a device, which responds to an
input quantity by generating a functionally
related output usually in the form of an
electrical or optical signal.
Ultrasonic Range Sensor Precision Temperature
Flex Sensor
Sensor (-40 - 100
ELE 551 FKE - HH/2012 degrees Celsius)
SENSORS
Stimulus (s) Signal (S)
Physical Sensing Conditioning Target
Medium Element Handling
Temperature Resistance Voltage Information
Transducers
Micro-sensors 10-6m
TYPE OF SENSORS
• Acoustic, sound, vibration
• Automotive, transportation
• Chemical
• Electric current, electric potential, magnetic, radio
• Environment, weather, moisture, humidity
• Flow, fluid velocity
• Ionizing radiation, subatomic particles
• Navigation instruments
• Position, angle, displacement, distance, speed,
acceleration
• Optical, light, imaging, photon
• Pressure
• Force, density, level
• Thermal, heat, temperature
• Proximity, presence
ELE 551 FKE - HH/2012
ANALOG SENSORS
Analog sensors:
• Output a voltage or current
• 0-5V is typical
• 4-20 mA is typical
Pros:
• Usually a bit cheaper
• Easy to use with MCU (microcontroller unit)
ADCs
Cons:
• Vulnerable to noise
• Must be careful with routing signals
ELE 551 FKE - HH/2012
ANALOG SENSOR
For example:
• The voltage output is non-linearly proportional to
the amount of reflected infrared light received by
the infrared phototransistor.
Basic design of IR proximity sensor
ELE 551 FKE - HH/2012
DIGITAL SENSORS
Digital sensors:
• PWM output
– Duty cycle
– Pulse Width
• Quadrature
Pros:
• Usually less vulnerable to noise
• Easy to use with MCU Input Capture Pin
• No complicated protocol
Cons:
• Strong noise can still malformed signal
ELE 551 FKE - HH/2012
DIGITAL SENSOR
For example:
• Ambient Light Sensor
• Frequency output
– Fixed 50% duty cycle
– Frequency changes
ELE 551 FKE - HH/2012
SENSOR CLASSIFICATION
ACTIV
E
PASSI
VE
ACTIVE SENSORS
• The active sensor require external power for their operation,
which is called an excitation signal. That signal is modified by
the sensor to produce the output signal.
• "Active sensors emit energy into the environment, then
measure the environmental reaction."
– Tactile Sensors: Optical barriers, non-contact proximity sensor
– Wheel/Motor: Optical, magnetic, inductive, and capacitive encoders
– Active Ranging: Reflectivity sensors, ultrasonic sensors, laser
rangefinder, optical triangulation
– Motion/Speed Sensors: Doppler radar/sound.
• Generally, since these sensors emit energy into the
environment, they require more power.
ELE 551 FKE - HH/2012
PASSIVE SENSORS
• A passive sensor does not need any additional energy
source and directly generates an electrical signal in
response to an external stimulus.
• "Passive sensors measure ambient environmental energy
entering the sensor."
– Tactile sensors: Bumpers, contact switches
– Wheel/Motor sensors: Brush encoders, potentiometers
– Heading Sensors: Compass, gyroscopes, accelerometers
– Vision based sensors: CCD/CMOS cameras, visual ranging
packages.
– Others: Temperature, microphones, pyroelectric IR (PIR)
• Generally, these kind of sensors require very little power.
ELE 551 FKE - HH/2012
ANALOG TO DIGITAL CONVERTER
An electronic
integrated circuit
Analog signals are
which transforms a
directly measurable
signal from analog
quantities.
(continuous) to digital
(discrete) form.
What is Digital signals only
have two states. “0”
ADC? and “1
ANALOG TO DIGITAL CONVERTER
Microprocessors can only
perform complex
processing on digitized
signals.
Why we
When signals are in digital
need form they are less
susceptible to the
ADC? deleterious effects of
additive noise.
ADC provides a link
between the analog world
of transducers and the
digital world of signal
processing and data
handling.
ANALOG TO DIGITAL CONVERTER
Microcontrollers commonly use
8, 10, 12, or
16 bit ADCs
ADC PROCESS
ADC PROCESS – Sampling and
Holding
Holding signal
benefits the
accuracy of the A/D
conversion
Minimum sampling
rate should be at
least twice the
highest data
frequency of the
analog signal
ADC PROCESS – Quantizing and
Encoding
ADC PROCESS – Quantizing and Encoding
Quantizing:
• Partitioning the reference
signal range into a
number of discrete
quanta, then matching
the input signal to the
correct quantum.
Encoding:
• Assigning a unique
digital code to each
quantum, then allocating
the digital code to the
input signal.
ADC OVERVIEW for ARDUINO
• ATmega 328 microcontroller is
manufactured with 10-bit of ADC
microprocessor.
• In particular, Arduino divides the range of 0
to 5 volts into 1024 different voltage levels
or intervals. 0 volts is in the interval 0, and
5 volts in the interval 1023.
• In this way, 2.5 volts would be in the
interval 511 as well as 2.52 volts or
2.5103.
ELE 551 FKE - HH/2012
ADC on ARDUINO
• Not every pin on a microcontroller has
the ability to do analog to digital
conversions. On the Arduino board,
these pins have an ‘A’ in front of their
label (A0 through A5) to indicate these
pins can read analog voltages.
• ADCs can vary greatly between
microcontroller. The ADC on the Arduino
is a 10-bit ADC meaning it has the ability
to detect 1,024 (210) discrete analog
levels. Some microcontrollers have 8-bit
ADCs (28 = 256 discrete levels) and
some have 16-bit ADCs (216 = 65,535
discrete levels).
ELE 551 FKE - HH/2012
10-bit ADC Transfer Function
ELE 551 FKE - HH/2012
10-bit ADC Resolution Range
ELE 551 FKE - HH/2012
Analog Input Range
ELE 551 FKE - HH/2012
Voltage Reference (Vref)
ELE 551 FKE - HH/2012
ACCURACY of ADC
There are two ways to best improve the accuracy of A/D
conversion:
• increasing the resolution which improves the accuracy in
measuring the amplitude of the analog signal.
• increasing the sampling rate which increases the
maximum frequency that can be measured.
Low accuracy Improved accuracy
SENSORS & ACTUATORS
ACTUATORS
Actuators
In this part we will look at:
• Servo Motor
• H-Bridge Motor
• Pulse-Width-Modulation (PWM)
ELE 551 FKE - HH/2012
Actuators
• Actuators can be built in many different
ways, most prominently:
– Electrical motors
– Pneumatic and valves
Servo Motor Stepper Motor Pneumatic valve actuator
ELE 551 FKE - HH/2012
Types of Actuator
• Solenoids, valves, cylinders
• Hydraulics, pneumatics
• Motors
• Heaters
• Lights
• Sirens/Horns (audio)
ELE 551 FKE - HH/2012
Servo Motors
ELE 551 FKE - HH/2012
Servo Motors
• Motor speed determined by:
– Supplied voltage
• Motor direction determined by:
– Polarity of supplied voltage
• Difficult to generate analog power directly
from microcontroller
– External amplifier (pulse-width modulation)
ELE 551 FKE - HH/2012
Brushed Motor: H-Bridge
• Allows a motor to be driven in both
directions
Drive forward:
• Close 1 and 4
Drive backward:
• Close 2 and 3
ELE 551 FKE - HH/2012
Controlling Brushed Motor: H-Bridge
Stepper Motor
• Converts electrical pulses into discrete
mechanical movement
• Shaft rotates in discrete step increments
• Full torque at standstill
• Precise positioning and repeatability
• No brushes
• Low-speed possible
• Cons:
Resonance can occur
Not easy to control at high speed
ELE 551 FKE - HH/2012
Stepper Motor
• Motor speed determined by: Supplied
Voltage
• Motor direction determined by: Polarity of
supplied voltage
• Difficult to generate analog power signal
(1A…10A) directly from microcontroller.
– External amplifier (Pulse Width Modulation).
ELE 551 FKE - HH/2012
Pulse Width Modulation (PWM)
• A/D converters are used for reading
analog sensor signals.
• Why not use D/A converter for motor
control?
Too expensive (needs power circuitry)
Better do it by software, eg. Switching power
on/off in intervals
• This is called “Pulse-Width
Modulation”/PWM
ELE 551 FKE - HH/2012
Pulse Width Modulation
How does this work?
• The supplied voltage did not change
• Power is switched on/off at a certain pulse ratio
matching the desired output power.
• Signal has very high frequency (eg. 20kHz)
• Motors are relatively slow to respond
• The only thing that counts is the supplied power
• Integral (summation)
• Pulse-width ratio = ton/tperiod
Pulse Width Modulation
Pulse Width Modulation
• A pulse that has finite length in time is called ‘time
on’ – it means how long was the electrical signal
present.
• Once the electrical signal is removed and until
the signal is applied again, is called ‘time off’.
• If the electrical signal changes to ‘on’ and ‘off’
with continuous and equal intervals of ‘time on’
and ‘time off’, the pulse is periodic. Its period is
equal to ‘time on’ + ‘time off’.
• The pulse period must remain constant in any
change of time.
RC Pulse Width Modulation
• Remote control/ RC PWM is different to
PWM signal used to control DC motor
speed.
RC Pulse Width Modulation
• RC Servos has designed to accept the RC
PWM signal which is periodic pulse with
1.0 ms to 2.0 ms width (standard).
• The idea behind this position protocol is
that 1.5 ms commands the servo to go to
the center position.
RC Pulse Width Modulation
• A 1.0 ms pulse commands the motor to
attempt to reach its leftmost position and
2.0 ms to its rightmost position.
• Any pulse measuring in between 1.0 ms
and 2.0 ms is decoded as a position in
between leftmost and rightmost.
• RC PWM signal can be generate using
microcontroller. The positions available are
dependent on timer resolution.
DC Motor Speed Control by PWM
• In DC motor it is important to decode the
position information (RC Pulse Width) and
generate a speed magnitude signal.
• This is done by achieving maximum
reverse speed when input is 1 ms. While,
the motor will stop at 1.5 ms.
• At 2.0 ms, DC motor will move forward at
maximum speed. Any other pulse width is
then decoded to partial speed on the
corresponding direction.
Controlling DC Motor : H-Bridge
• H-Bridge motor utilize PWM to control DC
motor speed.
• In H-Bridge motor, the duty cycle is
proportional to voltage applied into the
load –means that voltage applied is
directly proportional to motor speed.
• How the speed varies by changing PWM
duty cycle?
Cont. Controlling DC Motor
• The H-Bridge is chopping
the amount of time the
motor is receiving energy.
• By varying duty cycle, an
infinite amount of voltages
can be applied to the
motor. This will result, an
infinite DC motor speed
ranging from stopped
running at full speed.
Thank you for the attention !
Acknowledgement:
Thank you to Fadzliana Saad and Norhazlin Khairudin from FKE for the teaching
materials