Building and Embedding a Reduced Order Model in National Instruments Hardware (cRIO)

4 次查看(过去 30 天)
Hi All,
I could do with some guidance on a task required on an National Instruments (NI) LEM controller currently under build.
I have a Simscape system-level model of an plant (engine and linear electric machine combination). I need to embed a simplfied model or function onto the NI hardware (cRIO-9035 RT Controller) that provides a reference signal (velocity or maybe LEM force) to the High Voltage LEM drives (M700). The M700 drives and its current/force-based controller are to be considered as "black-boxes" with unknown dynamics. The "reference trajectory model" inputs are simply pressure [bar] and crank angle position [CA] and for the time being a single output, which is the translator velocity [m/s].
The sample rate for the LEM drives I have been told is 1 m/s. I can export the Simscape signals directly from the data inspector. Has anyone experience of how to train a simplfied model or create a function such as this, that can be embedded in NI hardware, where in real-time the function will receive the plant pressure and crank angle at 1 m/s intervals and output the plant velocity? A function as a transfer-function or non-linear model such as a neural network?
I appreciate its a vast topic, however, and suggestions to get me started, would be great.
Thanks, Patrick

回答(3 个)

Umar
Umar 2025-9-8

Hi @Patrick,

Original Request: " I could do with some guidance on a task required on a National Instruments (NI) LEM controller currently under build. I have a Simscape system-level model of an plant (engine and linear electric machine combination). I need to embed a simplfied model or function onto the NI hardware (cRIO-9035 RT Controller) that provides a reference signal (velocity or maybe LEM force) to the High Voltage LEM drives (M700). The M700 drives and its current/force-based controller are to be considered as "black-boxes" with unknown dynamics. The "reference trajectory model" inputs are simply pressure [bar] and crank angle position [CA] and for the time being a single output, which is the translator velocity [m/s]. The sample rate for the LEM drives I have been told is 1 m/s. I can export the Simscape signals directly from the data inspector. Has anyone experience of how to train a simplfied model or create a function such as this, that can be embedded in NI hardware, where in real-time the function will receive the plant pressure and crank angle at 1 m/s intervals and output the plant velocity? A function as a transfer-function or non-linear model such as a neural network? I appreciate its a vast topic, however, and suggestions to get me started, would be great."

Response (No Simulink/Simscape access, but research-based guidance): You're right - it's a vast topic! Let me address your specific points:

For your cRIO-9035 embedding requirement: The cRIO-9035 is a rugged, fanless, embedded controller featuring an FPGA, real-time processor running NI Linux Real-Time OS, and embedded UI capability. Applications can be deployed using application components configured during the LabVIEW Real-Time build process.

Training approaches for your pressure [bar] + crank angle [CA] → velocity [m/s] model:

1. Transfer Function: Use System ID with your exported Simscape data 2. Neural Network: The Deep Learning Toolkit for LabVIEW allows you to create, configure, train, and deploy deep neural networks, and Vision Development Module works with frozen TensorFlow models on Linux RT 64-bit systems 3. Lookup Tables: Most deterministic for 1ms real-time requirements

*For M700 "black-box" drives: *

Focus on smooth, physically realizable velocity references that won't excite unknown dynamics.

Real-time implementation at 1ms:

The cRIO-9035's real-time processor should handle this timing requirement effectively.

Getting Started Suggestions: 1. Export your Simscape pressure/crank/velocity time-series 2. Start with simple lookup table approach for reliability 3. Validate against full Simscape model 4. Deploy to cRIO using LabVIEW project targeting the real-time processor

References:

1. NI cRIO-9035 Official Documentation: https://www.ni.com/en-us/shop/model/crio-9035.html

2. cRIO-9035 Technical Specifications: https://www.ni.com/docs/en-US/bundle/crio-9035-specs/page/specs.html

3. Deep Learning Toolkit for LabVIEW: https://www.ni.com/en-us/shop/software/products/deep-learning-toolkit-for-labview.html

4. Deploying Deep Learning Models to NI Hardware: https://www.ni.com/en/shop/data-acquisition-and-control/add-ons-for-data-acquisition-and-control/what-is-vision-development-module/deploying-deep-learning-models-to-ni-hardware.html

5. LabVIEW Real-Time Application Deployment: http://www.ni.com/product-documentation/12919/en/

6. Building Real-Time Applications: https://www.ni.com/docs/en-US/bundle/labview-real-time-module/page/lvrthowto/rt_building_rt_app.html

7. Deep Learning Library Community Discussion: https://forums.ni.com/t5/Example-Code/Deep-Learning-Library-for-LabVIEW/ta-p/4029995

8. Third-party Deep Learning Toolkit: https://www.ngene.co/deep-learning-toolkit-for-labview


Yifeng Tang
Yifeng Tang 2025-9-10
Given the dynamic nature (I think) of your system model, I wonder whether you could make use of the Reduced Order Modeler app: https://www.mathworks.com/products/reduced-order-modeling.html
The model type it supports, Neural State Space, LSTM, and Nonlinear ARX, are all "dynamic" in nature. The app allow you to perform DoE, data generation (from Simulink/Simscape models), modeling training, exporting to Simulink, and code generation & deployment all in the same app. Feel like worth checking out.

Patrick
Patrick 2025-9-11
Hi Umar, Yifeng,
Many thanks for taking the time to answer my question. I have build some initial transfer function, surface polynomial and shallow NN models coded in basic MATLAB script, which seem to capture what seems like a basic MISO system.
One issue so far, in training some initial models, my rotational angular position input (degrees or radians) is limited to a single rotation of the crank (0 to 360 degrees). This is as my slider-crank signal "wraps" back to 0 after 2 pi radians. This is limiting me to using a shallow NN. I have be advised to convert the angular position to a sin and cos function, and maybe add the rotational speed as an input to the model. Ideally the training data and model would capture an increasing angular speed of the crank, and the angular position, which wraps back to 0 after TDC, over 10 to 20 full cycle from 0 rad/s to 64 rad/s. Any suggestions.
Yifeng, thanks for letting me now about the ROM toolbox. I have downloaded and installed. Can I use this directly with my Simscape model?
  1 个评论
Umar
Umar 2025-9-11

Hi @Patrick,

Great progress on building those initial models! You're absolutely right about the angular position wrapping issue - it's a classic problem when dealing with cyclic variables in machine learning.

Analysis of your model results: Looking at your plots, I can see you've made solid progress with your MISO system identification. The transfer function and surface polynomial models appear to be capturing the general behavior well. Your shallow NN results show promise, though I notice the angular position limitation is indeed constraining the model complexity as you mentioned.

For the angular position wrapping problem: Converting angular position to sin/cos components is definitely the way forward:

% Instead of using theta directly
sin_theta = sin(crank_angle);
cos_theta = cos(crank_angle);

This gives your model continuous, periodic features that don't have discontinuities at 0/360°. You'll now have inputs: [pressure, sin_theta, cos_theta, angular_velocity] → velocity.

For capturing increasing angular speed over multiple cycles: Since as mentioned before not having direct Simscape/Somulink access, here's again my research-based approach for your data generation:

1. Time-based simulation: Run your Simscape model with a time-varying speed profile (0 to 64 rad/s over 10-20 cycles) 2. Export comprehensive dataset: Pressure, crank_angle, angular_velocity, and resulting velocity at each timestep 3. Feature engineering: Convert your exported crank_angle data:sin_crank = sin(crank_angle);cos_crank = cos(crank_angle);inputs = [pressure, sin_crank, cos_crank, angular_velocity];

Regarding the ROM toolbox with Simscape: The Reduced Order Modeler app should work directly with Simscape models - it's designed to interface with Simulink/Simscape through the DoE and data generation features @Yifeng mentioned. The Neural State Space and LSTM models it offers might be particularly suitable for your dynamic system since they can capture temporal dependencies better than shallow NNs, especially given the cyclic nature of your crank mechanism.

Next steps I'd suggest: 1. Regenerate your training data with the sin/cos transformation 2. Include angular velocity as a third input alongside pressure 3. Try the ROM toolbox's Neural State Space model - it might handle the dynamics better than your current shallow NN 4. Validate against multiple operating points before cRIO deployment

The sin/cos transformation should resolve your wrapping limitation and allow deeper network architectures while maintaining the physical meaningfulness of your crank position variable.

请先登录,再进行评论。

社区

更多回答在  Power Electronics Control

类别

Help CenterFile Exchange 中查找有关 Model Preparation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by