LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert sine to sawtooth

Solved!
Go to solution
Hi,

I need to convert a DDS generated sinewave to different signals (sawtooth,square,triangle) in Labview FPGA.
I would be grateful if you could help me find an easy way to achieve this.

Thanks in advance!
0 Kudos
Message 1 of 10
(12,901 Views)

Hi Seitseman,

 

the square wave is easy: you just compare the sine wave input with a threshold level…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(12,887 Views)

Hi GerdW,

 

That is definately easy, thanks!

 

However, what do you think about the other ones? Anyone?

 

Thank you!

0 Kudos
Message 3 of 10
(12,880 Views)

Hi Seitseman,

 

determine the sine wave period (using a "simple" detection of zero crossing). Using this value you can create your triangle/sawtooth waveforms…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(12,867 Views)

I had to do arbitrary waveform generation on FPGA.

The DDS block as implemented uses a constant array for the look up table.

I used an FPGA memory block for the LUT and updated it as required from the RTHost using a DMA FIFO.

Then just wrote my own DDS algorithm on FPGA, it isn't that difficult.  You could learn from the sine wave generator express vi.

 

If you have to output multiple waveforms you can just use multiple memories and share the addressing.

 

NI white paper on DDS

 

snippet.png

 

0 Kudos
Message 5 of 10
(12,842 Views)

Hi WillD,

 

Sorry if I didn't explain myself well. I ignored in my explanation the fact that the sinewave is already generated, by the DDS Compiler 6.0 Xilinx IP block, and also that I need to achieve one sample/tick generation, placing the code inside an SCTL.

 

The DDS Compiler offers me the signal generator I need, and lets me vary the output signal frequency the way I want, but it does not support other waveforms rather than sine or cosine, and I would love to generate a sawtooth and triangle using the same mechanism.

 

So if I could perform small changes on the output of the DDS Compiler I would get a handy signal generator that could output different waveforms at very different frequencies, at requested.

 

Thank you!

0 Kudos
Message 6 of 10
(12,832 Views)

- Square wave: you can create it by using a comparator. When sin is posivtive, it returns +V, when negative, it returns -V.

 

- Triangle wave: you can obtain it through integration of the square wave

 

- Sawtoot wave: I think about it.....

Message 7 of 10
(12,820 Views)

Sawtooth: Each sample increments by a constant from the previous sample starting from the rising edge of the square wave.  Resets and starts over at the next rising edge.

 

Lynn

Message 8 of 10
(12,806 Views)

Thanks for your replies!

 

I tried to implement the 'square-to-triangle' conversion, but I'm kind of struggling with the code. If I apply integration point by point to the output of the square wave I get an erratic triangle wave that I cannot use.

 

I'm not quite sure where the issue is, I have tried changing the parameters to the "Integral x(t) PtByPt.vi" but it didn't work.

 

Have anybody implemented this before?

 

Thank you!

0 Kudos
Message 9 of 10
(12,773 Views)
Solution
Accepted by Seitseman

You could use the increment method I suggested for sawtooth except that you increment when the square (or sine) wave is positive and decrement when negative. This method does not depend on the quality of the input signal except at the comparator transitions.

 

Lynn

Message 10 of 10
(12,761 Views)