Transcript Exam Case

System Functional Requirements
 Children’s toy…comes with PC software. Child plays notes on the screen
and the device makes corresponding tones. It can generate 3 tones
simultaneously (A chord)
 Child can save a song to be played at any time. The song is stored on the
PC and “streamed” out to the device to be played.
 The beginning of a command always has the MSB = 1
 If bit 6 of the first byte = 1 then there are two more bytes for a total of 24
bits.
 TNE: 7 bits indicating the number of time units until the next event
 F1: 5 bits, indicating frequency of channel 1 (0 means off)
 F2: 5 bits, indicating frequency of channel 2 (0 means off)
 F3: 5 bits, indicating frequency of channel 3 (0 means off)
 If bit 6 is a 0 then it is a 1 byte command indicating tempo:
 TEMPO : 6 bits, indicates the number of samples/time unit. It is a
linear scale with the fastest tempo equal to 1/16 of a second
 Note: the frequency number selects from a set of notes. 5 bits gives 32
notes. With sharps and flats (12 notes?) that is a bit less than a 3 octave
range.
CSE466 Autumn ‘00- 1
MIDI (Musak) Synthesizer
 Digital to Analog Converter
SW?
8
DAC
AMP
(V to I)
8051
Voltage signal
Speaker cares about current, not voltage
What is algorithm to superimpose 1KHz tone with 500Hz tone
With a sampling rate of 10KHz
CSE466 Autumn ‘00- 2
Digital-to-Analog Converter
Vref
out1
Memory
Mapped
device
input
AMP
\write
8051
port0 data
DAC
gnd
CSE466 Autumn ‘00- 3
Summation of tones gives a composite tone
 Add waveforms to get multiple tones
4
3.5
3
2.5
tone1
2
tone2
1.5
tone3
1
0.5
31
28
25
22
19
16
13
10
7
4
1
0
Note that lower frequency is smoother for a given sample rate
CSE466 Autumn ‘00- 4
Synthesizer Algorithm – Constant Sample Rate
 Let sin[] be a look up table with 256 entries (1 complete cycle)
 Every .1ms (10KHz)
 Output = (sin[t1] + sin[t2] + sin[t3])/3  three superimposed tones (a chord!)
 t1 += stride1, t2 += stride2 , t3 += stride3
 f1 = (10Ksamples/sec * stride1/256 cycles/sample) = f cycles/sec
 If stride = 1 then frequency = 10KHz/256 = 39.0625
 If stride = 25.6 then frequency = 1KHz is this hard? how do we implement this?
 If stride = 256/20 then frequency = 500Hz
 At 8-bit resolution we can vary output from 0 to 255. Hi frequencies are smoother
255
128
0
 Can generate arbitrary waveforms (not just tone summations) but that is harder. This
is what those ‘bad’ synthesizers do. The good ones take a sample of the real
instrument and modify it for pitch, etc.
CSE466 Autumn ‘00- 5
Frequency range w/ fixed sample rate
 What is the max Stride for our lookup table?
 Does 128 give us a 5KHz signal?
 Let Stride = 1 and Sample Rate = 10KHz
 output frequency = 10KHz/256 = 39.0625Hz
 Solve for stride given desired frequency
 stride = (freq*256)/sample rate
 Middle C = 262Hz, so stride = 6.7072 can we just round this off?
 D = 294, so stride = 7.5264
 What happens for low frequencies
 Low F: 87.31Hz  stride = 2.235136
 Low E: 82.42Hz  stride = 2.109952
 what do we do with non-integral strides?
CSE466 Autumn ‘00- 6
Decomposition
 I suggest the following logical decomposition of work::
 Serial Thread
 Accepts encoded music commands from the serial port
 Implements the byte-for-byte protocol
 Music Thread
 Generates up to three tones using a fixed sample rate
 Keeps track of passage of time
 Controls tempo of the music and controls tone generation according to
incoming commands.
CSE466 Autumn ‘00- 7
Things to consider
 Would the streaming system work in manual play mode? What commands
would you send, and when? Are any modifications (e.g. new commands),
needed to support manual play mode?
 What are the top and bottom half decompositions?




Where is inter-task communication necessary? How would you do it?
Where are the critical sections in you system?
What are the deadlines in the system?
Are there any schedulability concerns? (assume a 32MHz 8051) What is the
worst case scenario? Do you have enough information? What else would
you need to know?
 What would a Linux device driver look like for this device, assuming that you
can get interrupts for completed serial transmissions like in the 8051? What
would the user program have to do? What would the device driver take care
of?
 The exam questions will be much more specific, quantified questions
pertaining to these general questions
CSE466 Autumn ‘00- 8