IO and Peripherals - PowerPoint PPT Presentation

1 / 52
About This Presentation
Title:

IO and Peripherals

Description:

task goal (ref pos) UM003 Motor Control. Motor. encoder count (est pos) ... fm : Nyquist Frequency : highest frequency. 2fm : Nyquist Rate. Sampling a Sinusoid ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 53
Provided by: mat83
Category:
Tags: fm | peripherals | task

less

Transcript and Presenter's Notes

Title: IO and Peripherals


1
I/O and Peripherals
Key Concepts and Terms
  • control and status registers
  • ports
  • bitmasking
  • bit manipulation
  • device drivers
  • memory mapped I/O
  • bandwidth
  • synchronization
  • polling
  • busy waiting
  • serial and parallel interfaces
  • analog and digital signals
  • analog to digital conversion
  • sampling frequency
  • active high, active low
  • edge-triggered
  • level triggered
  • timing diagram

2
I/O and UM003
  • I/O
  • Ports
  • Device Drivers and Interfaces
  • Control and Status Registers
  • Synchronization Techniques
  • Signal Processing
  • Signal Types
  • Sampling
  • A/D Conversion

3
UM003 Robot (Motor) Controller
encoder count (est pos)
AtMega (PD Control)
Motor
Encoder
user command (ref pos)
Serial Comm
PWM signal (motor control)
task goal (ref pos)
Visual System
4
UM003 Motor Control
encoder count (est pos)
/3
/3
Motor
dir
Ch. A
Ch. B
PWM
dir
Motor
PWM
Ch. A
Ch. B
dir
PWM
Motor
Ch. A
Ch. B
5
(No Transcript)
6
Control and Status Registers
  • Initialization
  • direction
  • function
  • synchronization (when to read or write)
  • Interaction with peripheral
  • read or write value

7
PORTS
  • Atmega datasheet p. 365
  • PORTA 1B (3B)
  • DDRA 1A (3A)
  • PINA 19 (39)
  • winAVR io128.h (IO for atmega128)
  • / Input Pins, Port A /
  • define PINA _SFR_IO8(0x19)
  • / Data Direction Register, Port A /
  • define DDRA _SFR_IO8(0x1A)
  • / Data Register, Port A /
  • define PORTA _SFR_IO8(0x1B)
  • winAVR sfr_defs.h (special function register
    defs)
  • define _SFR_IO8(io_addr) ((io_addr)
    __SFR_OFFSET)

8
Read / Write to Ports
  • Memory-Mapped I/O
  • Port-Mapped I/O
  • DMA

out(PORTA, 0x33) or PORTA 0x33
9
Bit Manipulation


10
Control Status Register Pins/Ports
iom128.h / Port B Data Register - PORTB
/ define PB7 7 define PB6
6 set bit7, bit6, bit0 hi (equivalent to
0xC2) DDRB (1ltltPB7) (1ltltPB6) (1ltltPB0)
read 4 most significant bits data PINA 0xF0
11
UM003 Motor Control
encoder count (est pos)
/3
/3
Motor
dir
Ch. A
Ch. B
PWM
dir
Motor
PWM
Ch. A
Ch. B
dir
PWM
Motor
Ch. A
Ch. B
12
Decoder (motor position)
13
Reading Decoder on UM003
  • int32_t read_decoder_U7()
  • // select the appropriate decoder (U6/U7/U8)
  • PORTG 0x
  • //need to wait for a moment to ensure the demux
    has switched
  • delay_ms(10)
  • //read the data from the decoder and do
    something with it
  • int8_t data PINC
  • //now to reset the encoder
  • PORTG 0x
  • delay_ms(10)
  • //and lastly, turn the encoder back on (stop
    reset)
  • PORTG 0x00

14
Device Driver
  • Goal Hide the hardware completely.
  • ONLY module to read/write control status
    registers directly.
  • BUT, in embedded systems, little distinction
    between
  • application software, OS, and device drivers
  • The making of a device driver
  • Create interface to registers (.h file)
  • Define variables to track status.
  • Routine to initialize hardware.
  • API for users
  • Interrupt service routines.
  • First use polling to get driver working.

Writing Windows CE Device Drivers Principle to
Practice, Linux device driver design
embedded.com
15
Relating to the outside world
  • 4 categories of interfaces
  • parallel (digital, simultaneous bits at a time)
  • serial (digital, one bit at a time)
  • analog (voltage, continuum)
  • time (analog period, frequency, )
  • Types of Signals (signal processing world)
  • continuous-time (analog)
  • discrete-time (sampled analog signal or
    inherently discrete signal)
  • continuous-value
  • discrete-value
  • random (noise)

16
Synchronization (Timing the Communication)
CPU State Transition
EMS Figs 3.1 and 3.2 p. 143
17
Synchronization (Timing the Communication)
EMS Figs 3.3 and 3.4 p. 144
18
Latency
  • Latency
  • Real-Time Systems
  • Throughput (Bandwidth)

19
Synchronization Techniques(Im just waiting on a
friend)
  • blind cycle open door at precisely 204 pm
  • busy wait (gadfly) stand at the door
  • interrupt keep busy until doorbell rings
  • periodic polling doorbell broke, check every 5
    minutes
  • DMA friend lets herself in

20
Blind Cycle (Input)
char Input (void) PULSE Timer_Wait(5) retur
n(PORT)
Figs 3.5 and 3.6 from EMS
21
Blind Cycle (Output)
void Output (unsigned char LETTER)
PORTLETTER Pulse() Timer_MsWait(100)
Figs 3.5 and 3.6 from EMS
22
Busy Wait (Gadfly)
/ use spinlock to wait for i to change. /
static void f1() while (i0) / do
nothing - just keep checking over and over /
printf("i's value has changed to d.\n", i)
return NULL
Figs 3.7 from EMS
23
Interrupt (IN)
24
Interrupt (OUT)
25
Periodic Polling
do / play games, read, / / poll to
see if ready / status areWeThereYet()
while (status NO)
26
Motivations for Various Synchronization Techniques
EMS Table 4.1 p. 193
27
Peripherals and I/O
  • Ports
  • Device Drivers and Interfaces
  • Control and Status Registers
  • Synchronization

28
Peripherals and I/O
  • I/O
  • Ports
  • Device Drivers and Interfaces
  • Control and Status Registers
  • Synchronization
  • Signal Processing
  • Signal Types
  • Sampling
  • A/D Conversion

29
Input (Sensors) and Output (Actuators)
  • Force
  • Position
  • Motion (Acceleration, Velocity)
  • Temperature, Humidity
  • Chemical
  • Sound
  • Shape / Texture / Color
  • Motors (DC, Stepper, Servo)
  • LCD Display
  • LEDs
  • Alarm
  • Microwaves

30
Signals
  • Signal
  • a time varying physical phenomenon which is
    intended to convey information.

31
Relating to the outside world
  • 4 categories of interfaces
  • parallel (digital, simultaneous bits at a time)
  • serial (digital, one bit at a time)
  • analog (voltage, continuum)
  • time (analog period, frequency, )
  • Types of Signals (signal processing world)
  • continuous-time (analog)
  • discrete-time (sampled analog signal or
    inherently discrete signal)
  • continuous-value
  • discrete-value
  • random (noise)

32
Types of Signals
SS Fig. 1.3-1.5 p. 3
33
Computer ScienceThe Art of Compromise (or The
Art of Abstraction)
Accuracy

Space
Time
34
Sampling Methods
  • Sample and Hold (S/H)

SS Fig 7.1 p. 493
35
What computers understand
SS Fig 7.2 p. 493
36
Analog to Digital Conversion (ADC)
  • continuous-time, continuous-value
  • ? discrete-value, continuous-time
  • Using the process of
  • Sampling
  • Quantization
  • Encoding

37
ADC Process
SS Fig. 1.6 p. 4
38
Sampling
  • fs Sampling Frequency
  • Ts Sampling Period (time between samples)

39
Quantization
  • if n is the word length of the ADC
  • then
  • quantization noise

SS Fig. 7.4 p. 494
40
ADC Process
SS Fig. 1.6 p. 4
41
Encode
SS Fig. 1.8 p. 5
42
ADC Process
SS Fig. 1.6 p. 4
43
Sinusoidal Signals
RED 20sin(2pi50t) BLUE 40sin(2pi50t)
RED 40sin(2pi25t) BLUE 40sin(2pi50t)
44
Linear Combination of Sinusoids(Fourier Series)
SS Fig. 4.4 p. 211
45
Sampling a Sinusoid(How often, is often enough?)
  • Shannons Sampling Theorem
  • If sampled at a rate more than twice the highest
    frequency (of the component sinusoids)
  • it can be exactly reconstructed.
  • fm Nyquist Frequency highest frequency
  • 2fm Nyquist Rate

46
Sampling a Sinusoid(How often, is often enough?)
47
Sampling a Sinusoid(How often, is often enough?)
SS Figs 7.36, 7.37, 7.38
48
Sampling a Sinusoid(How often, is often enough?)
SS Figs. 7.39, 7.41 p. 515
49
Sampling a Sinusoid(How often, is often enough?)
RED 40sin(2pi25t) BLUE
40sin(2pi50t) BLACK BLUE RED
50
Sampling a Sinusoid(How often, is often enough?)
RTS Fig. 1.2 p. 4
51
Signal Processing (sub-basics)
  • Signal Types
  • Sampling
  • A/D Conversion

52
I/O and Peripherals
Key Concepts and Terms
  • control and status registers
  • ports
  • bitmasking
  • bit manipulation
  • device drivers
  • memory mapped I/O
  • bandwidth
  • synchronization
  • polling
  • busy waiting
  • serial and parallel interfaces
  • analog and digital signals
  • analog to digital conversion
  • sampling frequency
  • active high, active low
  • edge-triggered
  • level triggered
  • timing diagram
Write a Comment
User Comments (0)
About PowerShow.com