MEFT-SAD/2ndSEMESTER1rstLab Guide - 2017/2018
Periodic sampling and conversion of analog signals using the A-D module of the dsPIC30F4011 microcontroller. Digital analysis on time and frequency (FFT). Signal reconstruction.
Student nº
(You can use this doc as a template or any editor (e.g. LaTeX) to produce and PDF files. Include all the circuits used, plot and results. When needed extract screens and datafrom oscilloscope, showing the measured parameters. Attach the dsPIC “C” and Octave/MATLABwell commentedsource codes in the annexes, or better use github)
Fig.1 Partial diagram of the dsPIC30F4011 ADC internal module. Note there is a single ADC converter, 4 S&H block and 9 input channels.
Objectives:
The main goal with this activity is to get acquaintance with periodic sampling of analog electrical signals and the conversion to the digital values using a 10-bit ADC module included in the dsPIC30F4011 microcontroller. Use ofsimultaneous sampling, FFT and windowing. ADC clock jitter. Data Histograms.
Equipment:
- Microcontroller board (version 3)with microcontroller dsPIC30F4011
- “MPLAB X” programming software and “C” compiler “XC16”
- Electronic Test Bench with Signal generator/ Digital Oscilloscope /Multimeter
- Electronic “breadboard” (Each group should have and keep its own)
- Linux PC with a RS232 terminal app (e.g. Putty)
- Optional Audio board of the PC Linux stations / Audacity Software
Procedures:
1rstPart:Sampling and Acquisition:
1)Theoutput pin Electronic Test Bench Signal generator has a pure AC signal (zero DC offset) while the ADC module only accepts unipolar inputs(0-5V). You must design and build a small signal conditioning electronic circuit (Op-Amp Adder) to add a suitable DC offset to the signals adapted to the input range of the ADC. Check the min-max ranges with the oscilloscope and set the generator for a frequency close to 1 kHz.
2)Write a small program able to sample and convert a single sample of an electronic voltage and transmit the integer result to the PC using the serial RS232 interface.
3)Modify the program to acquire an array of samples (N=256 or512) from an analog signal and store them in the internal RAM memory. The sampling should be controlled within aninterrupt routine driven by a TIMERx module. This routine should also toggle an output pin (e.g. _LATF0) so that you can measure accurately the sampling rate with the oscilloscope and compare with your calculations. Get the Nyquist frequency. You should also implement a “software Level Trigger”function, i.e. the acquisition should only start when the signal reaches at the certain voltage level.
4)Transfer the full array to the PC and store in a text file to be plotted/analysed with MATLAB/Octave. Adjusting the generator frequency get the sample array in the followingcases:
- Sine wave with 4/5 FULL periods
- Sine wave 2 and ½ periods.
- Sine wave with fsinal ~ 70% fsampling (subsampling)
5)Using a second generator adapt the Op-Amp adderto make a sum of two sine waves withdifferentfrequencies. (measure both freq. values). Acquire and store the sampled data.
6)Build a RC low pass filter circuit with an fcut-off ~fNyquist/4. Use simple sine waveswith fsignal near to fcut-offin order to build a Bode Plot of the filter (amplitude & phase transfer function). Acquire both signals at the input and output of the filter. Note: you must use the dsPIC ADC inSimultaneous Sampling Mode.
7)Introduce an artificial “jitter” on the Timer, by changing the PRx (period) in the TIMERx interrupt routine with a pseudo-random function up to +- 10%. Get the data arrays for the signal 4a.)
8)Use a single sinus signal with a very low frequency and make sure you are using the whole ADC input range but without saturation. Make a program to stream and store a large number (N>10000) of samples to the PC.
2nd Part:Signal analysis
1)Make the time plots for the data samples acquired in 4) and compare them with theoriginal analog signals. Plot both signals using matched vertical scales ([V] units).
2)Calculate the Fast Fourier Transform for these arrays and plot the results in Magnitude (dB). Discuss the obtained plots (Maximumof the spectra, noise level, harmonics, and spectrum leakage). Can you extract the original signal frequency in the case 4c)?
3)Use e a time ompare with thege) aneakage). lot the ration. t frequnecies oscope.the internal RAM memory. scope)111111111111111111 a suitable time Window (Hann, Hamming, etc.) and redo the FTTs. Compare the results.
See for example
4)Analyse the FFT plots and try to identify both signal component frequency and amplitude.
5)Build the experimental Transfer function of the RC filter and compare the results obtained with SPICE simulator.
6)Compare the results obtained in 4a and 7). Discuss the noise caused by the timing jitter.
7)In the case of FFT 4a) estimate to parameters SFDR e ENOB of this ADC.
8)For the data acquire in 8) make a Histogram of digital values. Save for later analysis.What would the shape of the histogram if we used a triangular or saw tooth shaped signal?
Fig. 2. Example FFT plot for a sampled sinus signals, showing the harmonics and estimates of the SFDR parameter.