LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sine wave genaration on FPGA

Solved!
Go to solution

Hi all,

I've a problem during the sinewave geneartion on cRIO via FPGA with NI9246 module.
I've used the same LV structure found in LV example folder ( Hardware Input and Output->CompactRIO->Signal generation and Processing->Analog->Sine Wave) and adapted at my porject (based on LVOO and actor framework).
I'm anle to generate a signal with right frequency and amplitude but regarding the shape no!!!...I generate a square wave.
I attach the jpg of real time part and the fpga impementation, due to the complexity of the project i can not upload all files.
The cRIO module works with a FXP (int word lenghts 5 bits and word lenght 16, signed)

Any suggestion?
Thanks

T

 

Download All
0 Kudos
Message 1 of 9
(3,377 Views)

Hi,

the code snippets you attached are not very helpful, but it would actually be useful if you could attach at least a simplified VI allowing to reproduce the sine wave generation.

Other information that could be relevant:

  • the ratio between frequencies set in the Sine Wave Generator Express VI and in the sine wave generation loop (desired loop rate);
  • the exact model of the module you are using for generation (it cannot be NI-9246, because that's a current input module). Depending on the model, there may be limitations on supported data type, such that decimal numbers are unexpectedly truncated... and this is how a sine wave may become a square wave.

Regards,

Alessia

0 Kudos
Message 2 of 9
(3,333 Views)

Hello,

 

apologize for my typing error. The AO is NI 9264. I try to generate a sin with f=40Hz and Amplitude =2V (4 Vpp).

I've added the full project based on the NI example. The Amplitude is not a problem, the target is the frequency (reached) and the shape (sin instead of square).

I work with FPGA clock (40Mhz), maybe the problem is due to FXP AO data type ( Int word lenght : 5 bit and word lenght: 20). The Sine Wave Generator2 ( Express VI) has a I16 Output. Have you a suggestion about skip the problem and adapt the Express VI output for the AO ?

 

Thanks 

0 Kudos
Message 3 of 9
(3,308 Views)

Hello,

 

apologize for my typing error. The AO is NI 9264. I try to generate a sin with f=40Hz and Amplitude =2V (4 Vpp).

I've added the full project based on the NI example. The Amplitude is not a problem, the target is the frequency (reached) and the shape (sin instead of square).

I work with FPGA clock (40Mhz), maybe the problem is due to FXP AO data type ( Int word lenght : 5 bit and word lenght: 20). The Sine Wave Generator2 ( Express VI) has a I16 Output. Have you a suggestion about skip the problem and adapt the Express VI output for the AO ?

0 Kudos
Message 4 of 9
(3,311 Views)
Solution
Accepted by topic author zundap1970

Hi.

 

I've found my mistake...a bad sampling parameters in fpga area ("Desired loop rate" parameters in my example).

Now, seems work.

 

Thanks 

 

P

0 Kudos
Message 5 of 9
(3,279 Views)

Hi P,
thanks for the update. Would you be so kind as to specify how you changed the parameters to make the code work (wrong values --> right values)? This information could offer useful insights to other members of the community who may have a similar problem.
Regards,

Alessia

0 Kudos
Message 6 of 9
(3,272 Views)

Yes, of course.

In the example posted, on fpga module, there is "Desired loop rate (ticks)" parameters. This parameter set the loop scheduling and is necessary set it at the HW sample rate (in my case cRIO 9264 is 25K).

 

 

 

Message 7 of 9
(3,267 Views)

Thank you so much!

Best regards,

Alessia

0 Kudos
Message 8 of 9
(3,259 Views)

Hi there, I am having the same issue, and with changing the sample rate in the HOST vi, nothing change with the signal.

I have a CRio 9039 with a 9264 Module, i am using LV 2020. I tried you Project(which comes from the examples) and I using a scope on output A0.  

I still only get pulses, at the right frequency but no sinus wave at all. Can u maybe explain with pictures what variables you change in the FPGA vi or the Host vi?

 

Thanks in advance.

0 Kudos
Message 9 of 9
(2,178 Views)