From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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 a sine with LabView FPGA and connect it to an AOModule

Hi,

 

Im trying to generate a sine with LabView FPGA (with the "sine wave generator") and connect it to  "Mod4/AO4". This Module refers to "NI9381" and it has analog inputs and outputs. I have attached an image were you can see the output I get (which doesnt look like a sine). I dont know whats wrong or whats happening...(if I execute my VI with simulated I/O everything is fine but when I execute on FPGA target I get a wrong sine).

 

Thank you in advanced,

Claudia Ramos

0 Kudos
Message 1 of 8
(4,366 Views)

Hello Claudia Ramos,

 

when executing your code on FPGA you use a feature called "Interactive execution". Since execution rates of any Code on the FPGA often is very high f.E. 40MHz this feature will not transfer and display every value generated on the FPGA. Only a small portion of the Sine values will be displayed witch will result in the data you are seeing in your graph control. This is perfectly normal. When measuring the electrical signal on your analog output chanel you will see that a sine pattern is actually generated.

 

From your screenshot i see that you dont use any timing in your loop, this can and will result in aliasing effects since you are generating values faster than the 9381 can output. I suggest that you limit your loop rate using timing functions to at least 20kHz. This is the maximum sampling rate when using one single channel with the 9381.

 

Best Regards!

 

Moritz M.

Message 2 of 8
(4,333 Views)

Hello Moritz,

 

Thank you for your answer. As you suggested me, I have added a timing function (ms) to my blockdiagramm and when I run the program (executed on FPGA target) the results in the graph control are now OK. But there is another issue now. When I check the results with an oscilloscope (connected physically one terminal to Mod4/AO4 and the other to "GND") what I see is not a sine. I have attached some pictures. What could be the problem in this case? and another question, Is there a way to control the sine amplitude? and, Is there something like an amplifier in LabView?

 

Regards!

Claudia

0 Kudos
Message 3 of 8
(4,321 Views)

Hello Claudia,

 

on FPGA VIs everything runs in pararel, except the compiler is instructed to do otherwise. In your case i expect the loop to wait for a certain amount of time after generating and outputting the sine value. In your VI the "Wait" function is placed pararel to the other code. I suggest to use a sequence structure: Frame0: sine generator and AO I/O node, Frame1: wait function. This of coure has nothing to do with the effects you are seeing.

 

The "Sine Wave Generator" uses I16 Integers for the output data, your 9381 module uses Fixed Point Numbers in calibrated mode (FXP 16,3)

When wiring the I16 to the FXP output the Labview creates a coercion dot (small red dot on the AO node)

The Output of "Sine Wave Generator" has a Range from -32767 to 32767 the FXP our AO channel uses a Fixed Point with Range 0 to 7,99987

LabVIEW doesnt scale the values during conversion so you have to rescale them yourselve.

 

This Knowledgebase shows how:

 

Using Fixed-Point Data Types with Integer-Based IP in LabVIEW FPGA 8.5.x

 

http://digital.ni.com/public.nsf/allkb/672BC377EE206CC08625740F00580544?OpenDocument

 

Another way would be to switch your Module to use "raw" data (that means Integer values).

This can be performed in the property page of your module in project explorer.

The AO will then use U16 datatype. So you only have to implement the conversion only from I16 to U16.

 

Best Regards!

 

Moritz M.

Message 4 of 8
(4,283 Views)

Hello Moritz,

 

Now I have a sequence structure and I switched my Module tu use "raw" data and I implemented the conversion from I16 to U16 (in fact the coercion dot disappeared). But I still cant see a sinus...I have attached some screenshots.

 

 

When I use the other possible solution (I have LabVIEW 2012): "wire integer data to the Integer to Fixed-Point Cast function to interpret integer data and produce fixed-point data", the coercion dot doesnt disappear (and I have my Module on "calibrated mode"). The Module in this case need FXP <+ ,16,3> and the conversor gives FXP <+,8,8>.

 

Thank you very much in advanced.

Best regards,

Claudia

Download All
0 Kudos
Message 5 of 8
(4,262 Views)

Hello again,

 

I have solved the FXP issue (so now the coercion dot disappeared) and now the signal in the oscilloscope looks better...but it still doesnt look like it should. I have attached again some pictures.

 

Regards!

Claudia

Download All
0 Kudos
Message 6 of 8
(4,255 Views)

Hello Claudia,

 

like i mentioned bevore simply converting Datatypes wont do the trick. Why?

The Sine generator VI outputs signed Integer values. Sinus is symetrical to 0V. Your C-Series Module however can only output from 0-5V not from -5V to 5V. When using the "to FXP" conversion Function, like you did in your last post, the function wont return a Sine that is symetrical to 2,5V but some other Signal. You will have to convert the datatypes like mentioned in this Knowledgebase:

 

Using Fixed-Point Data Types with Integer-Based IP in LabVIEW FPGA 8.5.x

 

http://digital.ni.com/public.nsf/allkb/672BC377EE206CC08625740F00580544?OpenDocument

 

I suggest to test the conversion on a simulated target by using a I16 Control instead of the Sine Function and an FXP Indicator of the right datatype.

By selecting + and - peak amplitude in the I16 control (f.E. +10 and -10) you can determine if your conversion works as intended.

 

Best Regards!

 

Moritz M.

Message 7 of 8
(4,229 Views)

Hello Moritz,

 

Thank you very much for your tips. Now everything works properly!

 

Best regards,

Claudia

0 Kudos
Message 8 of 8
(4,212 Views)