03-04-2014 10:56 AM
I have been working with a cRIO in Scan Interface for some time now, but now I need to acquire 6 analog input waveform signals with 50Hz by using 2 NI cRIO9215 modules on a cRIO 9074.
To do this in Scan Interface I cannot have the necessary sample rate in order to save all 6 waveforms, so I assume it will be required to jump into FPGA.
I have followed some examples, but I am stuck with the resolution of the Analog Input signal. After creating the Target VI to write data to a FIFO in SGL, the result in the Host VI is a strange wave forme that appears to don't have the required sample rate.
In the Target VI I am using 1ms in the Loop Timer, that should give 20 samples for each waveform period.
Anyone with FPGA experience could give me some advice please?
03-04-2014
12:04 PM
- last edited on
08-12-2024
06:42 PM
by
Content Cleaner
I haven't used that specific module, so I'm making a guess here. Check your scaling. The analog input is returning a raw, unscaled integer value (the blue wire) which you are forcing into a single-precision value. There is documentation saying that, at least in a USB configuration, that module returns binary data rather than the more common two's complement, and that the zero value is in the middle of the range. If that's the case here too, then I would guess your module is occasionally reading a slight negative value which, due to the representation difference, is being displayed as a large negative value. What shape do you expect from the waveform? You might convert the DMA FIFO to the correct integer representation, then do the scaling on the host side before you display the value on the graph.
As for the sampling rate: the X axis on the graph, even though it is labeled "Time" it is really just the number of points acquired. If you want it to match real time, set the axis multiplier (in the chart properties -> scales) to adjust it. You may also want to change the axis numerical format to a time format.
03-04-2014 12:28 PM
Thank you very much for the reply.
The waveform should be a sinewave since I am measuring 3 AC currents and 3 AC voltages.
Indeed the output of the FPGA I/O Node is in blue, so I assume it is an Int, however I need it to have some digits of precision to represent the actual waveform.
If you open the Chart.png in attach on my question, you can see that the data I am getting is far from the sinewave.
03-04-2014
12:54 PM
- last edited on
08-12-2024
06:42 PM
by
Content Cleaner
Have you tried switching the module to read Calibrated data, instead of Raw? That will get you fixed-point data. Alternatively, if you want to do the conversion in a VI, see Converting and Calibrating CompactRIO Analog Input Values (FPGA Interface). In either case, you should set the DMA FIFO to the data type that matches the data that you're writing to it. The implicit conversion between integer and floating-point is preserving the value, but you need it scaled. That is, if the analog input reads 3800 as an integer, the floating-point value is also 3800, which is not what you want.
03-05-2014
04:57 AM
- last edited on
08-12-2024
06:43 PM
by
Content Cleaner
I have follow this https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x0UdCAI&l=en-US nice example from NI website, however the signal I capture is not even close to the sinewave I should get.
I have trieded to increse the FIFO Word Lenght and Integer Word Leght but with no success.
Please see in attach the result I am having with this VI (Chart.png), and the real waveform by using an osciloscope (F0039TEK.PNG).
I am also sending a ZIP file with the entire project.
The FIFO is set to 1023 elements, FXP 16-bit Word Lenght and 16-bit Integer Word Lenght.
I have also changed the Target VI to measure the time in uSec that the FPGA takes to make each measurement into the FIFO, and the fastest possible is 10uSec, more then enought to get a 50Hz sinewave. However, from the result chart in the Host VI it appears that the sample rate is not enought.
03-05-2014 10:14 PM
Sorry, computer problems at my office, I'm currently unable to open your VI. Can you apply a fixed voltage to the analog input (for example, a battery) and check that you are reading a constant value? Does the value you read match what you expect? There is still definitely a scaling problem, because your Y axis runs to 32000.
How did you choose the fixed-point settings? Setting the integer length to the same as the word length means you just have an integer, so no need for a fixed-point value. If you are reading a raw, unscaled value from the analog input, then you need to do some math, either on the host or on the FPGA, to convert that to engineering units such as voltage. Just shoving that data into a different format won't do it, there needs to be actual computation. It's possible that one of the integer to fixed-point cast functions will work too.
The fact that the screenshot of the front panel has both a True value for "Timed Out?" and that there's a warning suggests that you're doing something wrong, but unfortunately as I mentioned I can't look at the code right now so I can't provide a useful suggestion as to what exactly is wrong.
03-06-2014 05:29 AM
Dear nathand,
The FIFO has the following settings:
Type: Target to Host - DMA
Requested Number of Elements: 1023
Data Type: FXP
Encoding: Signed
Word Length: 16 bits (since the NI cRIO-9215 has 16bit)
Integer Word Length: 12 bits
Arbitration for Write: Arbitrate if Multiple Requestors Only
The signal I am trying to read is a sinewave with a frequency of 50Hz that vary betwwen +1,25V and -1,25V. The period is 20ms (1/50), so an aquisition of 1ms should be enought to have the waveform.
By applying a constant DC voltage of 7.09V on the same CH0 channel, the results are quite strange (Please see in attach the chart when applying the sinewave and the DC voltage).
I have also made an experiment by using the same module NI cRIO 9215 with BNC terminals with an USB cDAQ-9171. By applying the same DC voltage I get a constant horizontal line by using Signal Express around 7V as I expect. By using the sinewave signal, I get, as I expect, an almost perfect sinewave signal.
This way I can conclude that my signals are correct, the module is working just fine and that the problem must be on the cRIO aquisition.
03-06-2014 08:13 PM
I think there are two separate problems here - one is scaling, and the other is transferring data over the DMA FIFO.
In the constant voltage image, is it possible you are timing out the DMA Read, leading to occasional 0's in the data? It looks to me like you are mostly reading a constant value around 2050, with regular readings of 0. I would guess that the 0's are due to a DMA timeout. Again, sorry I can't look at your code right now, I hope to have that fixed soon. Is the code that you uploaded in a previous post the same code that you used to measure the constant voltage? Can you make sure that if you upload an image, you upload the latest code as well so it's clear that they match?
What is the voltage in the constant voltage image? You wrote 7.09V, but you labeled the image 6.66DC, and the range along the Y axis is the same as for the sine wave where you said the voltage range is +/- 1.25V. Were the sine and constant voltage images captured with the same code?
In the sinewave image there is a vague sine pattern in it, but again with lots of 0's. It looks like you're at least reading something, though.
Again, how did you pick the fixed-point settings? You provided two different integer widths in the past two posts (one said 16, the other 12). Did you change the module to read calibrated data instead of raw data, or are you still reading raw data but putting it into a fixed-point value? Do you understand the difference between integer, fixed-point, and floating point, as well as the difference between numbers that have the same bit pattern versus numbers that have the same value?
03-06-2014
11:05 PM
- last edited on
08-12-2024
06:43 PM
by
Content Cleaner
nathand is right. There are 2 issues at hand. (1) your FPGA is returning binary, uncalibrated data. (2) your FIFO is fixed point data
If you choose to change the 9215 to provide Calibrated data, then you will need ot make your FIFO match the specifications for the 9215, <+-, 20, 5>.
If you choose to keep the data in its Raw form as a 16-bit integer, then you will need to make your FIFO match that data type and then do the conversion from binary to voltage in your host program. This page talks about that: https://www.ni.com/docs/en-US/bundle/c-series-reference-and-procedures/page/criodevicehelp/convertin...
Either way, you will have to decide what kind of data you will be getting from your FPGA I/O node for the 9215, make the FIFO match that.