LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

myRIO-1950, FPGA output frequency incorrect

Solved!
Go to solution

Hi All,

 

Working with a myRIO-1950 and I am getting my feet wet with the FPGA for the first time. I have a simple program where I am trying to generate a sine wave at 20kHz. I can generate the waveform just fine, but the frequency is always off. This is irrespective of the actual target frequency.

 

For example if I set the frequency to 5kHz, my output is roughly 5.8kHz. If I set it to 750Hz, my output is 850Hz. I am certain this is a mistake or an oversight on my part, and I am hopeful someone can provide some info.

 

 

0 Kudos
Message 1 of 4
(2,781 Views)
Solution
Accepted by topic author ademedeiros

I notice two things that could possibly result in what you are seeing.

 

1) I see that the data type for the periods/tick terminal is being coerced. By default the VI you are using wants all 32 bits of the FXP devoted to the decimal (0 bits integer word length). If you are using a different FXP representation with fewer decimal places that could result in not exactly the period you are asking for. In the FPGA world data types become pretty important and require more thought than you would put into datatypes in a normal LabVIEW environment. FXP is a good thing, much more efficient than using floating points.. but you have to think about what your range of values might be and how much precision you really need. If you use the high-throughput math functions you can set exactly how you want your result represented as a FXP number.

 

Also, instead of solving for 1/40000000 on the fpga every cycle, I would simply make that a constant. That way you can easily set the precision of the FXP constant. You can still set precision of math functions, but in the FPGA world doing the minimum processing you can is usually better.

 

2) Maybe the error is in your measurement device? That's a long shot, but hey... anything is possible


Corey Rotunno

0 Kudos
Message 2 of 4
(2,735 Views)

Thanks! The data type was the culprit. I'm pretty darn close to the target frequency now. Thanks again!

0 Kudos
Message 3 of 4
(2,713 Views)

I would just add that in FGPA integers are your friends! Try to use them whenever possible!

 

Consider doing the annoying steps, like divide and multiply, on the host rather than the FPGA. The Sine Generator Express VI is quite configurable, so consider that your offset and amplitude steps can be done in there instead of manually outside.

CLA - Kudos is how we show our appreciation for comments that helped us!
0 Kudos
Message 4 of 4
(2,702 Views)