MEFT-SAD/1ºSEMESTRE 1º Lab Guide - 2016/2017

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.

Group nº: Students nº

(You can use this doc as a template or any editor (e.gLaTeX) to produce and PDF files. Include all the circuits used, plot and results. When needed get an oscilloscope screen copy, showing the measured parameter. Attach the dsPIC “C” and Octave/Matlabwell commented codes in the annexes)

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 with microcontroller dsPIC30F4011 (version 3)
  • “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,512) from ananalog 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)The array when full should be transferred to the PC and stored in a text file to be plotted/analysed with MATLAB/Octave. Adjusting the generator frequency get the sample array in the followingcases:

  1. Sine wave with 4/5 full periods
  2. Sine wave 4 and ½ periods.
  3. Sine wave with fsinal ~ 1.2 * fsampling (subsampling)

5)Using a second generator to make a sum of two sine waves at differentfrequencies. (measure both freq. values). Acquire and store the sampled data.

6)Make a RC low pass filter circuit with an fcut-off = 0.25 * fNyquist. Use simple Sine waveswith fsignal close to fcut-off needed 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 ADC Simultaneous Sampling Mode.

7)Introduce an artificial “jitter” on the Timer, by changing the PRx(period) in the TIMERxinterrupt 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 transfer a large number (N>10000) of samples to the PC. (No need to use the Timer).

2nd Part:Signal analysis

1)Make the time plots for the data samples acquired in 4) and compare them with theoriginal analog signals using matched vertical scales.

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 Se 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.