chapter 4 standard single purpose processors: peripherals
DESCRIPTION
Chapter 4 Standard Single Purpose Processors: Peripherals. Red A. Vd. 1. 16. Vm. White A’. A’. 2. 15. B. Yellow B. A. 3. 14. B’. Black B’. 4. 13. GND. GND. 5. 12. Bias’/Set. 6. 11. Phase A’. Clk. 7. 10. CW’/CCW. O|C. 8. 9. - PowerPoint PPT PresentationTRANSCRIPT
1
Embedded Systems Design A Unified HardwareSoftware Introduction
Chapter 4 Standard Single Purpose Processors Peripherals
2Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor controller
Red AWhite ArsquoYellow B
Black Brsquo
MC
3479P
1
5
4
3
2
7
8
6
16
15
14
13
12
11
10
9
Vd
Arsquo
A
GND
BiasrsquoSet
Clk
O|C
Vm
B
Brsquo
GND
Phase Arsquo
CWrsquoCCW
FullrsquoHalf Step
Sequence A B Arsquo Brsquo1 + + - -2 - + + -3 - - + +4 + - - +5 + + - -
bull Stepper motor rotates fixed number of degrees when given a ldquosteprdquo signalndash In contrast DC motor just rotates when
power applied coasts to stop
bull Rotation achieved by applying specific voltage sequence to coils
bull Controller greatly simplifies this
3Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper Motor Operation
4Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor with controller (driver)
2 Arsquo 3 A
10 7
B 15Brsquo 14
MC3479PStepper Motor
Driver 8051
P10P11
StepperMotor
CLK
CWrsquoCCW
The output pins on the stepper motor driver do not provide enough current to drive the stepper motor To amplify the current a buffer is needed One possible implementation of the buffers is pictured to the left Q1 is an MJE3055T NPN transistor and Q2 is an MJE2955T PNP transistor A is connected to the 8051 microcontroller and B is connected to the stepper motor
Q2
1K
1KQ1
+V
A B
void main(void)
turn the motor forward cw=0 set direction clk=0 pulse clock delay() clk=1
turn the motor backwards cw=1 set direction clk=0 pulse clock delay() clk=1
mainc
sbit clk=P1^1sbit cw=P1^0
void delay(void) int i j for (i=0 ilt1000 i++) for ( j=0 jlt50 j++) i = i + 0
5Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor without controller (driver)
StepperMotor
8051
GND +VP24
P23P22P21P20
A possible way to implement the buffers is located below The 8051 alone cannot drive the stepper motor so several transistors were added to increase the current going to the stepper motor Q1 are MJE3055T NPN transistors and Q3 is an MJE2955T PNP transistor A is connected to the 8051 microcontroller and B is connected to the stepper motor
Q2
+V
1KQ1
1K
+V
A
B
330
maincsbit notA=P2^0sbit isA=P2^1sbit notB=P2^2sbit isB=P2^3sbit dir=P2^4
void delay() int a b for(a=0 alt5000 a++) for(b=0 blt10000 b++) a=a+0
void move(int dir int steps) int y z clockwise movement if(dir == 1) for(y=0 ylt=steps y++) for(z=0 zlt=19 z+4) isA=lookup[z] isB=lookup[z+1] notA=lookup[z+2] notB=lookup[z+3] delay()
counter clockwise movement if(dir==0) for(y=0 ylt=step y++) for(z=19 zgt=0 z - 4) isA=lookup[z] isB=lookup[z-1] notA=lookup[z -2] notB=lookup[z-3] delay( ) void main( ) int z int lookup[20] = 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 while(1) move forward 15 degrees (2 steps) move(1 2) move backwards 75 degrees (1step) move(0 1)
6Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Data conversion
Interface circuits
1048711 Anti-aliasing filter
1048711 Sample-and-hold (SH) circuit
1048711 Analog-to-digital converter (ADC)
1048711 Digital-to-analog converter (DAC)
1048711 Reconstruction filter
7Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA transfer curves
output
Quantization error
8Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA conversion
proportionality
Vmax = 75V
0V
11111110
0000
0010
0100
0110
1000
1010
1100
0001
0011
0101
0111
1001
1011
1101
05V10V15V20V25V30V
35V40V45V50V
55V60V65V70V
analog to digital
4
3
2
1
t1 t2 t3 t4
0100 1000 0110 0101
timeanalog input (V)
Digital output
digital to analog
4
3
2
1
0100 1000 0110 0101
t1 t2 t3 t4time
analog output (V)
Digital input
9Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD Data Converters
bull Sigma Deltandash High resolution low-to-medium
speed
bull Pipelinedndash Low-to-medium resolution high
speed
bull Flashndash Low resolution high speed
bull Successive approximation register (SAR)ndash Medium resolution medium speed
10Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
SAR AD Converter
VDAC
time
Vin
bit 3=0 bit 2=1 bit 1=0 bit 0=1
frac14 Vref
frac12 Vref
frac34 Vref
Vref
(MSB) (LSB)
Successive Approximation
Register (SAR)
DAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
Successive Approximation
Register (SAR)
DACDAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
0
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
2Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor controller
Red AWhite ArsquoYellow B
Black Brsquo
MC
3479P
1
5
4
3
2
7
8
6
16
15
14
13
12
11
10
9
Vd
Arsquo
A
GND
BiasrsquoSet
Clk
O|C
Vm
B
Brsquo
GND
Phase Arsquo
CWrsquoCCW
FullrsquoHalf Step
Sequence A B Arsquo Brsquo1 + + - -2 - + + -3 - - + +4 + - - +5 + + - -
bull Stepper motor rotates fixed number of degrees when given a ldquosteprdquo signalndash In contrast DC motor just rotates when
power applied coasts to stop
bull Rotation achieved by applying specific voltage sequence to coils
bull Controller greatly simplifies this
3Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper Motor Operation
4Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor with controller (driver)
2 Arsquo 3 A
10 7
B 15Brsquo 14
MC3479PStepper Motor
Driver 8051
P10P11
StepperMotor
CLK
CWrsquoCCW
The output pins on the stepper motor driver do not provide enough current to drive the stepper motor To amplify the current a buffer is needed One possible implementation of the buffers is pictured to the left Q1 is an MJE3055T NPN transistor and Q2 is an MJE2955T PNP transistor A is connected to the 8051 microcontroller and B is connected to the stepper motor
Q2
1K
1KQ1
+V
A B
void main(void)
turn the motor forward cw=0 set direction clk=0 pulse clock delay() clk=1
turn the motor backwards cw=1 set direction clk=0 pulse clock delay() clk=1
mainc
sbit clk=P1^1sbit cw=P1^0
void delay(void) int i j for (i=0 ilt1000 i++) for ( j=0 jlt50 j++) i = i + 0
5Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor without controller (driver)
StepperMotor
8051
GND +VP24
P23P22P21P20
A possible way to implement the buffers is located below The 8051 alone cannot drive the stepper motor so several transistors were added to increase the current going to the stepper motor Q1 are MJE3055T NPN transistors and Q3 is an MJE2955T PNP transistor A is connected to the 8051 microcontroller and B is connected to the stepper motor
Q2
+V
1KQ1
1K
+V
A
B
330
maincsbit notA=P2^0sbit isA=P2^1sbit notB=P2^2sbit isB=P2^3sbit dir=P2^4
void delay() int a b for(a=0 alt5000 a++) for(b=0 blt10000 b++) a=a+0
void move(int dir int steps) int y z clockwise movement if(dir == 1) for(y=0 ylt=steps y++) for(z=0 zlt=19 z+4) isA=lookup[z] isB=lookup[z+1] notA=lookup[z+2] notB=lookup[z+3] delay()
counter clockwise movement if(dir==0) for(y=0 ylt=step y++) for(z=19 zgt=0 z - 4) isA=lookup[z] isB=lookup[z-1] notA=lookup[z -2] notB=lookup[z-3] delay( ) void main( ) int z int lookup[20] = 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 while(1) move forward 15 degrees (2 steps) move(1 2) move backwards 75 degrees (1step) move(0 1)
6Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Data conversion
Interface circuits
1048711 Anti-aliasing filter
1048711 Sample-and-hold (SH) circuit
1048711 Analog-to-digital converter (ADC)
1048711 Digital-to-analog converter (DAC)
1048711 Reconstruction filter
7Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA transfer curves
output
Quantization error
8Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA conversion
proportionality
Vmax = 75V
0V
11111110
0000
0010
0100
0110
1000
1010
1100
0001
0011
0101
0111
1001
1011
1101
05V10V15V20V25V30V
35V40V45V50V
55V60V65V70V
analog to digital
4
3
2
1
t1 t2 t3 t4
0100 1000 0110 0101
timeanalog input (V)
Digital output
digital to analog
4
3
2
1
0100 1000 0110 0101
t1 t2 t3 t4time
analog output (V)
Digital input
9Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD Data Converters
bull Sigma Deltandash High resolution low-to-medium
speed
bull Pipelinedndash Low-to-medium resolution high
speed
bull Flashndash Low resolution high speed
bull Successive approximation register (SAR)ndash Medium resolution medium speed
10Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
SAR AD Converter
VDAC
time
Vin
bit 3=0 bit 2=1 bit 1=0 bit 0=1
frac14 Vref
frac12 Vref
frac34 Vref
Vref
(MSB) (LSB)
Successive Approximation
Register (SAR)
DAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
Successive Approximation
Register (SAR)
DACDAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
0
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
3Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper Motor Operation
4Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor with controller (driver)
2 Arsquo 3 A
10 7
B 15Brsquo 14
MC3479PStepper Motor
Driver 8051
P10P11
StepperMotor
CLK
CWrsquoCCW
The output pins on the stepper motor driver do not provide enough current to drive the stepper motor To amplify the current a buffer is needed One possible implementation of the buffers is pictured to the left Q1 is an MJE3055T NPN transistor and Q2 is an MJE2955T PNP transistor A is connected to the 8051 microcontroller and B is connected to the stepper motor
Q2
1K
1KQ1
+V
A B
void main(void)
turn the motor forward cw=0 set direction clk=0 pulse clock delay() clk=1
turn the motor backwards cw=1 set direction clk=0 pulse clock delay() clk=1
mainc
sbit clk=P1^1sbit cw=P1^0
void delay(void) int i j for (i=0 ilt1000 i++) for ( j=0 jlt50 j++) i = i + 0
5Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor without controller (driver)
StepperMotor
8051
GND +VP24
P23P22P21P20
A possible way to implement the buffers is located below The 8051 alone cannot drive the stepper motor so several transistors were added to increase the current going to the stepper motor Q1 are MJE3055T NPN transistors and Q3 is an MJE2955T PNP transistor A is connected to the 8051 microcontroller and B is connected to the stepper motor
Q2
+V
1KQ1
1K
+V
A
B
330
maincsbit notA=P2^0sbit isA=P2^1sbit notB=P2^2sbit isB=P2^3sbit dir=P2^4
void delay() int a b for(a=0 alt5000 a++) for(b=0 blt10000 b++) a=a+0
void move(int dir int steps) int y z clockwise movement if(dir == 1) for(y=0 ylt=steps y++) for(z=0 zlt=19 z+4) isA=lookup[z] isB=lookup[z+1] notA=lookup[z+2] notB=lookup[z+3] delay()
counter clockwise movement if(dir==0) for(y=0 ylt=step y++) for(z=19 zgt=0 z - 4) isA=lookup[z] isB=lookup[z-1] notA=lookup[z -2] notB=lookup[z-3] delay( ) void main( ) int z int lookup[20] = 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 while(1) move forward 15 degrees (2 steps) move(1 2) move backwards 75 degrees (1step) move(0 1)
6Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Data conversion
Interface circuits
1048711 Anti-aliasing filter
1048711 Sample-and-hold (SH) circuit
1048711 Analog-to-digital converter (ADC)
1048711 Digital-to-analog converter (DAC)
1048711 Reconstruction filter
7Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA transfer curves
output
Quantization error
8Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA conversion
proportionality
Vmax = 75V
0V
11111110
0000
0010
0100
0110
1000
1010
1100
0001
0011
0101
0111
1001
1011
1101
05V10V15V20V25V30V
35V40V45V50V
55V60V65V70V
analog to digital
4
3
2
1
t1 t2 t3 t4
0100 1000 0110 0101
timeanalog input (V)
Digital output
digital to analog
4
3
2
1
0100 1000 0110 0101
t1 t2 t3 t4time
analog output (V)
Digital input
9Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD Data Converters
bull Sigma Deltandash High resolution low-to-medium
speed
bull Pipelinedndash Low-to-medium resolution high
speed
bull Flashndash Low resolution high speed
bull Successive approximation register (SAR)ndash Medium resolution medium speed
10Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
SAR AD Converter
VDAC
time
Vin
bit 3=0 bit 2=1 bit 1=0 bit 0=1
frac14 Vref
frac12 Vref
frac34 Vref
Vref
(MSB) (LSB)
Successive Approximation
Register (SAR)
DAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
Successive Approximation
Register (SAR)
DACDAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
0
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
4Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor with controller (driver)
2 Arsquo 3 A
10 7
B 15Brsquo 14
MC3479PStepper Motor
Driver 8051
P10P11
StepperMotor
CLK
CWrsquoCCW
The output pins on the stepper motor driver do not provide enough current to drive the stepper motor To amplify the current a buffer is needed One possible implementation of the buffers is pictured to the left Q1 is an MJE3055T NPN transistor and Q2 is an MJE2955T PNP transistor A is connected to the 8051 microcontroller and B is connected to the stepper motor
Q2
1K
1KQ1
+V
A B
void main(void)
turn the motor forward cw=0 set direction clk=0 pulse clock delay() clk=1
turn the motor backwards cw=1 set direction clk=0 pulse clock delay() clk=1
mainc
sbit clk=P1^1sbit cw=P1^0
void delay(void) int i j for (i=0 ilt1000 i++) for ( j=0 jlt50 j++) i = i + 0
5Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor without controller (driver)
StepperMotor
8051
GND +VP24
P23P22P21P20
A possible way to implement the buffers is located below The 8051 alone cannot drive the stepper motor so several transistors were added to increase the current going to the stepper motor Q1 are MJE3055T NPN transistors and Q3 is an MJE2955T PNP transistor A is connected to the 8051 microcontroller and B is connected to the stepper motor
Q2
+V
1KQ1
1K
+V
A
B
330
maincsbit notA=P2^0sbit isA=P2^1sbit notB=P2^2sbit isB=P2^3sbit dir=P2^4
void delay() int a b for(a=0 alt5000 a++) for(b=0 blt10000 b++) a=a+0
void move(int dir int steps) int y z clockwise movement if(dir == 1) for(y=0 ylt=steps y++) for(z=0 zlt=19 z+4) isA=lookup[z] isB=lookup[z+1] notA=lookup[z+2] notB=lookup[z+3] delay()
counter clockwise movement if(dir==0) for(y=0 ylt=step y++) for(z=19 zgt=0 z - 4) isA=lookup[z] isB=lookup[z-1] notA=lookup[z -2] notB=lookup[z-3] delay( ) void main( ) int z int lookup[20] = 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 while(1) move forward 15 degrees (2 steps) move(1 2) move backwards 75 degrees (1step) move(0 1)
6Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Data conversion
Interface circuits
1048711 Anti-aliasing filter
1048711 Sample-and-hold (SH) circuit
1048711 Analog-to-digital converter (ADC)
1048711 Digital-to-analog converter (DAC)
1048711 Reconstruction filter
7Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA transfer curves
output
Quantization error
8Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA conversion
proportionality
Vmax = 75V
0V
11111110
0000
0010
0100
0110
1000
1010
1100
0001
0011
0101
0111
1001
1011
1101
05V10V15V20V25V30V
35V40V45V50V
55V60V65V70V
analog to digital
4
3
2
1
t1 t2 t3 t4
0100 1000 0110 0101
timeanalog input (V)
Digital output
digital to analog
4
3
2
1
0100 1000 0110 0101
t1 t2 t3 t4time
analog output (V)
Digital input
9Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD Data Converters
bull Sigma Deltandash High resolution low-to-medium
speed
bull Pipelinedndash Low-to-medium resolution high
speed
bull Flashndash Low resolution high speed
bull Successive approximation register (SAR)ndash Medium resolution medium speed
10Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
SAR AD Converter
VDAC
time
Vin
bit 3=0 bit 2=1 bit 1=0 bit 0=1
frac14 Vref
frac12 Vref
frac34 Vref
Vref
(MSB) (LSB)
Successive Approximation
Register (SAR)
DAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
Successive Approximation
Register (SAR)
DACDAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
0
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
5Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Stepper motor without controller (driver)
StepperMotor
8051
GND +VP24
P23P22P21P20
A possible way to implement the buffers is located below The 8051 alone cannot drive the stepper motor so several transistors were added to increase the current going to the stepper motor Q1 are MJE3055T NPN transistors and Q3 is an MJE2955T PNP transistor A is connected to the 8051 microcontroller and B is connected to the stepper motor
Q2
+V
1KQ1
1K
+V
A
B
330
maincsbit notA=P2^0sbit isA=P2^1sbit notB=P2^2sbit isB=P2^3sbit dir=P2^4
void delay() int a b for(a=0 alt5000 a++) for(b=0 blt10000 b++) a=a+0
void move(int dir int steps) int y z clockwise movement if(dir == 1) for(y=0 ylt=steps y++) for(z=0 zlt=19 z+4) isA=lookup[z] isB=lookup[z+1] notA=lookup[z+2] notB=lookup[z+3] delay()
counter clockwise movement if(dir==0) for(y=0 ylt=step y++) for(z=19 zgt=0 z - 4) isA=lookup[z] isB=lookup[z-1] notA=lookup[z -2] notB=lookup[z-3] delay( ) void main( ) int z int lookup[20] = 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 while(1) move forward 15 degrees (2 steps) move(1 2) move backwards 75 degrees (1step) move(0 1)
6Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Data conversion
Interface circuits
1048711 Anti-aliasing filter
1048711 Sample-and-hold (SH) circuit
1048711 Analog-to-digital converter (ADC)
1048711 Digital-to-analog converter (DAC)
1048711 Reconstruction filter
7Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA transfer curves
output
Quantization error
8Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA conversion
proportionality
Vmax = 75V
0V
11111110
0000
0010
0100
0110
1000
1010
1100
0001
0011
0101
0111
1001
1011
1101
05V10V15V20V25V30V
35V40V45V50V
55V60V65V70V
analog to digital
4
3
2
1
t1 t2 t3 t4
0100 1000 0110 0101
timeanalog input (V)
Digital output
digital to analog
4
3
2
1
0100 1000 0110 0101
t1 t2 t3 t4time
analog output (V)
Digital input
9Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD Data Converters
bull Sigma Deltandash High resolution low-to-medium
speed
bull Pipelinedndash Low-to-medium resolution high
speed
bull Flashndash Low resolution high speed
bull Successive approximation register (SAR)ndash Medium resolution medium speed
10Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
SAR AD Converter
VDAC
time
Vin
bit 3=0 bit 2=1 bit 1=0 bit 0=1
frac14 Vref
frac12 Vref
frac34 Vref
Vref
(MSB) (LSB)
Successive Approximation
Register (SAR)
DAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
Successive Approximation
Register (SAR)
DACDAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
0
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
6Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Data conversion
Interface circuits
1048711 Anti-aliasing filter
1048711 Sample-and-hold (SH) circuit
1048711 Analog-to-digital converter (ADC)
1048711 Digital-to-analog converter (DAC)
1048711 Reconstruction filter
7Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA transfer curves
output
Quantization error
8Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA conversion
proportionality
Vmax = 75V
0V
11111110
0000
0010
0100
0110
1000
1010
1100
0001
0011
0101
0111
1001
1011
1101
05V10V15V20V25V30V
35V40V45V50V
55V60V65V70V
analog to digital
4
3
2
1
t1 t2 t3 t4
0100 1000 0110 0101
timeanalog input (V)
Digital output
digital to analog
4
3
2
1
0100 1000 0110 0101
t1 t2 t3 t4time
analog output (V)
Digital input
9Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD Data Converters
bull Sigma Deltandash High resolution low-to-medium
speed
bull Pipelinedndash Low-to-medium resolution high
speed
bull Flashndash Low resolution high speed
bull Successive approximation register (SAR)ndash Medium resolution medium speed
10Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
SAR AD Converter
VDAC
time
Vin
bit 3=0 bit 2=1 bit 1=0 bit 0=1
frac14 Vref
frac12 Vref
frac34 Vref
Vref
(MSB) (LSB)
Successive Approximation
Register (SAR)
DAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
Successive Approximation
Register (SAR)
DACDAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
0
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
7Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA transfer curves
output
Quantization error
8Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA conversion
proportionality
Vmax = 75V
0V
11111110
0000
0010
0100
0110
1000
1010
1100
0001
0011
0101
0111
1001
1011
1101
05V10V15V20V25V30V
35V40V45V50V
55V60V65V70V
analog to digital
4
3
2
1
t1 t2 t3 t4
0100 1000 0110 0101
timeanalog input (V)
Digital output
digital to analog
4
3
2
1
0100 1000 0110 0101
t1 t2 t3 t4time
analog output (V)
Digital input
9Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD Data Converters
bull Sigma Deltandash High resolution low-to-medium
speed
bull Pipelinedndash Low-to-medium resolution high
speed
bull Flashndash Low resolution high speed
bull Successive approximation register (SAR)ndash Medium resolution medium speed
10Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
SAR AD Converter
VDAC
time
Vin
bit 3=0 bit 2=1 bit 1=0 bit 0=1
frac14 Vref
frac12 Vref
frac34 Vref
Vref
(MSB) (LSB)
Successive Approximation
Register (SAR)
DAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
Successive Approximation
Register (SAR)
DACDAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
0
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
8Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD and DA conversion
proportionality
Vmax = 75V
0V
11111110
0000
0010
0100
0110
1000
1010
1100
0001
0011
0101
0111
1001
1011
1101
05V10V15V20V25V30V
35V40V45V50V
55V60V65V70V
analog to digital
4
3
2
1
t1 t2 t3 t4
0100 1000 0110 0101
timeanalog input (V)
Digital output
digital to analog
4
3
2
1
0100 1000 0110 0101
t1 t2 t3 t4time
analog output (V)
Digital input
9Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD Data Converters
bull Sigma Deltandash High resolution low-to-medium
speed
bull Pipelinedndash Low-to-medium resolution high
speed
bull Flashndash Low resolution high speed
bull Successive approximation register (SAR)ndash Medium resolution medium speed
10Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
SAR AD Converter
VDAC
time
Vin
bit 3=0 bit 2=1 bit 1=0 bit 0=1
frac14 Vref
frac12 Vref
frac34 Vref
Vref
(MSB) (LSB)
Successive Approximation
Register (SAR)
DAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
Successive Approximation
Register (SAR)
DACDAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
0
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
9Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
AD Data Converters
bull Sigma Deltandash High resolution low-to-medium
speed
bull Pipelinedndash Low-to-medium resolution high
speed
bull Flashndash Low resolution high speed
bull Successive approximation register (SAR)ndash Medium resolution medium speed
10Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
SAR AD Converter
VDAC
time
Vin
bit 3=0 bit 2=1 bit 1=0 bit 0=1
frac14 Vref
frac12 Vref
frac34 Vref
Vref
(MSB) (LSB)
Successive Approximation
Register (SAR)
DAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
Successive Approximation
Register (SAR)
DACDAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
0
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
10Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
SAR AD Converter
VDAC
time
Vin
bit 3=0 bit 2=1 bit 1=0 bit 0=1
frac14 Vref
frac12 Vref
frac34 Vref
Vref
(MSB) (LSB)
Successive Approximation
Register (SAR)
DAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
Successive Approximation
Register (SAR)
DACDAC
Timing control
Sample amp hold
Register
StartCLKEOC
N bitsN bits
Vin
+
-
Start
CLK
CONV
SAH
EOC
CO
NVSAH
Conversion time
Anti-aliased signal
0
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
11Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Given an analog input signal whose voltage should range from 0 to 15 volts and an 8-bit digital encoding calculate the correct encoding for 5 volts Then trace the successive-approximation approach to find the correct encoding
515 = d(28-1)d= 85
Successive-approximation method
AD conversion using successive approximation
0 1 0 0 0 0 0 0
Encoding 01010101
frac12(Vmax ndash Vmin) = 75 voltsVmax = 75 volts
frac12(75 + 0) = 375 voltsVmin = 375 volts
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0frac12(75 + 375) = 563 voltsVmax = 563 volts
frac12(563 + 375) = 469 voltsVmin = 469 volts
0 1 0 1 0 0 0 0
frac12(563 + 469) = 516 voltsVmax = 516 volts
0 1 0 1 0 0 0 0
frac12(516 + 469) = 493 voltsVmin = 493 volts
0 1 0 1 0 1 0 0
frac12(516 + 493) = 505 voltsVmax = 505 volts
0 1 0 1 0 1 0 0
frac12(505 + 493) = 499 volts 0 1 0 1 0 1 0 1
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
12Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Analog-to-digital converters
Example You have a 12 bit AD and the range of the AD is -1V
to 1V If the output of the AD is ldquo001010111111rdquo
what analog voltage is at the input
We are trying to determine the analog input which is e
eVmax = d(2n ndash 1)
e(1 ndash (-1)) = d(2n ndash 1) note the range is shifted by 1V
d = ldquo001010111111rdquo = 703 n = 12 2n = 4096
e2 = 703(4096 ndash 1) = 7034095 = 01716722
e = 0343345 shifted back e = -1 + 0343345
= -0656654
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
13Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Exercises
1 You have a 4-bit ADC which has an input range from 2V to 3V It is sending the value ldquo1110rdquo What is the analog input Can you determine the tolerance (ie accuracy) of you answer
2 A 16 bit AD with a 0 to 5V range has itrsquos 8 most significant bits connected to an 8 bit DA with a range of 0 to 5V If the input to the AD is 3700V what is the output of the DA
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
14Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Interface with the microcontroller
Sample and hold
Anti-alias filter
fs2
mp ADC
StartEOC Vr+
Vr-
Vin
fs
mp DAC
StartEOC
I+I-
Dout
IV
Vr+
Din
Driver
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
15Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock (RTC)
bull Much like a digital wristwatch keeps the time and date
bull Typically composed of a crystal-controlled oscillator numerous cascaded counters and a battery backup
bull The crystal controlled oscillator generates a very consistent high frequency digital pulse that feeds the counters
bull Operation ndash The 1st counter counts up to the oscillator frequency (Example f = 32768kHz
first counter counts 32768 or 215 corresponding to 1 sec)
ndash At this point the 1st counter generates a pulse that feeds the 2nd counter that counts up to 59 and generates a pulse that feeds the 3rd counter
ndash The 3rd counter counts up to 59 and so on
ndash The hour date month and year counters work in a similar fashion
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp
16Embedded Systems Design A Unified HardwareSoftware Introduction (c) 2000 VahidGivargis
Real-time Clock
bull Provides a time-of-day clock and 100-year calendar with alarm features and battery operation
mp