-1

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

Nick Alexeev
  • 37,739
  • 17
  • 97
  • 230
user3213767
  • 455
  • 2
  • 6
  • 11
  • C code can't really be made to chirp on its own, perhaps you could show what you have already tried. – Erik Friesen Jan 30 '15 at 14:41
  • 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. – Chris Stratton Jan 30 '15 at 14:47

3 Answers3

4

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.

Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842
  • 2
    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. – Matt Young Jan 30 '15 at 14:46
  • 2
    @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. – Spehro Pefhany Jan 30 '15 at 14:50
  • It's tagged PIC and AVR and neither of those are ARM cores with built in FPU. – Matt Young Jan 30 '15 at 14:51
  • i have edited the post. please review and waiting for your kindly anwers – user3213767 Jan 30 '15 at 15:28
  • Alright, 10-20 MSps definitely puts 8-bit parts out of the equation. – Matt Young Jan 30 '15 at 15:56
4

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.

Dave Tweed
  • 168,369
  • 17
  • 228
  • 393
2

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.

Scott Seidman
  • 29,274
  • 4
  • 44
  • 109