7. WARNING
What Not To Think…
• “I am already engineer… this should be
good time to take a nap.”
• “Some of this is theory… why is this guy
wasting my time with that?”
• “I don’t have a clue what he’s talking
about.”
8. _an Introduction
• What is a system?
• A system is a way of working, organizing or doing one
or many tasks according to a fixed plan, program or
set of rules.
• A system is also an arrangement in which all its units
assemble and work together according to the plan or
program.
9. System Example
WATCH
•It is a time display SYSTEM
•Parts: Hardware, Needles, Battery, Dial,
•Chassis and Strap
RULES
1.All needles move clockwise only
2.A thin needle rotates every second
3.A long needle rotates every minute
4.A short needle rotates every hour
5.All needles return to the original position after 12 hours
10. Embedded System
•Definition: An Embedded System is one that has
computer hardware with software embedded in it as
one of its important components. •Its software embeds in
ROM (Read Only
Memory). It does not need
secondary memories as in
a computer
•SOFTWARE PROGRAM
•#include <16f876a.h>
#use delay (clock=20000000)
#byte PORTB=6
•HARDWARE
main()
{
set_tris_b(0);
portb=255; //decimal
delay_ms(1000);
portb=0x55; //hexadecimal
delay_ms(1000);
portb=0b10101010; //binary
delay_ms(500);
}
11. Components Of Embedded System
• It has Hardware
Processor, Timers, Interrupt controller, I/O Devices, Memories,
Ports, etc.
• It has main Application Software
Which may perform concurrently the series of tasks or multiple
tasks.
• It has Real Time Operating System (RTOS)
RTOS defines the way the system work. Which supervise the
application software. It sets the rules during the execution of
the application program. A small scale embedded system may
not need an RTOS.
13. Embedded System Constraints
An embedded system is software designed to keep in
view three constraints:
– Available system memory
– Available processor speed
– The need to limit the power dissipation
When running the system continuously in cycles of
wait for events, run, stop and wakeup.
14. What Makes Embedded Systems
Different?
• Real-time operation
• size
• cost
• time
• reliability
• safety
• energy
• security
15. Processor
• A Processor is the heart of the Embedded System.
• For an embedded system designer knowledge of
microprocessor and microcontroller is a must.
Two Essential Units: Operations
Control Unit (CU), Fetch
Execution Unit (EU) Execute
16. Various Processor
1. General Purpose processor (GPP)
Microprocessor
Microcontroller
Embedded Processor
Digital signal Processor
2. Application Specific System Processor (ASSP)
3. Multi Processor System using GPPs
17. Microprocessor
• A microprocessor is a single chip semi conductor
device also which is a computer on chip, but not a
complete computer.
• Its CPU contains an ALU, a program counter, a stack
pointer, some working register, a clock timing circuit
and interrupt circuit on a single chip.
• To make complete micro computer, one must add
memory usually ROM and RAM, memory decoder, an
oscillator and a number of serial and parallel ports.
18. History Of Microprocessor
•1st Generation (4 bit processors)
4004 and 4040 4 bit in early 1970 by Intel (Integrated Electronics)
•2nd Generation (8 bit processors)
8008 and 8080 8 bit in 1974 Intel with +5 V Input supply 8080 8085 8 bit
•3rd Generation (16 bit processors)
8086 16 bit. Same as 8086, the 8088 introduced 8088 has only 8 bit data bus
(This made it easier to interface to the common 8 bit peripheral devices
available at the time) Followed by: The 80186 & 80286 (16 bit processor), the
80386 & 80486
•(a 32 bit processor), leading to the Pentium range of microprocessors (64 bit
processors) available today. The 80x86 and Pentium processors have all been
designed for use in personal computer type applications and have large
memory maps.
19. Microcontroller
• A microcontroller is a functional computer
system-on-a-chip. It contains a processor,
memory, and programmable input/output
peripherals.
• Microcontrollers include an integrated CPU,
memory (a small amount of RAM, program
memory, or both) and peripherals capable of
input and output.
20. Microprocessor Vs Microcontroller
Microprocessor Microcontroller
It includes functional blocks of
The functional blocks are ALU, microprocessors & in addition has
registers, timing & control units timer, parallel i/o, RAM, EPROM, ADC
& DAC
Bit handling instruction is less, One or Many type of bit handling
two type only instruction
Rapid movements of code and data Rapid movements of code and
between external memory & MP data within MC
They are used for designing
It is used for designing general
application specific dedicated
purpose digital computers system
systems
21. Embedded Processor
• Special microprocessors & microcontrollers
often called, Embedded processors.
• An embedded processor is used when fast
processing fast context-switching & atomic
ALU operations are needed.
Examples : ARM 7, INTEL i960, AMD 29050.
22. Digital Signal Processor ‘DSP’
• DSP as a GPP is a single chip VLSI unit.
• It includes the computational capabilities of microprocessor
and multiply & accumulate units (MAC).
• DSP has large number of applications such as image
processing, audio, video & telecommunication processing
systems.
• It is used when signal processing functions are to be
processed fast.
Examples : TMS320Cxx, SHARC, Motorola 5600xx
23. Application Specific System
Processor (Assp)
• ASSP is dedicated to specific tasks and
provides a faster solution.
• An ASSP is used as an additional processing
unit for running the application in place of
using embedded software.
Examples : IIM7100, W3100A
24. Multi Processor System Using GPPS
• Multiple processors are used when a single
processor does not meet the needs of
different task.
• The operations of all the processors are
synchronized to obtain an optimum
performance.
25. Moore’s Law
• Moore's law describes a long-term trend in the history of
computing hardware.
• Since the invention of the integrated circuit in 1958, the
number of transistors that can be placed inexpensively on an
integrated circuit has increased exponentially, doubling
approximately every two years.
• The trend was first observed by Intel co-founder Gordon E.
Moore in 1965.
• Almost every measure of the capabilities of digital electronic
devices is linked to Moore's law: processing speed, memory
capacity, etc.
27. Other Hardware
• Power Source
• Clock Oscillator
• Real Time Clock (RTC)
• Reset Circuit, Power-up Reset and watchdog
timer Reset
• Memory
• I/O Ports, I/O Buses
• Interrupt Handler
• DAC and ADC
• LCD and LED Display
• Keypad/Keyboard
28. Applications
•Household appliances:
Microwave ovens, Television, DVD
Players & Recorders Audio players
•Integrated systems in aircrafts
and missiles
•Cellular telephones
•Electric and Electronic Motor
controllers
•Engine controllers in automobiles
•Calculators
• Medical equipment's ..etc
29. Pop Quiz:
A motor is like a(n)…
A) Resistor
B) Capacitor
C) Inductor
D) Crazy space-aged device we aren’t really
meant to understand
32. Well, think about it…
• An inductor is a short circuit at DC!
• This means we’ll have an infinite current!
• Infinite current = Infinite Speed!!
33. Get to the Point…
• A motor is like a REAL inductor…
not an IDEAL inductor.
• It has resistance!
34. Remember this Waveform!
• Note how the current levels off.
• This will provide a steady speed.
Vs Vs t
i (t ) e
R R
LR
35. H-Bridge Basics
• H-Bridges are used to control the speed and
direction of a motor.
• They control the motor using Power
Electronics… transistors to be precise.
36. What’s a Transistor?
• Transistors are electronic devices that can act
as either:
– Amplifiers
– Switches
• We’ll be using them as switches that control
the flow of power to the motor.
37. A Closer Look at Transistors
• Note how Digital Logic at the Base controls
Power Flow in the other two ports
38. Controlling Motor Speed
• By turning our transistors
(switches) ON and OFF really
fast, we change the average
voltage seen by the motor.
• This technique is called
Pulse-Width Modulation
(PWM).
39. What is PWM Signal ?
• PWM (Pulse Width Modulation): It’s a fixed
frequency and pulse modulated for fan
speed control.
• Whenever change the duty cycle, the speed
will be changed by system requirement.
Cycle
Duty Cycle 20% Duty Cycle 50% Duty Cycle 80%
Lowest Speed Middle Speed High Speed
Duty
Cycle
(DT)
Duty Cycle = DT / T (%)
40. PWM Basics
• The higher the voltage seen by the motor, the
higher the speed.
• We’ll manipulate the PWM
Duty Cycle.
41. The Problem with PWM…
Remember that: Motors are like inductors
Remember this waveform
42. What’s the Problem?
• If we switch our transistors too quickly, the
current won’t have enough time to increase.
43. The Solution:
• The period (not to be confused with duty cycle)
of our PWM needs to be long enough for the
current to reach an acceptable level:
44. Direction Control using the H-Bridge
• The H-Bridge Chip has a “Direction Pin” that can
be set using digital logic High/Low
• This pin enables/disables flow through the
transistors
45. The H-Bridge Chip
• The H-Bridge we’re using (the LMD18200) has
11 pins
• Some pins involve logic signals, others involve
power signals, others won’t be connected
• Power signals = No breadboard
• No breadboard = Soldering
46. H-Bridge Pins Layout
• Pin 1: Bootstrap 1 (10nF cap to Pin 2)
• Pin 11: Bootstrap 2 (10nF cap to Pin 10)
• Pin 2: Output to Motor (M+)
• Pin 3: Direction Input (From PIC)
• Pin 5: PWM Input (From PIC)
• Pin 6: Power Supply (Vs)
• Pin 7: Ground
• Pin 10: Output to Motor (M-)
• Pin 4: Brake (Not Used – Connect to GND)
• Pin 8: Current Sense (Not connected)
• Pin 9: Thermal Flag (Not connected)
48. Another Problem:
• We’re dealing with a high voltages and currents
that are being switched at high frequencies.
• This is going to cause spiking in our power
supply… not to mention a whack of noise.
• Surely there must be some kind of component
that prevents instantaneous changes in voltage.
49. Of Course! Capacitors!
• Capacitors across the H-Bridge power supply will
prevent spiking.
• Two parallel capacitors are recommended:
– 200uF
– 1uf
(Be sure to check voltage ratings)
• Why two capacitors?
50. Using The PIC for Motor Control
• We’ll use the PIC to generate digital logic
signals to control our H-Bridge transistors
• So we’ll need
– A digital high/low for direction
output_high(PIN_A0);
– A PWM for speed control
51. Setting the PWM Signal
• This can be tough because we need to use a
timer to set the PWM frequency.
• We also need to figure out how to control the
PWM duty cycle.
• This is going to take some programming!
52. Setting up a PWM Signal cont.
• Step 1:
Tell the PIC we want a PWM signal:
– setup_ccp1(CCP_PWM);
• Step 2:
The PIC uses a timer called “Timer2” to control
the PWM frequency. We need to set this
frequency:
– setup_timer_2(T2_DIV_BY_X, Y, Z);
But what are X, Y, and Z?
- See handout for example.
53. Setting up a PWM Signal cont.
• Step 3:
• We said before that setting the PWM Duty
Cycle will set the speed of the motor.
• So, to start the motor, we could say:
– set_pwm1_duty(#); (0 < # < 100)
• To stop the motor, we could say:
– set_pwm1_duty(0);
54. Motor Encoders
• Motor Encoders allow for us to track how far
travelled.
• The encoders count wheel revolutions using
optical sensors.
• These sensors count notches on the Drive Shaft
of the motor.
55. Some Encoder Details…
• There are 512 notches on the drive shaft.
• There is a 5.9:1 gear ratio. (This means the
drive shaft spins 5.9x faster than the wheel.)
• The top wheel speed is around 800rpm (using
a 30V supply).
56. Some Electrical Details…
• The encoders we’ll be using have 4 wires:
– 5V Power Supply (Red)
– GND (Black)
– Channel A a.k.a. CHA (Blue)
– Channel B a.k.a. CHB (Yellow)
• Channels A&B will give us the signals to count
wheel revolutions.
AKA=Also known as
57. How Encoders Work
• CHA and CHB are actually square
waves separated by 900.
58. Counting Encoder Cycles
• So, if we know the current encoder state and
the last encoder state, we can tell which
direction we’re going.
• By counting the number of times we’ve
changed states, we can tell how far we’ve gone.
• Just remember that there are 4 encoder states
per notch!
59. Grounding Advice
• What is “Ground”?
• Power Supply Grounds
• Batteries and Grounding
• Use a Grounding Panel!
• Attach your Panel to your Robot!!
61. PWM control Methods introduction
Use ON/OFF control by Transistor
Advantage:
Easy design and control method
Price cheaper.
Disadvantage:
Poor Reliability ( Transistor are
On/OFF continuously)
Error judgment of tachometer
signal.
63. Regulator Control Fan Configuration
Advantage:
The better Reliability
RPM Stable
Power efficiency saving.
Disadvantage:
Cost expensive.
Control Circuit
Complex
64. Control PWM Fan Configuration<Four Wires>
Vcc
•Fan Vcc
•System
PWM Fan Low High
PWM Speed Speed
System Signal
Motherboard Input
Low High
Tachometer
Speed Speed Output Signal
Oscillator
PWM Comparator Driver DC
Signal Controller Motor
Input Integration Block Block
Circuit Reference •PWM control
Voltage Configuration
67. PWM Input Signal Specification (from
system)
• PWM Operating Frequency : 25kHz ± 5kHz
• Maximum Input Low Voltage (VIL-MAX) = 0.8V
• Minimum Input High Voltage (VIH-MIN) = 2.0V
• High Input Impedance (10K ohms at least )
(Consider Fan-In Issue,Driver Capability)
Frequency = 25kHz
VIH-MIN=2.0V
VIL-MAX=0.8V
Input
Impedance
68. PWM Fan Specification
• Operation Voltage : 5V or 12V ± 10%
• Function: Locked Protection and Auto-restart
• Apply the Open Collector or Open Drain
Tachometer Output Signal
• Low Speed setting with 0~17% (or 20%) on
Same RPM level (Type B)
Vcc
FG FG
Open Collector Open Drain
Configuration Configuration
69. PWM Fan sample
Type A( For NB fan suggestion)
PWM Fan Duty Cycle v.s Speed
6000rpm Model
6500
6000
5500 •Fan Stop
5000
Duty Cycle
4500
4000
Speed
3500
3000
2500 •Fan Start_up
2000
Duty Cycle
1500
1000
500
0
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
Duty Cycle
70. PWM Fan sample
Type A( All kind of fan could be used.)
PWM Fan Duty Cycle v.s Speed
AD8025 Model
4000
3500
•Fan Stop
3000
2500 Duty Cycle
Speed
2000
1500
1000 •Fan Start_up
500
Duty Cycle
0
0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
Duty Cycle
71. PWM Fan sample
Type B(For Desktops fan suggestion)
PWM Fan Duty Cycle v.s Speed
4000
AD8025 Model
3500
3000
2500
Speed
2000
1500
•It’s same duty
1000 cycle curve for
500 fan start_up and
stop.
0
0% 10% 17% 20% 30% 40% 50% 60% 70% 80% 90% Full
Duty Cycle
• 71