Introduction to Embedded Systems
Input / Output
Courtesy to Prof. Vahid for the resources used in preparing this lecture note.
Getachew Teshome (Room 120-B)
Addis Ababa University, AAIT
School of Electrical and Computer Engineering
December 2022
Input Output
Hardware + Software Hardware + Software
Processor
Sensor Actuator
Environment
If vehicle speed is below set point, increase speed.
If tachometer output is below SP, increase DUTY of drive.
Monitoring Input
Eg. Speaker Protection System
How often should this check be made?
• As fast as possible?
• Response Vs Processor Utilization
MONITORING OUTPUT
• Automatic Gear Shift /Speed Control
• Helicopter Tail Control
• QR Orientation Control
Capturing Input
• SAMPLING: Reading sensor value at a specified period
• SAMPLING RATE : Frequency
• SAMPLING INTERVAL: Period
• SAMPLE : Each data value
Eg
• Temperature sensor in Room conditioning
• Button Press on your phone
Sampling
Sampling period
• should be as large as possible
not to burden the CPU
• should not be to large
not to miss important events
Event Inputs
No system is infinitely fast to detect all events.
Decide on events of interest.
Eg:
₋ Length of speaker volume above threshold
₋ 500ms
₋ Pulse length from a button press
₋ 50ms
Choose Sampling period well below the minimum
pulse duration expected
Event Inputs
Minimum Inter-event Separation Time
Choose Sampling period well below the minimum
Inter-event Separation Time
Event Inputs
Eg
• Buttons on a feature phone
– Minimum duration of a press is 50ms
– Minimum interval b/n two distinct presses – 20ms
– Expected response following a press – 25ms
What should be the sampling period of the button
inputs?
Event Inputs
Eg: What should be the sampling rate?
1.a vehicle sensor in Automatic Traffic
Controller.
2.a burglar sensor that detects whether a person
has passed by the door.
Input Conditioning
Filtering: Ignoring unnecessary events/ values
₋ Input glitch
₋ Noise, EMI
₋ Button bouncing
₋ Button quality
Input Conditioning
Filtering: Ignoring unnecessary events/ values
₋ Hardware Solution
₋ Sensor with cleaner output
₋ Isolating sensor terminals
₋ Capacitor filters
₋ Software Solution
₋ Button debouncing
₋ Consecutive samples
Output Glitch
Example 1
Counter
reset Hold/
Latch
latch
Output Glitch
Example 2
I/O Electrical issues
Low Output capacity
Buffer – boost voltage and/or current
Low capacity Load
Limiting resistor
Indeterminate Pin status
Drive every pin
Pull-up configuration
IO Issues
SHORTAGE OF PINS
• Encoding Input
– Eg Multiple Buttons
i1
i2
i3
.
.
.
Encoder
.
.
.
.
i9
i10
SHORTAGE OF PINS
• Decoding Output
– Eg Multiple LED o/p i1
i2
i3
.
.
Decoder
.
.
.
.
.
i9
i10
SHORTAGE OF PINS
• Time-multiplexed output with registers
SHORTAGE OF PINS
• Time-multiplexed output with rapid refresh
Loop{
PORTA =d3
PORTB= 0X07
Delay(t);
PORTA =d2
PORTB=XXXX1011, PORTB | 0X0B
Delay(t);
PORTA =d1
PORTB=XXXX1101, PORTB | 0X0D
Delay(t);
PORTA =d0
PORTB=XXXX1110, PORTB | 0X0E
Delay(t);
}
Pin Requirement for n Digits
1 Digit n Digit 8 Digit 32 Digits
Baseline (No optimization) 8 8*n 64 256
Multiplexing with
Registers
Multiplexing with Rapid
Refresh
Multiplexing with Decoder
Multiplexing with Decoder
+ Counter
Multiplexing with Ring
Counter
Pin Requirement for n Digits
1 Digit n Digit 8 Digit 32 Digits
Baseline (No optimization) 8 8*n 64 256
Multiplexing with 8+n 16 40
Registers
Multiplexing with Rapid 8+n 16 40
Refresh
Multiplexing with Decoder 8+log2n 11 13
Multiplexing with Decoder 8+1 9 9
+ Counter
Multiplexing with Ring 8+1 9 9
Counter
SHORTAGE OF PINS
Matrix Display (RxC)
Pin Requirement for n Digits
1 Cell 1 Row n Row n Row x
(16 Cells) (16 Cells) m Col
Baseline (No optimization)
Multiplexing with
Registers
Multiplexing with Rapid
Refresh
Multiplexing with Decoder
Multiplexing with Decoder
+ Counter
Multiplexing with Ring
Counter
SHORTAGE OF PINS
• Time-multiplexed Input (Input scanning)
char read_key (){
B = 0b1110;
Switch (A)
case (0b0111) return ‘A’;
case (0b1011) return ‘B’;
case (0b1101) return ‘C’;
case (0b1110) return ‘D’;
B = 0b1101;
Switch (A)
case (0b0111) return ‘3’;
case (0b1011) return ‘6’;
case (0b1101) return ‘9’;
case (0b1110) return ‘#’;
B = 0b1011;
…..
B = 0b0111;
…..
}
Alternative Approaches
When to read()?
Loop
Timer Interrupt
External Interrupt
How is Interrupt signal generated?
Using External Counters & Registers
Matrix Display
Large matrix displays
Large matrix displays
Large matrix displays
Large matrix displays
Large Graphic Display
• Architecture
– Dedicated Processor Display
– Dedicated Memory
• Color Display
– Bitmap, RGB CPU
– Resolution
Display
Display Memory
Display
CPU Controller
VGA
• VGA: Video Graphics Array
– 640 x 480 @60 Hz , 16 colors.
– 320 x 200, 256 colors
– R, G, B, Synchronization
• DVI: Digital Visual Interface
– 2560 x 1600 @144Hz
• HDMI: High Definition Multimedia Interface,
Touch Screen
• (x,y) Rx, Ry
• (x,y) Cx, Cy
Resistive Touchscreen
• User Presses Down
• Contact is Made
• Uniform Voltage on First
Screen for X
• Same on Second screen
for Y
• Happens instantaneously
4-Wire design
• One screen for X
• Another screen for Y
• Both create voltage
gradient.
• Uses voltage divider