Lab 5 Digital Oscilloscope and Remote Signal Processing

Download Report

Transcript Lab 5 Digital Oscilloscope and Remote Signal Processing

Lab 5
Signal Analyzer/Generator
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
Spartan 3 board
Tutorial 1
Tutorial 2
Tutorial 3
http://www.digilentinc.com/Products/Detail.cfm?Prod=S3BOARD&Nav1=Products&Nav2=Programmable
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.
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.
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
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++)
Windows GDI
If you took 408 you probably
already know this
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
How to draw
 Create paint object
 Move to point
 Draw line
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.
How to keep a drawing on a
screen
 Void draw(CDC* pDC,CRect rect)
{
pDC->Rectangle(rect)
}
How to keep a drawing on screen
 Onpaint()
{
CRect rect;
GetClientRect (&rect);
CPaintDC dc(this);
draw(&dc,rect);
}
Other draw functions
 Rectangle
 Arc
 PolyLine
 MoveTo
 Pie
 Ellipse
 RoundRect
Coordinates
taken from programming with MFC second edition
Coordinates
 How to set
 CClientDC dc(this)
 dc.SetMapMode (MM_LOMETRIC);
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)
Changing Color
 CPen pen;
 pen.CreatePen (PS_SOLID, 1, RGB (255, 0,
0));
 CClientDC dc(this)
 CPen *oldPen = dc.SelectObject(&pen);
Changing Color
Taken from programming with
MFC, Second Edition
Different Lines
Taken from programming with
MFC, Second Edition
Draw Text
 CPaint dc(this)
 dc.SetTextAlign(TA_RIGHT);
 dc.TextOut(0,0,”hello”);
Anything else?
 THERE IS MORE YOU CAN DO
 This is just on the basics
 Anything other details can be found on
the MSDN.