discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] Cannot change transmit power


From: Josh Stevens
Subject: [Discuss-gnuradio] Cannot change transmit power
Date: Fri, 14 Sep 2012 20:49:20 -0400

Hey All,

    I created a flow graph which would do the following

    dip_image_source_block (custom made digital image processing block which helps sending images over the air (neat OpenCV work))
      |
      |--> throttle block -->packet_encoder-->gmsk_mod-->uhd_usrp_sink(tuned with the help of uhd.tune_request)

Below described is a snip of my code :

class my_top_block(gr.top_block):
    def __init__(self,options):
        gr.top_block.__init__(self)

        ##################################################
        #  Variables to be set
        ##################################################
        self.samp_rate = samp_rate = 250000
        self._tx_amplitude = options.tx_amplitude   # digital amplitude sent to USRP

        ##################################################
    # Blocks
    ##################################################

        self.dip_image_source_0 = dip.image_source("/usr/include/opencv/lena512.bmp")
        self.gr_throttle_0 = gr.throttle(gr.sizeof_float*1, samp_rate)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_f(grc_blks2.packet_encoder(
                samples_per_symbol=2,
                bits_per_symbol=1,
                access_code="",
                pad_for_usrp=True,
            ),
            payload_length=0,
        )
        #self.txpath_0 = transmit_path(modulator, options)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=2,
            bt=0.35,
            verbose=False,
            log=False,
        )
     
        self.amp = gr.multiply_const_cc(1)
        self.set_tx_amplitude(self._tx_amplitude)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
    self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
    self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(2.475*10**9,10000), 0)
    self.uhd_usrp_sink_0.set_gain(20, 0)

        #self.connect(self.dip_image_source_0,self.gr_throttle_0,self.blks2_packet_encoder_0,self.txpath,self.uhd_usrp_sink_0)
        self.connect((self.dip_image_source_0, 0), (self.gr_throttle_0, 0))
    self.connect((self.gr_throttle_0, 0), (self.blks2_packet_encoder_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0),(self.digital_gmsk_mod_0,0))
        self.connect((self.digital_gmsk_mod_0,0),(self.uhd_usrp_sink_0, 0))

    def get_samp_rate(self):
    return self.samp_rate

    def set_samp_rate(self, samp_rate):
    self.samp_rate = samp_rate
    self.uhd_usrp_sink_0.set_samp_rate(self.samp_rate)

    def set_tx_amplitude(self, ampl):
        """
        Sets the transmit amplitude sent to the USRP in volts
        @param: ampl 0 <= ampl < 1.
        """
        self._tx_amplitude = max(0.0, min(ampl, 1))
        print "Anay"
        self.amp.set_k(self._tx_amplitude)
        print "Tx amplitude     %s"    % (self.amp.set_k(self._tx_amplitude))

def main():

    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")

    parser.add_option("", "--tx-amplitude", type="eng_float",
                          default=0.250, metavar="AMPL",
                          help="set transmitter digital amplitude: 0 <= AMPL < 1 [default=%default]")

    (options, args) = parser.parse_args ()

    # build the graph
    tb = my_top_block(options)
    tb.start()                       # start flow graph
    tb.wait()                       # wait for it to finish


if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        pass

Although i have defined set_tx_amplitude and at run time i do provide the user option --tx-amplitude value is set to 0.25 but it still transmits at 16dBm (max power of a USRP N200) when you would expect it to be around a quarter of that power.
Any suggestions in this regard would be greatly appreciated.

Thanks,
Josh.
reply via email to

[Prev in Thread] Current Thread [Next in Thread]