Commit 4a936acc authored by Federico Asara's avatar Federico Asara

Various bugfixes.

parent f6bab201
......@@ -83,18 +83,27 @@ class SingleToneSignal(Signal):
# index of the biggest peak nearest to `first`
# can only be first +-1.
second = first + (argmax(fdft[first-1:first+2:2])*2) -1
second = first + ((fdft[first-1]<fdft[first+1])*2) -1
ratio = (fdft[second] / fdft[first])
print first, second
print ratio
# save first in self
self.first = first
# self.beta quantifies the sampling incoherency, defining the
# fraction of a period sampled in excess.
self.beta = N/pi * arctan(sin(pi/N)/(cos(pi/N)+1./ratio))
print self.beta
# the position the peak between first and second
self.w0index = first+ self.beta
if first > second:
self.w0index = first- self.beta
else:
self.w0index = first+self.beta
print self.w0index
# sampling frequency
freqSample = 2 * pi * self.rate
......@@ -154,7 +163,6 @@ class SingleToneSignal(Signal):
if self.nsamples == 0:
return output
output.nsamples = self.nsamples
output.rate = self.rate
......
......@@ -78,9 +78,14 @@ class TwoToneSignal(Signal):
delta = abs(self.w1 - self.w2)
i1 = min([self.w1, self.w2]) - delta
i2 = max([self.w1, self.w2]) + delta
fw1, fw2 = self.fft[self.toi(self.w1)], self.fft[self.toi(self.w2)]
fi1, fi2 = max(self.fft[self.toi(i1)-1:self.toi(i1)+2]), max(self.fft[self.toi(i2)-1:self.toi(i2)+2])
i2 = max([self.w1, self.w2]) + delta
temp1, temp2 = self.toi(self.w1), self.toi(self.w2)
fw1, fw2 = max(self.fft[temp1-1:temp1+2]), max(self.fft[temp2-1:temp2+2])
temp1, temp2 = self.toi(i1), self.toi(i2)
fi1, fi2 = max(self.fft[temp1-1:temp1+2]), max(self.fft[temp2-1:temp2+2])
print fw1, fw2
print fi1, fi2
meaningful = hypot(fw1, fw2)
......
......@@ -82,7 +82,7 @@ class MainWindow(QMainWindow):
self.ui.wgFSR.setValue(5.)
self.ui.wgBits.setValue(24)
self.ui.wgFs.setValue(50e6)
self.ui.wgSamples.setValue(10000)
self.ui.wgSamples.setValue(8000)
# populate window box
windows = SignalProcessing.WindowFunction.windows.keys()
......@@ -176,7 +176,7 @@ class MainWindow(QMainWindow):
############################################################################
## Plans
############################################################################
def waveGenerate(self):
def waveGenerate(self, rate = None, bits = None, samples = None):
rate = float(self.ui.wgFs.value())
bits = int(self.ui.wgBits.value())
......@@ -394,10 +394,15 @@ class MainWindow(QMainWindow):
# if the generator cannot directly support this
playable = self.generator.adaptKeys()
if type(self.wave) not in playable:
fsr = float(self.ui.wgFSR.value())
bits = self.adc.get('nrBits')
data, f = self.wave.generatePeriod(bits, 1000, fsr)
self.generator.set('frequency', f)
self.generator.play(data)
def play():
bits, rate, wave = self.waveGenerate()
self.generator.set('frequency', rate)
self.generator.play(wave)
data, f = self.wave.generatePeriod(bits, 1000, fsr)
self.generator.set('frequency', f)
else:
def play():
self.generator.play(self.wave)
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>583</width>
<height>528</height>
</rect>
</property>
<property name="windowTitle">
<string>Setup test environment</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>291</width>
<height>114</height>
</rect>
</property>
<property name="title">
<string>Signal Generation and Acquisition</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>Full chain</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>ADC only</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_3">
<property name="text">
<string>Synthetic chain</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>320</x>
<y>10</y>
<width>131</width>
<height>114</height>
</rect>
</property>
<property name="title">
<string>Modality</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="radioButton_6">
<property name="text">
<string>Single tone</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_5">
<property name="text">
<string>Two tone</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_4">
<property name="text">
<string>Sweep</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>20</x>
<y>130</y>
<width>551</width>
<height>129</height>
</rect>
</property>
<property name="title">
<string>Output signal description</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Waveform</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox"/>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>257</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Configure..</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Generator</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_2"/>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>257</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Configure..</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>ADC</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox_3"/>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>257</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Configure..</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment