PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

Efficient transfer of Simulink algorithm to PXI

I have a big simulink algorithm which we want to execute on a PXI chassis. It is big in Simulink, and also contains lower-level fully-inlined S functions, and complex heirarchical Simulink subsytems with initialisation commands within the subsystem masks.

 

I can easily:

- Create a mexw32 or mexw64 (dll file) for the entire algorithm, for use within Simulink with my IP protected.

or I can easily create x86-compatable C source code for the entire algorithm.

These are standard Simulink (with Real-time workshop and embedded code) features, and result in very efficient code with fast execution speed.

 

My question is how to most easily get this onto the PXI platform to run in real time. The algorithm is BIG but it should execute in <50us on an x86 processor. Execution speed is important and I cannot afford long overheads during "wrappers" or "interfaces" to the algorithm function calls.

 

Does anyone have any experience of dropping a precompiled MATLAB mexw32 or mexw64 file (these are dll's just renamed) into Labview directly? The manual "Using External Code in LabVIEW”

http://www.ni.com/pdf/manuals/370109a.pdf implies that might work. Maybe you just need to rename .mexw32 to .dll?

 

Does anyone have any experience of taking auto-generated C code from Simulink and compiling it within a Labview environment for download to, and execution on, the real-time OS on the PXI?

 

I can't believe this isn't doable, but I don't find any references to people doing it on the web. Also, I am hearing experiences of previous projects that have struggled with this exact Simulink-to-PXI conversion issue and had to re-code Simulink manually into Labview. In my case, this is probably not an option. The code is too large and complex.

 

I see there is a

 

- "LabVIEW Simulation Interface Toolkit" whose method is unclear to me, and seems to be very convoluted involving having MATLAB running the whole time, which I don't want - the software will end up running on the platform as embedded code, not on a PC.

or

- "LabVIEW Control Design and Simulation Module" which seems to be a Simulink-to-labview auto-translator (scary!)

I'm not convinced that either of these methods produce an end result which preserves the functionality or (importantly) speed of execution of a large simulink model in real time. My simulink model includes lower-level hand-coded S functions in C with associated tlc files, and complex hierarchical subsystems with mask initialization commands within some of the subsystems. I don't think any auto-translator will be able to effectively cope with these.

 

I'm not very familiar with LABVIEW, but quite with Simulink.

 

Andrew

0 Kudos
Message 1 of 4
(5,325 Views)

Hi,

 

Just to make sure I understand, are you happy to use dll function calls to solve your issue? In which case, you can use the call library function node to call C code. 

0 Kudos
Message 2 of 4
(5,277 Views)

If it works, using the dll would fulfill my requirements I think.

I found a help file location based on your answer:

http://zone.ni.com/reference/en-XX/help/371361H-01/glang/call_library_function/

 

Do you have any experience of using Simulink-generated mexw32/64 dlls in this way, dropped straight into Labview? Does Labview manage to determine the structure of the inputs and outputs automatically, and interface to the dll with a low overhead?

 

I'm just surprised that so far, in several internet trawls, I can't find any evidence of people doing this, or MATLAB/Labview Testimonials advertising that route.

 

On the other hand, I know several people who want to do something like it, and some who have tried in the past and failed!

0 Kudos
Message 3 of 4
(5,273 Views)

Hi, 

 

I personally do not have too much experience with simulink but as long as the code generated by simulink is in C, I dont see why you couldn't do it. 

 

The execution speed of the call library function node can be controlled under the error checking section when u double click on a call library function node. 

 

I hope that helps.

 

Thank you.

 

Best regards,

 

Nigel

0 Kudos
Message 4 of 4
(5,270 Views)