Download low_cost_pc-based_quad_channel_r
Transcript
Friday, 21 June 2002
Final Report
Colin K McCord
m_dcGrid.FillRect(&m_ClientRect,&Brush);
/* Draw Border */
m_dcGrid.MoveTo(m_nGridX[0],m_nGridY[0]);
m_dcGrid.LineTo(m_nGridX[x],m_nGridY[0]);
m_dcGrid.LineTo(m_nGridX[x],m_nGridY[y]);
m_dcGrid.LineTo(m_nGridX[0],m_nGridY[y]);
m_dcGrid.LineTo(m_nGridX[0],m_nGridY[0]);
/* Draw V Gray Lines */
for (n=10; n < x;n=n+10)
{
for(i = m_nGridY[0]; i<m_nGridY[y];i++) m_dcGrid.SetPixel(m_nGridX[n],i,GRAY);
}
/* Draw H grey line */
for (n=10; n < y; n=n+10)
{
for(i = m_nGridX[0]; i<m_nGridX[x];i++) m_dcGrid.SetPixel(i,m_nGridY[n],GRAY);
}
/* Draw Centre Axis */
m_dcGrid.MoveTo(m_nGridX[x/2],m_nGridY[0]);
m_dcGrid.LineTo(m_nGridX[x/2],m_nGridY[y]);
m_dcGrid.MoveTo(m_nGridX[0],m_nGridY[y/2]);
m_dcGrid.LineTo(m_nGridX[x],m_nGridY[y/2]);
/* Draw V Ticks on H Centre */
for (n=2; n < x; n=n+2)
{
m_dcGrid.MoveTo(m_nGridX[n],m_nGridY[(y/2)-1]);
m_dcGrid.LineTo(m_nGridX[n],m_nGridY[(y/2)]);
}
/* Draw H Ticks on V Center */
for (n=2; n < y; n=n+2)
{
m_dcGrid.MoveTo(m_nGridX[(x/2)],m_nGridY[n]);
m_dcGrid.LineTo(m_nGridX[(x/2)+1],m_nGridY[n]);
}
m_dcGrid.SelectObject(pOldPen);
/* Update Display */
Invalidate(TRUE);
}
7.3. The Traces
The drawing of the traces looks extremely complex when looking at the big picture as channel offsets, zero
positions, time-base, sample rate, triggering method, channel disabled/enabled and voltage scales all affect
how the scope traces are drawn. Allow the basic principles behind the drawing of the waveforms are simple,
so let’s try and describe how the waveform traces are drawn step-by-step.
There are four large arrays (one for each channel) in class CScopeApp: int
int
int
int
m_nCH1Volt[10000];
m_nCH2Volt[10000];
m_nCH3Volt[10000];
m_nCH4Volt[10000];
//
//
//
//
Voltage
Voltage
Voltage
Voltage
*
*
*
*
1000
1000
1000
1000
These arrays are global and can be accessed from any part of the program. Sampled readings for each
channel are stored in these arrays; filled by the communication protocol, note the method used to fill these
arrays is depended on which mode is selected e.g. for scroll mode every location is moved one placed to the
left and the new reading is placed at the end of the array. Note the 10-bit ADC readings have already been
converted into voltage depending on the selected input voltage range and multiplied by 1000 to increase
resolution without having to use floating point numbers (e.g. for range -10 to 10V: -10V = -10000, 0V = 0 and
10V = 10000).
EEE516J4 – Honours Project
Page 52
Chapter 7: The Scope Program