From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate Sine wave on myRIO 1950, FPGA

Solved!
Go to solution

Hi All,

 

Hope you are doing well and are healthy.

 

I have been trying to generate a sine wave using FPGA on (myRIO 1950) and validating results using a scope but not able to get a sine wave out(attached image of scope screen x2) (blue waveform is a response from a another device, yellow is from myRIO analog output node A0 Pin2)

 

I have tried different solutions available online but nothing seems to be working. Some are: 

1) Link a, 2) Link b, 3) Link c, 4) Link d, 5) Link e

Also checked NI tutorials but all that I could find shows use of I16 data with no coercion.

FPGA Code.png

 

I suspect following could be the issue: (Data type)

 

Most of these examples use I16 data type where as IO node on myRIO 1950 accepts U16 data type. I have used two methods found on forums to generate sine wave (works great in simulation) but the output is always I16 and if connected directly to the IO node it shows a coercion dot. I used a conversion vi I16 to U16 to avoid coercion dot but that does not change the output. (Below is a snapshot from myRIO 1950 manual)

 

It reads that IO node is of 12 bit resolution, so attempted to use logical bit shift. It does changes the shape of waveform (from some what sinusoidal to square) . But not sure if that could lead to some solution.

Xonmyth743_0-1593021802287.png

Should I start with writing a code on FPGA which would produce U16 data points and send it to IO node.

Or convert existing output.

 

I was hoping if someone can guide me in the right direction, I would really appreciate that.

Experience level: Beginner

 

Attached lvproject to be reviewed,

Thanking you,

Have a good day.

 

0 Kudos
Message 1 of 4
(2,449 Views)

Hi Xonmyth,

 


@XM43 wrote:

It reads that IO node is of 12 bit resolution, so attempted to use logical bit shift. It does changes the shape of waveform (from some what sinusoidal to square) . But not sure if that could lead to some solution.

Xonmyth743_0-1593021802287.png

Should I start with writing a code on FPGA which would produce U16 data points and send it to IO node.


The AO of the myRIO has a range of 0…5V, with 12bits resolution. So an U16 value of 0 outputs 0V, and 2^12-1=4095 outputs 5V.

To output the sine signal you have to scale your calculated values into this integer range of 0…4095!

So the scaling from a range of ±1 (sine signal) will be

y = (x * 2047) + 2048

Also note those "absolute accuracy" and "slew rate" specifications, both may influence the accuracy of your sine signal…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(2,397 Views)

@GerdW wrote:

Hi Xonmyth,

 


@XM43 wrote:

It reads that IO node is of 12 bit resolution, so attempted to use logical bit shift. It does changes the shape of waveform (from some what sinusoidal to square) . But not sure if that could lead to some solution.

Xonmyth743_0-1593021802287.png

Should I start with writing a code on FPGA which would produce U16 data points and send it to IO node.


The AO of the myRIO has a range of 0…5V, with 12bits resolution. So an U16 value of 0 outputs 0V, and 2^12-1=4095 outputs 5V.

To output the sine signal you have to scale your calculated values into this integer range of 0…4095!

So the scaling from a range of ±1 (sine signal) will be

y = (x * 2047) + 2048

Also note those "absolute accuracy" and "slew rate" specifications, both may influence the accuracy of your sine signal…


Thank you so much for reply. You are the savior

 

I  implemented your suggestion and I am at least getting a some stable wave now. But the waveform appears to be triangular on scope.

 

Currently trying figure out why it is triangular.

0 Kudos
Message 3 of 4
(2,355 Views)
Solution
Accepted by topic author XM43

 

 

 


@XM43 wrote:

@GerdW wrote:
The AO of the myRIO has a range of 0…5V, with 12bits resolution. So an U16 value of 0 outputs 0V, and 2^12-1=4095 outputs 5V.

To output the sine signal you have to scale your calculated values into this integer range of 0…4095!

So the scaling from a range of ±1 (sine signal) will be

y = (x * 2047) + 2048

Also note those "absolute accuracy" and "slew rate" specifications, both may influence the accuracy of your sine signal…



Previous Context: (Generated Sine Wave with voltage (amplitude) control)

GerdW, thank you again, I could not implement your suggestion as it is but it did give me an idea and I was able to generate sine waveform of desired parameters.

 

I am attaching the project if someone wants to use it. Hope it helps them. (for myRIO 1950)

Current Problem Statement:
I have bigger problem now and have no clue how to approach it.
myRIO outputs sine wave of 0-5V and the device I need to send it to requires sine wave of +-2.5V.

Also, the device sends back +-2.5V of sine wave which I would want to acquire using myRIO but input range for myRIO is 0-5V. Can you or someone please suggest or guide me on this. I cannot afford to change the hardware at this moment.

Download All
0 Kudos
Message 4 of 4
(2,316 Views)