Skip to content

Commit

Permalink
scaling in spectra corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
JvanKatwijk committed Aug 22, 2018
1 parent ee997c5 commit d5f2373
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions spectrum-viewer/spectrum-viewer.cpp
Expand Up @@ -184,8 +184,9 @@ void spectrumViewer::ViewSpectrum (double *X_axis,
double amp,
int32_t marker) {
uint16_t i;
float amp1 = amp / 100;

amp = amp / 50.0 * (-get_db (0));
amp = amp / 100.0 * (- get_db (0));
plotgrid -> setAxisScale (QwtPlot::xBottom,
(double)X_axis [0],
X_axis [displaySize - 1]);
Expand All @@ -195,7 +196,7 @@ uint16_t i;
// get_db (0), 0);

for (i = 0; i < displaySize; i ++)
Y1_value [i] = get_db (amp * Y1_value [i]);
Y1_value [i] = get_db (amp1 * Y1_value [i]);

spectrumCurve -> setBaseline (get_db (0));
Y1_value [0] = get_db (0);
Expand All @@ -207,7 +208,7 @@ uint16_t i;
}

float spectrumViewer::get_db (float x) {
return 10 * log10 ((x + 1) / (float)(normalizer));
return 20 * log10 ((x + 1) / (float)(normalizer));
}

void spectrumViewer::setBitDepth (int16_t d) {
Expand Down
2 changes: 1 addition & 1 deletion src/ofdm/ofdm-decoder.cpp
Expand Up @@ -216,7 +216,7 @@ float signal = 0;
signal += abs (v [(T_u + i) % T_u]);
signal /= (carriers / 2);

return 10 * log10 ((signal + 0.005) / (noise + 0.005));
return 20 * log10 ((signal + 0.005) / (noise + 0.005));
}


3 changes: 2 additions & 1 deletion tii-viewer/tii-viewer.cpp
Expand Up @@ -170,6 +170,7 @@ void tiiViewer::ViewSpectrum (double *X_axis,
double amp,
int32_t marker) {
uint16_t i;
float amp1 = amp / 100;

amp = amp / 50.0 * (-get_db (0));
plotgrid -> setAxisScale (QwtPlot::xBottom,
Expand All @@ -181,7 +182,7 @@ uint16_t i;
// get_db (0), 0);

for (i = 0; i < displaySize; i ++)
Y1_value [i] = get_db (amp * Y1_value [i]);
Y1_value [i] = get_db (amp1 * Y1_value [i]);

spectrumCurve -> setBaseline (get_db (0));
Y1_value [0] = get_db (0);
Expand Down

0 comments on commit d5f2373

Please sign in to comment.