05-01-2015
08:34 AM
- last edited on
06-18-2025
09:44 AM
by
Content Cleaner
I have a project that requires utilizing a cRIO-9068 for realtime control and data acquisition. I am new to LabVIEW and have been completing the self-paced online training classes so I have some decent familiarity but only a little programming experience. The hardware I have is a cRIO-9068 with two 9225 voltage input modules, a 9227 current input module, a 9474 sourcing DO module, and a 9401 DI module.
The program that I need to write needs to look at two 60Hz sine waves (one from one 9225 and one from the other 9225), and then provide a digital out when the phase shift between the two signals is equal to a certain amount. While this is occurring, I need to be logging data from all the inputs on the 9225's, the 9227, and the 9401 as fast as possible. The duration of each test from initialization to completion would only be about 300-500ms.
I attempted to write a program to capture the signal waveforms with enough resolution to be used for the phase shift calculation using the scan engine with the analog data being written to a single process shared variable with RT FIFO enabled in a timed loop with a 1ms period. Once the FIFO was full, a while loop read the data out to populate a waveform chart. The program seemed to work, but the resolution of the data was very coarse (approx. 4-6 samples per waveform). This has lead me to believe that in order to achieve the speed that I need for both control and data acquisition that I will need to implement the program on the FPGA. Is this correct? Perhaps my code was not optimized enough? I had used an example from the Real Time online class as the basis of the program.
I was hoping that someone might be able to give me a little high level guidance as to what would be the best direction to take with implementing the program. I found the LabVIEW cRIO Waveform Reference library (https://www.ni.com/en/support/documentation/supplemental/09/ni-compactrio-waveform-reference-library... that seems it would be ideally suited for the data acquisition portion of my program. Unfortunately, when I installed the reference library, the package didn't include the example host VI's. I'm a little bit at a loss for as to what the next direction might be. I think that it would probably be best to detect the phase shift by looking at the shift of the zero crossings of the two waves (the two waves have slightly different amplitudes and frequencies).
I still need to take the FPGA online class, so that might shed some light on the subject, but in the mean time it would be nice to know how best to focus my efforts to arrive at a program to complete the project requirements.
Thanks for any help you can offer.
05-01-2015
01:27 PM
- last edited on
06-18-2025
09:44 AM
by
Content Cleaner
Ral00,
If you have not already, I would take a look at the Compact RIO Developer's Guide.
https://www.ni.com/en/shop/compactrio/compactrio-developers-guide.html
This is a great resource for some of the high level application getting started questions. Chapter 2 talks about choosing a programming mode (Scan Interface vs FPGA) and gives the general rule of thumb that FPGA should be used if acquiring or generating signals higher than 500Hz. The fact that you mention you need to log data "as fast as possible" makes me think you should move this part of the acquisition to the FPGA and push the data over a DMA FIFO to be saved later on your RT VI.
If you have any other questions, or if I missed some that you asked in this post, feel free to ask.
05-05-2015 10:33 AM
Matt,
Thanks for the reply. I figured that I probably needed to utilize the FPGA for the data collection portion of the programming. I had been trying to do the phase shift detection/calculation using the scan engine and found that I was only able to collect about 6 samples per cycle, which seems to be a little too coarse to accurately detect phase shift - and definitely too coarse for capturing the high speed event data.
I'm working through the FPGA online training course and am now reviewing the developer's guide (thanks for reminding me of its existence). With the basic description that I gave above, do you think that my best plan of attack is to use the cRIO Waveform Reference Library on the FPGA to stream the data to the host while other logic on the FPGA performs the phase shift detection and trigger the output? Or should I figure out a way to stream the data and then analyze the data in the stream to detect the phase shift?
Any thoughts on how might be best to structure the program? Sorry if these questions are a little too general. Like I said, I'm still working through the FPGA familiarity as I have only been programming with the scan engine before for realtime programs.
Thanks again for any help you can offer.
05-06-2015
06:22 PM
- last edited on
06-18-2025
09:45 AM
by
Content Cleaner
I haven't looked into the Waveform Reference Library beyond just installing it and looking through the example so I'm not really sure which would be better. For the most part, the library seemed to abstract more basic FPGA Interface functions to make it look more like DAQmx functions so I would say if you can seed a way to modify the example to do what you want then go for that, otherwise just stick to building it up yourself.