Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert triangular wave to sine wave [FPGA NI 9263 cRIO 9012]

Hello Everyone,

 

How can I convert a triangular wave to a sine wave? I am using NI cRIO-9012, with NI 9263 (AO), Real-Time Module and FPGA.

 

Please find attached a screenshot and my .vi. The current VI contains 2 while loops. The first while loop generates data (1/4 of the entire triangular wave) according to a multiplication factor. The second while loop outputs the data to the AO module, using a flat sequence and for loop. The address is called incrementally/decrementally; additionally the data is negated twice to accommodate for the negative part of the triangular wave.

 

However, at this point, I am struck. I would like to tweak the triangular wave to generate a sine wave (without using any inbuilt functions). I suppose using Taylor Series would be the best option, but I am having trouble implementing this idea. The sinewave should be operations around KHz.

 

If there are any newbie programming errors, please let me know.

 

Any assistance would be appreciated.

Donaustadt.

Download All
0 Kudos
Message 1 of 7
(7,452 Views)

The sinewave should be operating in the MHz region.

0 Kudos
Message 2 of 7
(7,451 Views)

i am confused.  why do you not want to use the built in functions for sin wave generation?

 

Stu
0 Kudos
Message 3 of 7
(7,438 Views)

Hey Stu,

 

Thanks for your message. Just not a big fan of signal generating functions. Building my own will help me understand better- is that something bad? Can you assist Stu?

 

I would like to use taylor series to generate the sinewave. First start will a low no. of points for 1/4 of the wave (12 points in total for 1 period)- Then I would like to increase the number of points using a control to make the sine wave smoother. The speed should be in the MHz region.

 

Thanks

Donaustadt.

0 Kudos
Message 4 of 7
(7,432 Views)

i would definately use the built in functions for sinewave.

your approach is good for understanding and for implementation of triangle wave.

however, understanding DDS generation is even more important.  with DDS you can adjust triangle wave frequency (or any other wave) with very good resolution.

the built in generation of sine has been optimized for use so unless there is a good reason NOT to use it, then use it.

do you mean the update rate of the output at the MHz rate? if so then ok, if you intend to output frequencies in that range then you need to look at the flex line of FPGA.

Stu
0 Kudos
Message 5 of 7
(7,430 Views)

i would definately use the built in functions for sinewave.

your approach is good for understanding and for implementation of triangle wave.

however, understanding DDS generation is even more important.  with DDS you can adjust triangle wave frequency (or any other wave) with very good resolution.

the built in generation of sine has been optimized for use so unless there is a good reason NOT to use it, then use it.

do you mean the update rate of the output at the MHz rate? if so then ok, if you intend to output frequencies in that range then you need to look at the flex line of FPGA.

Stu
0 Kudos
Message 6 of 7
(7,430 Views)

Hey Stu,

 

Thanks for your prompt reply. At the moment, this task is only for understanding purposes. Currently, I am trying to comprehend the basic building blocks of FPGA- that is the reason of not using inbuilt functions.

 

Is it possible for you to have a glance at my .vi? Any clean up suggestions for the current .vi?

How can I change the lower while loop to generate 1/4 of the sine wave?

 

Best Regards,
Donaustadt

0 Kudos
Message 7 of 7
(7,426 Views)