Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal...
-
date post
19-Dec-2015 -
Category
Documents
-
view
218 -
download
3
Transcript of Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal...
![Page 1: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/1.jpg)
Lab 5
Signal Analyzer/Generator
![Page 2: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/2.jpg)
Introduction
Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or DirectX.
Digitally analyze and generate analog waveforms
Reconstruct the waveform using the sampled signal
![Page 3: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/3.jpg)
Spartan 3 board
http://www.digilentinc.com/Products/Detail.cfm?Prod=S3BOARD&Nav1=Products&Nav2=Programmable
Tutorial 1
Tutorial 2
Tutorial 3
![Page 4: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/4.jpg)
Acquiring an Analog Signal
Input is a signal with peak to peak of 5 V Voltage input in the range -2.5 to 2.5 V Use Analog to Digital Converter
ADC0820 Input’s analog voltage 0 to 5 V Requires adding 2.5 Volts to input signal
before converted.
![Page 5: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/5.jpg)
Voltage compatibility issue
Spartan 3 uses a 5 V adapter Internal voltage levels are 3.3 V, 2.5 V and 1.2 V. ADC0820 needs a 5V, Output levels are close to 5V Inputs cannot handle 5 V without a current limiting
resister. Use R > 170 Ohms to limit current to 10 mA. Alternately, since the FPGA I/O are TTL compatible,
you may want to use TTL buffers to limit the voltage levels to about 3.4 V.
![Page 6: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/6.jpg)
Sampling Signals on Serial Port
Max Baud Rate 115,200 115,200 bits per second
Max Sampling Frequency 115,200 / 10 bits (8 data, 1 start, 1 stop)
Max Input Frequency to avoid aliasing (Max Sampling Frequency) / 2 = 5760 Hz
![Page 7: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/7.jpg)
Discrete Fourier Transform (DFT)
Can be processor intensive thus use Fast Fourier Transform (FFT) to calculate DFT
Algorithm requires a sampling frequency as a power of 2
Refer to FFT function on UL-99 (C++)
![Page 8: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/8.jpg)
Windows GDI
If you took 408 you probably already know this
![Page 9: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/9.jpg)
Device context classes
CPaintDC - for drawing on windows client handlers (on paint only)
CClientDC - for drawing on windows client handlers (anytime other then on paint)
CWindowDC – for drawing anywhere in a window
CMetafileDC - Drawing to a GDI metafile
![Page 10: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/10.jpg)
How to draw
Create paint object Move to point Draw line
![Page 11: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/11.jpg)
How to draw
CClientDC DC(this) DC.MoveTo(0,0); DC.LineTo(100,100);
When the window calls on_paint the window will clear the area.
![Page 12: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/12.jpg)
How to keep a drawing on a screen
Void draw(CDC* pDC,CRect rect) {
pDC->Rectangle(rect) }
![Page 13: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/13.jpg)
How to keep a drawing on screen
Onpaint() {
CRect rect;
GetClientRect (&rect);
CPaintDC dc(this);
draw(&dc,rect); }
![Page 14: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/14.jpg)
Other draw functions
Rectangle Arc PolyLine MoveTo Pie Ellipse RoundRect
![Page 15: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/15.jpg)
Coordinatestaken from programming with MFC second edition
![Page 16: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/16.jpg)
Coordinates
How to set
CClientDC dc(this)
dc.SetMapMode (MM_LOMETRIC);
![Page 17: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/17.jpg)
Why you should use a pixel coordinate systems and pitfalls
There are only so many pixels on a screen, this is set by a screen resolution.
In a pixel coordinate system, how many pixels on a client window can be found by finding the size by using:
GetClientRect(CRect rect); 1 pixel is the most accurate there is (no such
thing as ½ pixel in GDI)
![Page 18: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/18.jpg)
Changing Color
CPen pen;
pen.CreatePen (PS_SOLID, 1, RGB (255, 0, 0));
CClientDC dc(this)
CPen *oldPen = dc.SelectObject(&pen);
![Page 19: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/19.jpg)
Changing Color
Taken from programming with MFC, Second Edition
![Page 20: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/20.jpg)
Different Lines
Taken from programming with MFC, Second Edition
![Page 21: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/21.jpg)
Draw Text
CPaint dc(this)
dc.SetTextAlign(TA_RIGHT);
dc.TextOut(0,0,”hello”);
![Page 22: Lab 5 Signal Analyzer/Generator. Introduction Create a client MFC application that samples a signal and displays wave using Windows GDI, Open GL, or.](https://reader031.fdocuments.us/reader031/viewer/2022032309/56649d3a5503460f94a153f5/html5/thumbnails/22.jpg)
Anything else?
THERE IS MORE YOU CAN DO
This is just on the basics
Anything other details can be found on the MSDN.