程序代写接单-EECS 511 2022 Final

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top

EECS 511 2022 Final Assignment Version 1.1, assigned April 16, updated April 18 (see changes log in appendix) Due: April 26 6PM Overview In this assignment you will model a set-and-down SAR ADC with redundancy and noise shaping in MATLAB. The ADC have differential input with a nominal input range 0 to 1 on the positive (vinp) and negative (vinn) inputs. The input common mode is 0.5. The ADC has a nominal resolution specified by numbits. The input signal source is derived by from the vin vector. Both sine and ramp are possible depending on thevariablesine_input_mode. Hereissomesamplecodeforgeneratingtheinputsignals: if sine_input_mode fin=bin/samples; % samples is the total number of samples for the FFT vin=input_amps(j)*sin(2*pi*fin*t); else vin=-0.5:.001:0.5; % ramp test end vinp=0.5+vin; vinn=0.5-vin; Samples are at 1 Hz. These variables are provided: bin % The FFT bin number. Note the sample rate is 1Hz input_amps % a vector or input amplitudes. The nominal maximum is 0.5 sine_input_mode % 1 for a sine input, 0 for a ramp Use 216 samples for sine wave operation. However, allow an extra 10,000 samples at the beginning for the ADC to warm up. Redundancy and set-and-down operation Redundancy in a set-and-down ADC can be complicated. The sign bit can be especially tricky. We are providing some additional explanation to clarify things. (There are other ways of doing things but this approach is straightforward and consistent). Your MATLAB program should work with an arbitrary coding scheme. We will provide some examples to you and also test your code independently with different coding scheme. To explain things, we use this example for a 4 bit ADC: Weights = 6,4,2,2,1. This coding scheme has one redundant bit. The output code range is 0 to 15. In the example below we go through the sequence of decisions and the corresponding comparator input voltages. In this test we apply a positive input of 0.501 and a negative input of 0.499 (i.e., the common mode is 0.5). We see that the MSB decision (bit 1) is 1. The process for calculating the set-and-down voltages is shown. vcompp vcompn bit value 1 1 2 0 3 0 4 1 5 0 DAC change for next step sub 6/16 from vcompp sub 4/16 from vcompn sub 2/16 from vcompn sub 2/16 from vcompp 0.501 0.499 0.126 0.499 0.126 0.249 0.126 0.124 0.001 0.124 1 We calculate the overall decision value based on the weights. The key thing to notice is how the initial bit is calculated. Note that this gives an ADC range from 0 to 15. It is not signed. bit1*6+ bit2*4 + bit3*2 + bit4*2 + bit5*1 1*6 + 0*4+ 0*2 + 1*2 + 0*1 = 8 To test the benefit of redundancy you test the conversion with an error in the first SAR step. The variable first_step_error contains this error. This error can be thought of as an error in the first comparison (e.g. due to comparator offset or settling). All other comparisons are ideal. The data .mat file provided will have the following variables related to redundancy: numbits % the nominal number of bits for the ADC redun % extra bits for redundancy. This is 0 for binary coding next_range_mag_arr % Vector of weights. Does not include termination weight first_step_error % Error in first comparison. All other comparisons are ideal Noise shaping The noise shaping part of this assignment adds noise-shaping to the set-and-down ADC. The noise shaping should work with the redundant coding scheme. The noise-shaping should be first order and implemented with the error-feedback (EF) technique (i.e. not the CIFF technique). EF noise-shaping adds filtered quantization noise to the ADC input signal. With first-order EF noise- shaping, the filter HEF is 1. However the feedback back should have a single sample of delay (i.e. z-1). The quantization noise is captured from the comparator input at the end of the conversion. However you must be careful how you do this. It will require an additional capacitor switching. You should also be careful how you careful how we calculate the quantization error. Assuming Dout*LSB=Vin+Q We get For a linear input we get this error characteristic Q=Dout*LSB – Vin Q LSB/2 0 -LSB/2 Code Code Code change change change Vin 1 LSB Vin span 2 You should use the capacitor DAC to generate the residue. As mentioned in class this will require an additional switching of the DAC after the final bit trial. The residue is the difference between The following variables are related to the noise-shaping operation: ns % ns=1 for noise shaping, and ns=0 for no noise shaping (i.e., no EF) OSR % oversampling ration EF_gain % error feedback gain, ideally = 1 Testing and reports Your code should begin by loading the settings .mat file. The code should ask for the name of this file. Here’s some sample code for this purpose: test_data_file = input('Please input the name of the test data file: ','s'); load(test_data_file) There are two test scenarios: sine wave testing and ramp testing. The requirements differ for each so please read carefully: Sine wave testing • sine_input_mode = 1 • Use Blackman windowing • Report the main settings (amplitude, OSR, noise shaping on/off etc) • Calculate and report the SNDR for the OSR • Single amplitude testing: o input_amps is just a single number o PlottheFFT,usealogfrequencyaxis o Identifyingthebandwidthwithaverticalline o TitlethegraphwiththeSNDR o Onaseparatefigure,plottheresidueversusvin(Forsamplesfrom10000to20000) • Multiple amplitude testing: plot the SNDR vs amplitude o input_amps is a vector o ProvideasinglegraphofSNDRvsinput_amps o Usealoghorizontalaxis o ReportthemaximumSNDR Ramp testing • sine_input_mode = 0 • Provide a single plot with multiple subplots o Digitaloutputvsdifferentialinputvoltage o Residue(generatedbyDAC)plottedversusdifferentialinputvoltage • The input is the full ADC range What to report • This should be your own work. o Insomecaseswewillusecodeplagiarismchecking. • Submit the following on Gradescope in a single pdf file o Commentedcode o Outputsandplotsforthetestsettingsprovided o Therewillbe3testsettingfilesprovided. o Use1pageforeachrun,showingplots,settings,resultsandthenameofthetestfiles. • You will also submit your MATLAB file on Canvas so we can test your code o Yourcodeshouldbeasingleself-contained.mfile. 3 Appendix Grading The following will be considered for grading: - - - - - Your code Operation as a SAR without redundancy Operation as a SAR with redundancy Residue capture from the SAR Noise shaped SAR operation not an exclusive list. We will look at the outputs you provide and also test your code with This is some additional scenarios. Variable provided in settings .mat file bin % The FFT bin. Note the sample rate is 1Hz input_amps % a vector or input amplitudes. The nominal maximum is 0.5 sine_input_mode % 1 fir sine input, 0 for a ramp numbits % the nominal number of bits for the ADC redun % extra bits for redundancy. This is 0 for binary coding next_range_mag_arr % Vector of weights. Does not include termination weight first_step_error % Error in first comparison. All other comparisons are ideal ns % ns=1 for noise shaping, and ns=0 for no noise shaping (i.e., no EF) OSR % oversampling ratio EF_gain % error feedback gain, ideally = 1 Calculating redundant code radix and weights We will provide the SAR weights for the assignment. However, some code for generating weights is also provided here: % first calculate x for ideal redundancy % subtract 1 due to sign bit being counted as one of numbits target=2^(numbits)-1; test_x=1.5000000; total=0; while total<target test_x=test_x+0.0000001; total=0; for j=1:(numbits)+redun total=total+test_x^(j-1); end end x=test_x; txt=sprintf('x = %0.7g',x); disp(txt) % quantized ranges for steps=1:(numbits)+redun next_range_mag_arr(steps)=round(x^((numbits)+redun-steps)); end % steps txt=sprintf(' %0.7g',next_range_mag_arr); txt2=strcat('Weights', txt); disp(txt2) 4 First example of run and plots Set and down ADC with redundancy and noise shaping Please input the name of the test data file: test.mat Noise shaping on EF gain: 1 Sine wave mode OSR: 8 Nominal bits: 4 Redundancy bits: 1 Weights: 6 4 2 2 1 First decision error: 0.0625 Input amplitude vector: 0.4 Uses Blackman windowing SQNR no window 46.6827 SQNR with Blackman window 46.6926 100 50 0 SNDR 46.6926 -50 10 10 10 10 10 10 15 10 5 0 0.06 0.04 0.02 0 -0.02 -0.04 -0.06 0 0 X 167 Y9 200 400 600 800 Vin 2000 4000 6000 8000 Vin 1000 1200 10000 12000 012345 Frequency Residue dB Code 5 First example of run and plots Set and down ADC with redundancy and noise shaping Please input the name of the test data file: test.mat Noise shaping off Ramp mode OSR: 8 Nominal bits: 4 Redundancy bits: 1 Weights: 6 4 2 2 1 First decision error: 0.0625 Uses Blackman windowing >> 15 10 5 0 -0.5 -0.4 -0.3 0.06 0.04 0.02 0 -0.02 -0.04 -0.06 -0.5 -0.4 -0.3 Changes log -0.2 -0.1 0 vin -0.2 -0.1 0 vin 0.1 0.2 0.3 0.4 0.5 0.1 0.2 0.3 0.4 0.5 Updates highlighted in yellow Version 1.1 April 18 fixed typo on page 3 2000=> 20000 6 Residue code


51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468