06-06-2006 07:12 AM
06-07-2006
06:34 PM
- last edited on
11-24-2025
01:03 PM
by
Content Cleaner
Hi engt,
I hope you're doing well. It may help to know what version of LabVIEW FPGA and the NI-RIO drivers you are using, but I will assume you are using LV FPGA 8.0 and NI-RIO 2.0 or later. The overall application should acquire the analog data with the cRIO module and FPGA code, transfer the data to the cRIO Real-Time controller via a DMA channel, process the raw data into the rms value, and then send it back to the Windows host if necessary.
There are shipping examples that show you how to acquire the analog data and send information via the DMA channel, and the RMS value calculation should only require performing the math functions on the Real-Time target. For the analog input shipping examples, go to Help»Find Examples to launch the NI Example Finder, then Hardware Input and Output»CompactRIO»Basic IO»Analog Input - cRIO. The DMA example actually does very simple analog input and then sends the data back via the DMA channel, and this can be found under Hardware Input and Output»CompactRIO»FPGA Fundamentals»Basic DMA.
If you need more help with the FPGA/RT Host portion of the code, I would recommend looking at the KnowledgeBase linked here [broken link removed]. Particularly, the LabVIEW 8 FPGA Module Training linked in the KB may be very helpful if you are new to LabVIEW FPGA 8.0. Lastly, the RMS can probably be calculated using the RMS.vi or RMS Pt by Pt.vi. Let us know if you run into any trouble, or if there is a specific portion you have questions on. Have a great day!
Thaison V
Applications Engineer
National Instruments
06-15-2006 05:35 AM
Hi Thaison,
Thank you. It has been long since tour post but we were occupied because of a compile server bug (localized Windows) and now we have solved it. We are ready to built our application.
Our application is a power monitor which reads the current and voltage transformer outputs and reads them via ADC (NI9201) and calculates the RMS values, Active and Reactive powers and calculates the harmonics (FFT) if possible. The calculations should be done between two zero crosses of the voltage signals - the utility frequency is 50 Hz and the calculation time is 10 ms). I planned to costruct a FPGA VI that reads the signals and at each zero-cross it updates the RMS and active reactive power values at the system. cRIO is going to work stand alone and there will be no connection to any PC. When I first try the controller I used the zero crossing element under the FPGA Math... >> Control >> Nonlinear... I tried it with a function generator and oscilloscope and worked well except the multiple zero-crosses. When the signal is square then the cRIO senses only one zero-cross but when the signal is sine or triangle then the cRIO shows multiple zero-crosses.
Another handicap is the frequency. The utility frequency is not constant and can vary between 49.5-50.5 Hz (can be 49 - 51 Hz if there is an error at the utility) Since the sampling frequency is constant (500 kHz) then the total number of the samples would change.
I am using LV 8.0, LV FPGA 8.0, NI.RIO 2.0.1. How can I built such a code?
Lastly, there is a Sample&Hold element triggered with time (us to wait for next hold) but I could not find a Sample&Hold element triggered with a logical signal which is time independent.
Thank you again Thaison.
06-19-2006 04:58 PM
06-20-2006 02:54 AM
06-20-2006 02:55 AM
06-21-2006
05:02 PM
- last edited on
11-24-2025
01:04 PM
by
Content Cleaner
engt,
Thanks for clarifying that a bit. Is the frequency of the square wave the same as the triangle and sine waves that you are measuring the zero-crossings on? If so, it's possible that the FPGA is still executing the rest of the calculations and Wait that you have in the bottom While loop, so it may miss the second zero-crossing. One general suggestions I have--that may or may not be the root of the problem, but it is a suggestion we will want to address anyway--is the way that you are using the Wait functions in your loops. In the bottom loop, you have it floating in the loop; is this to set the loop time to 10 ms? You mention that you must complete the calculation within 10 milliseconds, so that's what I assume. As it is, without having the Wait in some kind of sequence with the rest of the calculations in the loop, we don't know whether the Wait or the calculation will happen first. If you indeed want the loop timing to be 10 ms, I would use the Loop Timer function. Take a look at the following LabVIEW FPGA 8 Training slides here [broken link removed]. Slides 4 and 5 in Chapter 4 discuss Loop Timers and show how you can use them with sequence structures to set the loop timing. So in your case, this would check for a zero-crossing and do the RMS calculation you have implemented every 10 ms.
Regarding your last statement ("Lastly, there is a Sample&Hold element triggered with time (us to wait for next hold) but I could not find a Sample&Hold element triggered with a logical signal which is time independent."), is this what you are trying to implement with the top While loop? The way you have your VI programmed now, it looks like the top loop is waiting for the DO line to be triggered by the zero-crossing in the bottom loop, then it sets the another DO line high (which is used to trigger the "initialize" input on your integration function), and then it shuts off this trigger DO line again. One thing I should point out is that to share data between two loops, you typically would use a FIFO or local variable instead of passing it using a DO line. Your implementation may be necessary if you are using this DO signal externally as well though. Also, is this Sample & Hold section the functionality that you wish to implement to only calculate the RMS value when a zero crossing happens? The way you have it implemented now, it will calculate the RMS value no matter if it's a zero-crossing or not, but the top loop is simpling determining whether the value used in the last integration is used or not (this is the purpose of the initialize? input of the Integrator function. Let me know if you need clarification of anything. If my descriptions of what you are trying to do don't match up with your intentions, it may be helpful if you give me a step-by-step overview, in words, of what you want your algorithm to do, and I can give suggestions of how to start implementing it in LV FPGA. Have a great day!
Thaison V
Applications Engineer
National Instruments
06-23-2006 09:21 AM
06-26-2006 12:39 PM
06-27-2006 09:55 AM