def detect(self, demodulated_samples, receiver, offset_hint, zero, one): """ Detects the preamble in an array of demodulated samples. Arguments: demodulated_samples = numpy.array of demodulated samples receiver = Receiver associated with the reception of the demodulated samples. Used to access the samples per bit, sample rate, and carrier frequency of this data. offset_hint = our best guess as to where the first 1 bit in the samples begins zero = best guess for V_0 for these samples one = best guess for V_1 for these samples Returns: The index (as an int) into demodulated_samples where the preamble is most likely to start. """ preamble_samples = util.bits_to_samples(self.data, receiver.spb, zero, one) mod_presamples = util.modulate(receiver.fc, preamble_samples, receiver.sample_rate) ideal_samples = receiver.demodulate_and_filter(mod_presamples) if receiver.demod_type == Receiver.QUADRATURE: ideal_samples = numpy.abs(ideal_samples) samples_to_search = demodulated_samples[offset_hint:offset_hint + 3 * self.preamble_data_len() * receiver.spb] pre_offset = self.correlate(ideal_samples, samples_to_search) return offset_hint + pre_offset
def detect(self, demodulated_samples, receiver, offset_hint, zero, one): ''' Detects the preamble in an array of demodulated samples. Arguments: demodulated_samples = numpy.array of demodulated samples receiver = Receiver associated with the reception of the demodulated samples. Used to access the samples per bit, sample rate, and carrier frequency of this data. offset_hint = our best guess as to where the first 1 bit in the samples begins zero = best guess for V_0 for these samples one = best guess for V_1 for these samples Returns: The index (as an int) into demodulated_samples where the preamble is most likely to start. ''' #Get ideal set of preamble samples #i.e. convert the preamble bits in self.data to samples, then modulate them #then demodulate and filter them. preamble_samples = util.bits_to_samples(self.data, receiver.spb, zero, one) modulated_preambles = util.modulate(receiver.fc, preamble_samples, receiver.sample_rate) demod_filter_preambles = receiver.demodulate_and_filter(modulated_preambles) #correlate ideal preamble samples to the demodulated samples sequence #and return the preamble start index start_indx = offset_hint + self.correlate(demod_filter_preambles, demodulated_samples[offset_hint:]) return start_indx
def detect(self, demodulated_samples, receiver, offset_hint, zero, one): ''' Detects the preamble in an array of demodulated samples. Arguments: demodulated_samples = numpy.array of demodulated samples receiver = Receiver associated with the reception of the demodulated samples. Used to access the samples per bit, sample rate, and carrier frequency of this data. offset_hint = our best guess as to where the first 1 bit in the samples begins zero = best guess for V_0 for these samples one = best guess for V_1 for these samples Returns: The index (as an int) into demodulated_samples where the preamble is most likely to start. ''' samples=util.bits_to_samples(self.data,receiver.spb,zero,one) modulated=util.modulate(receiver.fc, samples, receiver.sample_rate) dmf_samples=receiver.demodulate_and_filter(modulated) return offset_hint+self.max_correlation_index(dmf_samples,demodulated_samples[offset_hint:])
def detect(self, demodulated_samples, receiver, offset_hint, zero, one): ''' Detects the preamble in an array of demodulated samples. Arguments: demodulated_samples = numpy.array of demodulated samples receiver = Receiver associated with the reception of the demodulated samples. Used to access the samples per bit, sample rate, and carrier frequency of this data. offset_hint = our best guess as to where the first 1 bit in the samples begins zero = best guess for V_0 for these samples one = best guess for V_1 for these samples Returns: The index (as an int) into demodulated_samples where the preamble is most likely to start. ''' preamble_samples = util.bits_to_samples(self.data, receiver.spb, zero, one) modulated_samples = util.modulate(receiver.fc, preamble_samples, receiver.sample_rate) digitized_data = receiver.demodulate_and_filter(modulated_samples) return offset_hint + self.correlate(digitized_data, demodulated_samples[offset_hint:])
def heterodyne_demodulator(samples, sample_rate, carrier_freq): return util.modulate(carrier_freq, samples, sample_rate)
def modulated_samples(self): """Returns the modulated signal (preamble + payload).""" samples = self.sample_bits() return util.modulate(self.fc, samples, self.sample_rate)
def modulated_samples(self): '''Returns the modulated signal''' samples = self.gain_samples() return util.modulate(self.fc, samples, self.sample_rate)
def modulated_samples(self): '''Returns the modulated signal (preamble + payload).''' samples = self.sample_bits() return util.modulate(self.fc, samples, self.sample_rate)
def heterodyne_demodulator(samples, sample_rate, carrier_freq): '''Return the samples demodulated via heterodyne demodulation, using a cosine of the given frequency (carrier_freq is specified in hertz). You may need to convert between continuous-time and discrete-time frequencies.''' return util.modulate(carrier_freq,samples,sample_rate)