LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Intense Mathematic Algorithm in LabVIEW Real-Time

Hello,
 
I am currently working for my school on a research project. We have on order a PCI-6224, LabVIEW Base, and LabVIEW Real-Time. We currently have a BNC-2110 accesory with an accessory cable. We also have a PCI-6220, which we found won't work for our project and is why we are ordering the new card. I am going to set up a Desktop PC as a Real-Time target. Here is what we need to do.
 
Run an initialiation script that declares variables and arrays, puts them through mathematical algorithms (such as spline, bessel, etc). I only want to do this initialization once at the start of the program and then keep a look up table of the values that were determined. After the basic initialiazation, we want to get analog input continuously at 40KHz. We then want to process each of these values using a mathematical algorithm that is similiar to a portion of the initialization procedure. We then want to continuously digital ouput at 40Khz, turning on or off 1 or more of 16 total digital output lines based upon the processed value from the previous step.
 
I am wanting to know the best way to go about setting up the mathematical portion. I already understand input and output and don't need help with that. The full algorithm is already written out in .m files, but I have found that Real-Time does not accept .m files. I have included the .m files in a zip file with this post. I cleaned up the main file, "traj_error_area1_sign_ch_time_cl_obs1", but the other files may be a little messy. This is to give you a good idea of the kind of mathematical algorithm(s) that I need to run in the program. I should also mention that I have this same algorithm written in C#, as we originally intented to just run this from a regular Windows Desktop PC until we realized that we need a Real-Time system to get the timing and speed that we require.Please tell me the best way to go about converting this to run in LabVIEW Real-Time. I am a little lost as to what route I should take. Thanks


Message Edited by briancfehrman on 04-13-2008 04:43 PM

Message Edited by briancfehrman on 04-13-2008 04:47 PM
0 Kudos
Message 1 of 4
(3,152 Views)
Hi briancfeh,

Unfortunately, the nature of the LabVIEW Real-time operating system means that it does not support .NET assemblies or calling MATLAB via the MATLAB node.

The obvious solution is to re-code all of your algorithms into LabVIEW VIs, although this may take a bit of work.

As another possibility, you could use two PCs: a Windows XP PC with the full power of LabVIEW and only use the Real-time machine for the operations that require it.  See the KnowledgeBase article on Real-Time VI to Host VI Communication Methods for more details.
Eric V
National Instruments
Applications Engineer
Certified LabVIEW Associate Developer


"I'm a Ramblin' Wreck from Georgia Tech and a helluva (NI Applications) Engineer!"
0 Kudos
Message 2 of 4
(3,111 Views)
Hi Eric,
 
Does the Real-Time OS not support any written code at all? Is there no in code script option?
 
In using two PCs, one real time and one not, won't I lose most (if not all) of the determinism? I need to be able to analog input sample at 40Khz, take each of the values in a FIFO manner, manipulate them with the math algorithm, then do a digital output based on the result and then exactly 40KHz (1/40000 of a second) later output the next result and so forth. So the loop will be:
 
1.) Initialize values and make a look table or array
2.)Continuously take analog input samples at 40Khz
 
Start Loop:
1.) Send first value through algorithm
2.) Digital output based on algorithm result
3.) Send next value through algorithm
4.) Digital output based on algorithm result, outputted exactly 1/40000 of second from the output in step 3
5.) Repeat steps, getting the next value from the input, sending through algorithm, outputting a result exactly 1/40000 of second from the previous output
 
It seems like the moment that I try to send and receive values to and from the non-real time system, I am going to completely lose all determinism and it will completely defeat the purpose of us running a real-time OS in our setup.
 
Also, I have read about using DLLs. If you could give me some good information on those, I would be interested as well. Please give me information and not just a link.
 
Thank you,
 
Brian Fehrman
 
0 Kudos
Message 3 of 4
(3,096 Views)
Hi Brian,

The Real-Time OS does support calling DLLs to a certain extent.  It does not, however, support calls to many of the Windows API functions, so there is a good chance that whatever external code you have written will not work without some modification.  We have a utility to check if your DLL is compatible.  Please see the following KnowledgeBase article for more information as well as a link to download the utility:

How Can I Verify that My DLL is Executable in LabVIEW Real-Time?

As far as losing your determinism, you are correct under this scenario.  If, at any point, the RT vi has to wait on the Windows PC for any reason, you will lose your determinism.

Depending on the complexity of your algorithm, you may also want to take a look at the Formula Node, which is supported on RT targets.
Eric V
National Instruments
Applications Engineer
Certified LabVIEW Associate Developer


"I'm a Ramblin' Wreck from Georgia Tech and a helluva (NI Applications) Engineer!"
0 Kudos
Message 4 of 4
(3,071 Views)