Professional Documents
Culture Documents
Today: Basics of A/D and D/A. Spartan-3 analog I/O and DDS. Digilent family boards. Printed copy of todays lecture slides. VHDL materials on handouts web page Pedroni, data sheets, etc. Please keep the lab clean and organized. Last one out should close the lab door!!!!
Nothing is more dicult, and therefore more precious, than to be able to decide. Napoleon I.
EECS 452 Fall 2009 Lecture 9 Page 1/59 Mon 9/28/2009
HW 3b due this Wednesday. HWs 2 and 3 due this Friday. Project team formation and topic selection next Wed night.
Mon 9/28/2009
We will take a look at the basic idea behind these. We will introduce the A/D and D/A on S3-SB and other related IO. You will get to practice these in Lab 4. Discretize it in time: sampling or time quantization. Discretize it in value/amplitude: quantization or amplitude quantization. Reverse quantization: assign real value to each quantile Reverse sampling: interpolation (reconstruction)
Mon 9/28/2009
0.2
0.4
0.6
0.8 x 10
1
3
Analog waveform.
0.2
0.8 x 10
1
3
zero-
Mon 9/28/2009
Comments on sampling
Given a real valued lowpass spectrum with bandwidth BW (zero to null), the sampling frequency 2BW is often called the Nyquist sampling rate/frequency.
There is good reason behind this. You may recall from 216 and/or 451. We will take another more realistic look at this in another two lectures.
In practice one often should sample at a rate of at least two or three times the Nyquist sampling rate. It is also common practice to take the analog signal through an anti-alias lter before sampling.
We will see more details on this later, but this is basically a low pass lter to get rid of high frequency components in the analog signal. The AIC23 used on the C5510 DSK has built in anti-alias lters. The cuto frequencies change with the selected sampling rate.
Lecture 9 Page 5/59 Mon 9/28/2009
Many waveforms can have energy beyond a band of interest. Voice: fundamental around 150 Hz, overtones to about 5 kHz. male fundamental about 120 Hz. female fundamental about 200 Hz. bass low E is 82.4 Hz. soprano high C is 1,046.5 Hz. 27.5 Hz (A0) to 4816 Hz (C8).
Piano:
Normal young adult hearing range is 20 Hz to 20,000 Hz. Telephone nominally passes range 300 Hz to 3200 Hz.
Mon 9/28/2009
Common sampling rates: standard telephone system wideband telecommunications home music CDs professional audio DVD-Audio instrumentation, RF, video 8 kHz 16 kHz 44.1 kHz 48 kHz 192 kHz extremely fast
Mon 9/28/2009
Pencil and paper. Dual slope integration. Successive approximation. R-2R resistive ladders. charge redistribution. Flash. Delta-sigma (DSP systems in their own right).
Mon 9/28/2009
Mon 9/28/2009
Mon 9/28/2009
VRT
255
DRB (DATA READY) D8 (OVR) D7 (MSB) D6 D8B D7B DRB (DATA READY) D8B (OVR) D7B (MSB)
152
D5B
151
D3B D2B
D4B D3B D2B D1B D0B (LSB) DRA (DATA READY) DRA (DATA READY) D8A (OVR) D7A (MSB)
128
1:2 DEMULTIPLEXER
D5
D1B D0B
VRM
127
D4
64
D3
63
D2
D1
D2A D1A
D0 (LSB)
D0A
VRB
BANK A
D6A
BANK B
D6B
Mon 9/28/2009
Delta-sigma A/D
Basic idea is to save bandwidth by sending the changes (often encoded using a single bit) in a waveform rather than the full waveform. Samples very fast. Exploits the cheap availability and small size of todays digital logic. More details to come in a later lecture.
Mon 9/28/2009
To convert between the two formats, invert the most signicant bit.
EECS 452 Fall 2009 Lecture 9 Page 13/59 Mon 9/28/2009
Mon 9/28/2009
Uniform quantization
Converts analog voltages into B-bit numbers. Change in number by 1 is one quanta. One quanta change one voltage change. = Vp /2B 1 Usually place A/D bits into computer word most signicant bits. Note the placement of the zero input relative to the output count. Plots x-axis is normalized.
EECS 452 Fall 2009 Lecture 9 Page 15/59 Mon 9/28/2009
4bit linear quantizer input to output transfer function 8 6 Quanizer integer output 4 2 0 2 4 6 8 1 0.75 0.5 0.25 0 0.25 0.5 0.75 Quantizer analog input level 1
International Telecommunication Union ITU-T Recommendation G.711. Instead of using equal step sizes, use smaller steps for small input values. Why? What if you have a weak signal?
Mon 9/28/2009
Idea one: come up with unequal step sizes for the entire range. idea two: lets skew the signal instead.
stretch the small values and compress the large values. Now apply a uniform quantizer. This has an equivalent eect of assigning small steps when input is small, and large steps when input is large. y = Q sgn(x) ln(1 + |x |/V ) ln(1 + ) , = 255.
Implemented as logarithmic xed-point number sign, 3-bit. characteristic and 4-bit mantissa (8-bit code word). Performance roughly equivalent to 14-bit uniform (linear) encoding.
Lecture 9 Page 17/59 Mon 9/28/2009
The real world seems to always get in the way. Oset Error Gain Error Dierential Nonlinearity (DNL) Error Integral Nonlinearity (INL) Error Absolute Accuracy (Total) Error Aperture Error
Mon 9/28/2009
Now lets take a look at the amount of error we introduce in the process of A/D.
We know if we dont sample fast enough we get into trouble; details to come later. In quantization and encoding, analog values (uncountably innite) are converted into a nite number of values. Information is lost.
Digital values are most often represented using binary words. Common A/D word sizes are 8, 10, 12, 14, 16 and 24 bits. A word having B bits can represent 2B numeric values. The more A/D bits the greater the quality of the sampled data.
Mon 9/28/2009
The quantization errors are uniformly distributed over the range from /2 to /2. The quantization errors are independent of the waveform being quantized. Quantization error values are independent of each other. This leads to the concept of a white spectrum. The statistics of the quantization errors are wide sense stationary. A wide sense stationary random process is one whose rst and second moments are time invariant and whose autocorrelation function is invariant to time shift.
Mon 9/28/2009
xz xz=Z xz=H xz
xz
Sinewave quantization error using 4bit quantizer 1 0.5 Quanta 0 0.5 1 0 0.1 0.2 0.3 0.4 0.5 0.6 Sinewave period 0.7 0.8 0.9 1
Mon 9/28/2009
Really?
Do You Really Expect Me to Believe Those Assumptions? No. But you do have to start somewhere and these provide a relatively simple starting point. In actual practice these assumptions have proven to give surprisingly good results. Systems designed based on them often work as expected. On occasion, when designers run into problems they often think it is because of something they did. They forget that the theory is only an approximation to reality. Dont forget this!
Mon 9/28/2009
= =
0,
2 Vp 2 = 12 12 22B 2
3Px 2B 2 + 10 log10 2 Vp
Mon 9/28/2009
Reversing the quantization is easy. One of many ways: voltage divider. Whats the input-output mapping? Is there anything wrong with this scheme?
Mon 9/28/2009
Theoretically we can perfectly reconstruct if we sample fast enough. In practice sampling itself is imperfect. Example D/A output:
Three tones: 200 Hz, 1000 Hz, and 3500 Hz, fs = 8000 Hz. Using a zero-order hold D/A converter. The dashed line shows the eects of the zero-hold on the spectrum magnitude. It possesses images of the baseband spectrum.
Mon 9/28/2009
Anti-image lter
Zero-order hold has weighted (shaded) the spectrum. Low pass lter needed to attenuate/remove the images. Might correct for the zero-order hold amplitude shading. Low pass cuto will nominally be somewhat below fs /2. May have concerns about phase distortion. Filter may be solely analog or switched capacitor analog cascade.
Mon 9/28/2009
Basics of converting an analog signal to digital form. A/D: sampling and quantization. D/A: the reverse of the above processes. Next: the ADC and DAC on Spartan-3 and their use in Lab 4.
Mon 9/28/2009
Spartan-3 sub-family, S3, S3E. Size of the FPGA used. The type of external memory, static RAM, DRR2, paged and so on. Connectors used to connect o board devices to the FPGA. The over voltage protection included on the FPGA lines. extra and/or dierent o board connectors. Eight slide switches. Four digit seven segment display. Four push buttons. At least four 6-pin PMod connectors. A special board (MIB) is needed for the S3SB in order to add these.
Lecture 9 Page 29/59 Mon 9/28/2009
FPGA : XC3S1000 (106 gates) Package : FT256 (a ball grid package) Speed: -4 (not the fast part) EPROM : XCF04S (larger than on base board) Board powered by 5 Volt supply. Regulated voltage : 3.3 Volts. Signal lines are NOT 5 Volt tolerant!!!! Three 40-pin connectors, A1, A2 and B1. Supplied with Parallel Port JTAG programming cable. Cable supported by IMPACT and ExPort. Connector A2 cabled to C5510 External Peripheral Interface connector. Module Interface Board on B1 is used to convert 40-pin connector to 8 6-pin PMod connection positions.
Lecture 9 Page 30/59 Mon 9/28/2009
Dual 12-bit A/D converter, AD1. Dual 12-bit D/A converter, DA2. Four slide switches, SWITCH. Digital input, DIN1. Dual BNC, CON2. Speaker/headphone amplier, AMP1. Rotary encoder, ENC. and many more.
Given sucient lead time we can create our own project specic boards.
Mon 9/28/2009
P1: CS P2: Data1 J1 Connector ADC 1 Filter P1 J2 Connector P2 P3: Data 2 P4: Clk P5: GND P6: Vcc AD1 Circuit Diagram ADC 2 P3 P4 P5 P6
Filter
We have modied our MIB boards to have sockets in positions J1, J3, J5, J7 and pins in the other positions. The UCF naming is J1pmod_a, J3pmod_b, J5pmod_c and J7pmod_d.
Mon 9/28/2009
Pins on MIB connect to pins on PMod modules. We have installed sockets on alternate positions. Use socket-socket cables to connect pins. Make sure VB on MIB connects to VCC on PMod! Make connections with power OFF! For now connector A1 is not being used. (Actually is connected to memory bus which is used by the XVGA entity.) A2 is reserved for connecting to DSK peripheral interface bus to the Spartan-3 Starter Board. B1 is left for use by other devices. MIB goes here ! The Spartan-3 Starter Boards has provision for lots of connections. This is the primary reason we chose it.
Lecture 9 Page 33/59 Mon 9/28/2009
On the S3SB:
PMod pins
PMod pin names used on the MIB.
general I/O general I/O general I/O general I/O power ground. never use any voltage other than 3.3 volts.
GND
Names used on individual boards vary with the board. Please try very hard to connect V to the V pin on the PMod being plugged in. Things will often work better that way.
Mon 9/28/2009
Our goal is to always place, one to all, the switch, A/D and D/A PMod boards as follows.
Four slide switch PMod goes J1 (PMod A). A/D PMod goes J3 (PMod B). available, J5 (PMod C). D/A PMod goes J7 (PMod D).
Mon 9/28/2009
Lab exercise 4
Demonstrates:
interfacing the PMod DA2 D/A converter, DDS using the S3SB, interfacing the PMod AD1 A/D converter, single supply level shifting, S3SB electret microphone interface. simple A/D in, D/A out loop, S3SB/C5510 link, C5510 master, metastability demonstration, S3SB/C5510 link, S3SB master.
The exercise introduces the dual-channel A/D and D/A PMod modules.
Mon 9/28/2009
Two chips mounted per PMod board. One converter per chip. Four lines: data 1, data 2, sync, clock. Max clock rates of 30 (D/A) and 20 (A/D) MHz.! 16-bit data frames are used.
Low level entities were created rst. Attention was given on these would be used by higher levels. Tested using test VHDL. These might be considered device drivers written in VHDL.
Mon 9/28/2009
determine the part number. see how the part is designed into the board. nd the PMod pin signal assignments.
how it works. Actually, to learn how to make it work. the signal timings. the mapping from digital input values to output voltages.
Mon 9/28/2009
J1 Connector
D2 GND
VCC
The PMod-DA2 uses two National Semiconductor DAC121S101 12-bit digital-to-analog converters with rail-to-rail output. Uses a bit-serial interface. Maximum serial clock rate is 30 MHz. Operates using supply voltages in the range 2.7V to 5.5V.
Figure from the PMod Digilent data sheet.
Mon 9/28/2009
20114906
Mon 9/28/2009
sync_n can remain high between updates going low when a serial transfer is to start. The start of a serial transfer is detected by sampling sync_n using the rising edges of sclk. Data bits are sampled on the falling edges of sclk. There is a counter in the D/A that loads D/A holding register from the input shift register. Possibly on the 16th falling edge of sclk. After loading the DAC register the state machine waits for the next high to low transition on sync_n
Mon 9/28/2009
Mon 9/28/2009
Mon 9/28/2009
Initiating a conversion
This entity is designed so that the go and the clk signal can exist in dierent clock domains. Moving a signal between clock domains usually involves a level in one domain whose change signals an event, and a clock in a second domain that samples the event signal. If the setup time on the register being used to latch the event is smaller than required, the register can enter a metastable state. A metastable state is one where the latch knows that a decision is needed about whether or not the event occurred, but it cant decide. In theory this can take forever. Metastable events cannot be avoided. However there are things that one can do to minimize the probability of a metastable state becoming a problem.
Mon 9/28/2009
Walk through
50 MHz clock is assumed. 25 MHz SCLK is generated unless explicitly held high. 25 MHz is within the the D/A 30 MHz limit. GO pulses are assumed to be spaced at least 1 s apart. Only needs to be one 50 MHz clock period long. When GO is 1 then set four-bit counter to 0, copy 12-bit a and b values into 16-bit shift registers with normal ag bits. Send sync_m and SCLK low. Skip the low part of SCLK. Loop changing state only when SCLK is low. At the low to high transition, shift data, increment the counter. However, if the counter is 15 then also set sync_m high and go back to idling state.
Recall that the values to be updated are updated on the NEXT rising edge of the clk.
EECS 452 Fall 2009 Lecture 9 Page 46/59 Mon 9/28/2009
= | ~=~~ NR NQ NP NO NN NM
Mon 9/28/2009
Mon 9/28/2009
Now that we have a D/A driver and know how to make a counter lets make a sine wave direct digital synthesizer! The Xilinx CORE Generator provides modules for a sine/cosine lookup table and for a DDS. We could use these. Some other day. For now we will go DIY (using the DDS VHDL code we showed in the previous lecture). To create a DDS we need a ROM and we need to program the ROM.
Mon 9/28/2009
Mon 9/28/2009
begin AC0 <= ACC0(31 downto 24); AC1 <= ACC1(31 downto 24); process(clk, reset) begin if reset = 1 then elsif rising_edge(clk) then counter <= counter_next; ACC0 <= ACC0_next; ACC1 <= ACC1_next; FTV0R <= FTV0R_next; FTV1R <= FTV1R_next; DAC_load <= DAC_load_next; end if; end process;
Mon 9/28/2009
Mon 9/28/2009
256 values of 16-bits. Used MATLAB to generate. Primary thing to realize is that the least signicant bit is on the right and the most signicant bit is on the left.
Mon 9/28/2009
Filter
That was D/A. Now lets take a look at the A/D PMod. The PMod-AD1 uses two National Semiconductor ADCS7476 12-bit analog-to-digital converters supporting rail-to-rail input. Uses a bit-serial interface. Maximum serial clock rate is 20 MHz. Operates using supply voltages in the range 2.7V to 5.25V.
Figure from the PMod Digilent data sheet.
Mon 9/28/2009
Mon 9/28/2009
oR
Analysis of this is included in the lab write-up. A common problem well encounter is that our signals are zero referenced: it is centered on zero and swing between positive and negative voltage levels. Most of todays signal sources are voltage sources and DC coupled sources. The problem is that the ADC expects voltages from 0 to Vcc. So we need to shift the signal voltage.
EECS 452 Fall 2009 Lecture 9 Page 57/59 Mon 9/28/2009
type t_state is (s_idle, s_convert); signal state : t_state; begin pmod(0) <= cs_n and (not goo); ad0 <= pmod(1); ad1 <= pmod(2); pmod(3) <= sclk; process(go, clear_goo) is begin if clear_goo = 1 then goo <= 0; elsif rising_edge(go) then goo <= 1; end if; end process; -- main process goes here end Behavioral;
Mon 9/28/2009
Mon 9/28/2009