I was just working on a similar project today. Attached is a file to
generate fsk using the fm modulator function. You should be able to
adapt it to your application.
Jeff
#!/usr/bin/env python
#
# python code for gnuradio
#
# generate a binary continuous-phase fsk (cpfsk) signal using pseudo-random data
#
# sample rate, carrier freq, data rate, and freq shift are adjustable
from gnuradio import gr
from gnuradio import audio
import sys
import math
def build_graph ():
# ===== USER DEFINABLE PARAMETERS BETWEEN THESE LINES =====
# assign frequencies (units: Hz)
# frequency shift is distance between the two FSK tones
sample_rate = 8000
carrier_freq = 1000
data_rate = 100
freq_shift = 50
# ===== USER DEFINABLE PARAMETERS BETWEEN THESE LINES =====
m=int(sample_rate/data_rate)
# the following assumes data is +0.5/-0.5
fm_sens=2*math.pi*(freq_shift)/sample_rate
fg = gr.flow_graph ()
# generate random data and interpolate to sample rate
# for now we'll just use a short prsg sequence
# (later on integrate the binary lfsr generator)
# optionally, a longer string of 0s and 1s is available
prsg_string = (1,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,0,1,0,0,1,1,1,1,0,1,0,0,0,1,1,1,0,0,1,0,0,1,0,1,1,0,1,1,1,0,1,1,0,0,1,1,0,1,0,1,0,1,1,1,1,1)
# prsg_string = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
rng_src = gr.vector_source_s (prsg_string,1)
bit = gr.short_to_float ()
scale = gr.add_const_ff (-0.5)
interp_taps = (1,)*m
inter = gr.interp_fir_filter_fff(m,interp_taps)
fg.connect (rng_src, bit)
fg.connect (bit, scale)
fg.connect (scale, inter)
# generate complex-envelope fsk signal
fm_mod = gr.frequency_modulator_fc (fm_sens)
fg.connect (inter, fm_mod)
# mix complex-envelope signal up to carrier frequency
rf_src = gr.sig_source_c (sample_rate, gr.GR_SIN_WAVE, carrier_freq, 0.9, 0)
mixer = gr.multiply_cc ()
realpart = gr.complex_to_real ()
fg.connect (fm_mod, (mixer,0) )
fg.connect (rf_src, (mixer,1) )
fg.connect (mixer,realpart)
# output to soundcard
dst = audio.sink (sample_rate)
fg.connect (realpart, dst)
return fg
def main ():
fg = build_graph()
fg.start()
raw_input ('Press Enter to quit')
fg.stop()
if __name__ == '__main__':
main ()
_______________________________________________
Discuss-gnuradio mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio