-1
\$\begingroup\$

I would like to implement Chirp signal using C code

Do you have any idea how can I do it?

enter image description here

Edit

Goal is to send this signal to an DAC Component (µC intern or external peripheral). But I need fast sample rate like 10 Msamples or 20 Msamples. FPGA is not provided, any other µC is possible

\$\endgroup\$
2
  • \$\begingroup\$ C code can't really be made to chirp on its own, perhaps you could show what you have already tried. \$\endgroup\$ Commented Jan 30, 2015 at 14:41
  • \$\begingroup\$ First figure out if you are feeding samples into a DAC or (as is more typical on the small platforms you tagged) dividing down your clock to make a square wave. Then decide if you can afford trig and floating point, or if you need to use lookup tables and integer math. \$\endgroup\$ Commented Jan 30, 2015 at 14:47

3 Answers 3

4
\$\begingroup\$

Make your external peripheral a DDS (direct digital synthesis) chip. This sort of thing is well within the capabilities of even a relatively low-end chip such as the Analog Devices AD5930.

\$\endgroup\$
4
\$\begingroup\$

This reference has a simple Chirp function. Call it with the parameters and the time and it returns the signal value at that time. The w1, w2 are angular frequencies, so \$2\pi f_1\$, \$2\pi f_2\$, M is the chirp duration, A is the peak amplitude.

double Chirp(double w1, double w2, double A, double M, double time)
   {
   double res;
   res=A*cos(w1*time+(w2-w1)*time*time/(2*M));
   return res;
   }

Edit: With 10-20MSps you'll likely be looking at dedicated hardware such as a DDS that supports a chirp function and has internal trig tables. You may be able to find a processor with a DMA function that would allow a pre-calculated table to be output to a DAC, but that would be a peripheral function.

\$\endgroup\$
5
  • 2
    \$\begingroup\$ My assumption is the OP wants to us an 8-bit micro for this, and this function would take a disgusting amount of time to run on that platform. \$\endgroup\$
    – Matt Young
    Commented Jan 30, 2015 at 14:46
  • 2
    \$\begingroup\$ @MattYoung Well, there's nothing to indicate that. These days it could as easily be an ARM platform with single-precision floating point FPU built in. The above function can, of course, be used to precalculate a table and then the 8 bit (or 4 bit) micro could just index into the LUT. We use CORDIC HDL algorithms to generate this kind of stuff in real time inside FPGAs. \$\endgroup\$ Commented Jan 30, 2015 at 14:50
  • \$\begingroup\$ It's tagged PIC and AVR and neither of those are ARM cores with built in FPU. \$\endgroup\$
    – Matt Young
    Commented Jan 30, 2015 at 14:51
  • \$\begingroup\$ i have edited the post. please review and waiting for your kindly anwers \$\endgroup\$ Commented Jan 30, 2015 at 15:28
  • \$\begingroup\$ Alright, 10-20 MSps definitely puts 8-bit parts out of the equation. \$\endgroup\$
    – Matt Young
    Commented Jan 30, 2015 at 15:56
2
\$\begingroup\$

I think the way to go would be to generate a look up table of full-integer-scale of one cycle of a sine wave at your lowest frequency, and then modulo-index into it with increasing step sizes, possibly doing linear interpolations between two points if using the nearest point is too rough.

Lastly, depending on the relationship between your output rate and your highest wave frequency, you might consider sending this out via low-pass-filtered high res PWM as opposed to a DAC. It might be a lot faster.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Since a full sine cycle has 4-way symmetry, you only need to store 1/4 cycle. I go into more detail on that at electronics.stackexchange.com/a/16516/4512. \$\endgroup\$ Commented Jan 30, 2015 at 16:44
  • \$\begingroup\$ Good point,@OlinLathrop, and the original post is a nice resource. \$\endgroup\$ Commented Jan 30, 2015 at 16:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.