LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use java to do a calculation in my VI?

Hi,

I'm creating a VI for a Fourier Transform Spectrometer and I want to use java to do the FFT calculation. Could you please let me know the easiest way to do this? I have basic java programming knowledge. I just want to send a number to java to do the calculation and give back the number. I want to generate the interferogram and FFT graphs at the same time each point is read. I appreciate your help. If a java program example could be given, that would be wonderful. (I read through the JNI tutorial, and find it's more complicated than what I need). I don't have C or C++ experience. Can it be done with just java and Labview?
0 Kudos
Message 1 of 8
(3,472 Views)
I think you will need to use JNI (Java Native Interface) to interface between LabVIEW and Java. This Knowledge Base on NI's website gives instructions for implementing this. You may want to take a look at this for your application.
J.R. Allen
0 Kudos
Message 2 of 8
(3,472 Views)
> I'm creating a VI for a Fourier Transform Spectrometer and I want to
> use java to do the FFT calculation. Could you please let me know the
> easiest way to do this? I have basic java programming knowledge. I
> just want to send a number to java to do the calculation and give back
> the number. I want to generate the interferogram and FFT graphs at
> the same time each point is read. I appreciate your help. If a java
> program example could be given, that would be wonderful. (I read
> through the JNI tutorial, and find it's more complicated than what I
> need). I don't have C or C++ experience. Can it be done with just
> java and Labview?


I wonder if it wouldn't just be easier to do the FFT in LV. If you are
using the base edition, then you migh
t look around for one or consider
an upgrade.

The reason I mention this is that the FFT in LV is fast and it is
probably indistinguishable from the one written in Java. Sending the
data to the Java code and returning the array of frequencies will cause
some performace problem as well unless these are kept in process.

Greg McKaskle
0 Kudos
Message 3 of 8
(3,471 Views)
Can I use it to just calculate one point at a time? It looked to me that I had to have all the points go through and then the FFT would be plotted.

My edition includes those VIs, I just wasn't sure how to use them for point by point calculation (and I thought it might run really slow). I get broken lines with what I'm trying to do with it.

I'd really appreciate some help with it if you're familiar with how it works. Email vze488w7@verizon.net ?

Thank you.
0 Kudos
Message 4 of 8
(3,471 Views)
If you have LabVIEW 6.1, you can use the Point-by-Point VI's to process data a single point at a time including FFT and other Frequency domain analysis.

On the functions palette, point to:
Analyze>>Point By Point>>Frequency Domain PtByPt

If you don't have 6.1, you can still use the traditional block mode FFT VI's. You need to decide on a block size to use (say n=1024), initialize an array of that size with 0's. As you acquire points, you index the array and replace the 0 values with the measured values and pass that to the FFT VI.

The Point-By-Point functions are pretty cool, but is there a particular reason you want to do this point by point versus block mode?

Have Fun,
Scott
0 Kudos
Message 5 of 8
(3,471 Views)
I want to use point by point because I want to have the interferogram and spectrum plotted at the same time.

If it's too much to ask, can you send me a simple VI example taking a number (amplitude) and doing the FFT of it and showing that number in a number indicator? vze488w7@verizon.net

Thanks very much.
0 Kudos
Message 6 of 8
(3,471 Views)
hi
 
Have you solved the problem that use java to do a calculation in the VI? If you done,i wish you can give me an example about this, thank you very much!
waiting for your reply.*_*
 
regards!
0 Kudos
Message 7 of 8
(3,155 Views)
Hello,
 
Are you referring to this specific example or calling Java code in general? I don't have any examples that demonstrate Java code explicitly, but there are several examples of calling C DLL's. If you take another look at the link mentioned above:
 
How Do I Integrate Java with National Instruments Software Products?
 
It mentions using JNI and a wrapper DLL in C. Calling C DLL's in LabVIEW is a fairly common practice. This manual should provide all the instruction you need:
 
Using External Code in LabVIEW
 
Good luck & happy coding!
Charlie S.

Visit ni.com/gettingstarted for step-by-step help in setting up your system
0 Kudos
Message 8 of 8
(3,133 Views)