2

I have recently begun experimenting with SDR and have been using the GNU Radio platform.

More specifically the 'gnuradio-companion' graphical interface.

I have a need to determine a 4 quadrant arcTangent function and have run into some trouble. Within a 'GRC' file I have been able to successfully evaluate an ATAN function but, although python supports ATAN2, I have not been able to figure out how to implement this function.

I have read that there is a lookup table function included in GNU Radio called fast_atan2f but I do not know if this is accessible from within the blocks contained in the standard gnuradio-companion setup. I was able to access the python expression 'math.atan2(arg1,arg2)' from within a constant source block but I don't need this as a constant value, I'm looking for a block with two floating point inputs (or a single complex input) that will fit within a flow graph to properly evaluate the ATAN2 function.

I have included a sample 'GRC' file that may help to illustrate the issue in case my description is unclear.

link to the GNU Radio companion example file

Screenshot of the Flow Graph

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
Ed Coleman
  • 137
  • 1
  • 11

1 Answers1

4

The block gnuradio.blocks.complex_to_arg (Complex to Arg in GRC) is an atan2 operation.

If you need two separate floating point inputs as you described, then just precede it with a Float To Complex block.

Depending on your specific application, you may also be interested in gnuradio.analog.quadrature_demod (Quadrature Demod in GRC). This block produces essentially the derivative of atan2, but without any discontinuities at 180° or 360°. This is appropriate for e.g. demodulating FM signals.

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
  • Thank you Kevin. The Complex to Arg type conversion (of course) works perfectly. I was way overthinking the issue. – Ed Coleman Oct 16 '15 at 12:23
  • Thanks Kevin, could you also tell me how to define an 'exp(j(2*pifT+phase))' type of expression in gnuradio using c++ ? –  Dec 18 '19 at 08:55
  • @user1319236 Comments are not for asking new questions — please [post that separately](/questions/ask) and give more detail about how you want to use it. I'll still see it because I follow the [tag:gnuradio] tag. – Kevin Reid Dec 18 '19 at 16:17