|
From: | Affan Syed |
Subject: | [Discuss-gnuradio] variable transmission time of a single frequency |
Date: | Wed, 24 Mar 2010 18:00:56 -0700 |
Basically, I am trying to send a single frequency tone for a specified duration (currently 5ms) whenever a user wants to send one. My current solution uses messages by basically sending a single byte of ones no matter what a person enters on the cmd line. I convert that byte to symbols (representing one due to my above hardcode) and add to it the frequency of transmission. I then use a fixed number of repeaters to extend this symbol and use that to ourput from a vco that particular frequency. I have the code at the end of my email. What I am observing is that there seems to be some fundamental limit to how short that tranmission can be. In my code below, I am trying to send an 18Khz tone for 5ms. However, no matter what I do: a) the transmitted signal lasts for ~10-11ms (from scope and wav file) b) not every key press generates the tone. I generally miss one or two keypress. This happens even if the keypress are well spaced in time. So two questions to the community. What could be causing such a behavior? and is there an alternative way to get a similar result than what I am currently doing? Thank you. Affan Code ==================== TONE_FREQ=18000 #hz AUDIO_RATE=48000 #samples/sec TONE_DUR=5/1000#in sec BITS_IN_BYTES=8 REPEAT_TIME= TONE_DUR*AUDIO_RATE/BITS_IN_BYTES # Main Graph class tone_graph(gr.top_block): def __init__(self): gr.top_block.__init__(self) audio_rate = AUDIO_RATE self.src = "" msgq_limit) src = ""> b_to_syms = gr.bytes_to_syms() #we know that there should always be just one byte of code add = gr.add_const_ff(TONE_FREQ) repeater = gr.repeat(gr.sizeof_float,REPEAT_TIME) fsk_f = gr.vco_f(audio_rate, 2*pi,1.0) speaker = audio.sink(audio_rate); dst = gr.wavfile_sink("tone_tx.wav", 1, audio_rate, 16) self.connect(src,b_to_syms,add,repeater,fsk_f,speaker) self.connect(fsk_f,dst) def main(): fg = tone_graph() fg.start() # start flow graph try: while True: message = raw_input(" transmit a 5ms tone (Ctrl-D to exit): ") #make a one byte packet to indicate the tone transmission. pkt = struct.pack('B', 0xff) msg = gr.message_from_string(pkt) fg.src.msgq().insert_tail(msg) except EOFError: print "\nExiting." fg.src.msgq().insert_tail(gr.message(1)) fg.wait() # Main python entry if __name__ == '__main__': try: main() except KeyboardInterrupt: pass |
[Prev in Thread] | Current Thread | [Next in Thread] |