[USRP-users] Controlling GPIO on WBX

Dan CaJacob dan at spacequest.com
Wed Feb 1 09:29:48 EST 2012


Thanks, Jason.  That worked beautifully!

On 01/30/2012 05:19 PM, Jason Abele wrote:
> Dan,
>
> You are very close, but I think you are getting confused by the older
> libusrp1 api in gnuradio.
>
>
> You need to set a value of 0 - 3.3 (volts) for the value argument to
> write_aux_dac
>
>
> Also, there are handy constants to refer to UNIT_RX and AUX_DAC_C, see
> the code snippet below.  It will set the pin 3 of J15 on the WBX-FE to
> 2.0V
>
> -------------------------------------------------------------------
>
> from gnuradio import uhd
>
> usrp = uhd.usrp_source(
>      device_addr="",
>      io_type=uhd.io_type.COMPLEX_FLOAT32,
>      num_channels=1,
> )
>
> chan = 0
> unit = uhd.dboard_iface.UNIT_RX
> dac = uhd.dboard_iface.AUX_DAC_C
>
> iface = usrp.get_dboard_iface(chan)
>
> iface.write_aux_dac(unit, dac, 2.0)
>
> -------------------------------------------------------------------
>
> Hopefully that will clear a few things up for you.
>
> Jason
>
> On Fri, Jan 27, 2012 at 02:58:59PM -0500, Dan CaJacob wrote:
>> This is directed to Josh, but I'd appreciate anyone's help!
>>
>> I would like to control the output of one of the extra GPIO pins
>> brought out through the WBX grand-daughter card.  The purpose would
>> be to control an external amplifier.  I would prefer to do this using
>> python.
>>
>> I am running a USRP1 (or B100) with a WBX for context.
>>
>> Using ipython, I ran some initialization code Jason Abele sent me in
>> interactive mode and played around with the member functions of
>> iface:
>>
>> from gnuradio import uhd
>>
>> usrp = uhd.usrp_source(
>>      device_addr="",
>>      io_type=uhd.io_type.COMPLEX_FLOAT32,
>>      num_channels=1,
>> )
>>
>> iface = usrp.get_dboard_iface(0)
>>
>>
>> It looks like write_aux_dac() is the function I need.  Defined as
>> write_aux_dac(self, unit_t unit, aux_dac_t which_dac, double value)
>>
>> I ran it with a variety of different inputs, logically at first, then
>> desperately.  I setunit=0, I tried several values of which_dac (some
>> old documentation indicates it should probably be in the set [2,3]),
>> value=[0,4095].
>>
>> It seems like which_dac is the parameter that is giving me problems.
>> I really want to specify AUX_DAC_C or AUX_DAC_A, since they are
>> brought out by the GDB.  I tried numerical inputs and variables,
>> assuming that constants were defined like in the C++ code.  Nothing
>> seemed to work.
>>
>> Here's an error dump when running it with all numeric inputs:
>>
>> In [7]: iface.write_aux_dac(0,2,0)
>> ---------------------------------------------------------------------------
>> RuntimeError                              Traceback (most recent call last)
>>
>> /home/spacequest/<ipython console>  in<module>()
>>
>> /usr/local/lib/python2.7/dist-packages/gnuradio/uhd/uhd_swig.pyc in
>> write_aux_dac(self, *args, **kwargs)
>>     1660     def write_aux_dac(self, *args, **kwargs):
>>     1661         """write_aux_dac(self, unit_t unit, aux_dac_t
>> which_dac, double value)"""
>> ->  1662         return
>> _uhd_swig.dboard_iface_sptr_write_aux_dac(self, *args, **kwargs)
>>     1663
>>     1664     def read_aux_adc(self, *args, **kwargs):
>>
>> RuntimeError: LookupError: KeyError: key "2" not found in
>> dict(N3uhd4usrp12dboard_iface9aux_dac_tE,
>> N16usrp1_codec_ctrl9aux_dac_tE)
>>
>> I apologize if I am missing something obvious here.  Thanks for your help.
>> _______________________________________________
>> USRP-users mailing list
>> USRP-users at lists.ettus.com
>> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com





More information about the USRP-users mailing list