Back to Browse

Building Code for the NI PXI System from PLECS

1.7K views
Sep 13, 2022
6:05

This demo video shows how to run a PLECS model on the NI PXI System. Hardware setup: National Instruments PXI System: PXIe-107 Chassis, PXIe-8880 2.3 GHz Eight-Core Controller with Linux OS and PXI-6356 Multifunction I/O Module Software: PLECS Standalone 4.6.5 (https://www.plexim.com/download/standalone, 90 days trial: https://www.plexim.com/trial) NI Target Support Package: https://github.com/plexim/ni-target-support NI MAX: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YGQwCAO&l Audio script: (Intro) First, I'll build a simple model from scratch. This model contains a RL circuit as the plant. A controlled voltage source will provide the current for the RL circuit. I’ll leave the default values of the passive components – that’s 1 Ohm and 1 mH. Another voltage source and a pulse generator at the output simulate a disturbance in the plant. The output voltage toggles with a frequency of 2.5 Hz between 3 and 1 Volt. I'll now create a subsystem, which includes these components and enable the Code Generation option. The Code generation option provides the possibility to create the code for your real-time system. The circuit is created. Now I will add a PI-controller to regulate the current in the RL circuit. The PI-controller will adjust the input voltage of the RL circuit to keep the current at the desired value. The set point of the current can be defined by using the parameter iL. The Kp and Ki parameters of the controller can be set as well. (Kp = 1, Ki = 300) The current and voltage signals are connected to the PLECS scope. I will send the current signal of the RL circuit to an analog output of the NI real time system and read it back via the analog input block. For this purpose, I will use the specific analog target blocks from the NI library. The NI target blocks automatically configure the corresponding channels on the NI hardware. The card slot number and the port channel according to your hardware setup can be specified within this block. In addition, scale, offset and voltage limitations can be defined here. I have done the same with the PI controllers’ output and the plant’s voltage input. Later I will physically connect the analog outputs to the analog inputs on the hardware side. Check the description of this video for more information about the NI target support package. Now I'll configure the target configurations under the coder Options: In the General tab I'll set the discretization step to 0.1 ms. Under the Parameter Inlining - you can define the parameters you want to change during runtime. I will drag in these 3 constants here. Under Target - select NI VeriStand and the Custom Engine build type to deploy the model directly from PLECS. Import the Hardware Configuration File, which can be simply created using the NI MAX software. Enter the information of your NI hardware below. Target IP address, login information, analog input and output ranges can be defined here. With one click on the Build button the runtime executable will be created for the NI real time system and deployed to the target. The model is now running on the real time hardware. I'm using the PXIe 1071, the embedded Controller PXIe 8880 with a Linux operating system and the data acquisition card PXIe 6356. Using the breakout board and the wires - the plant’s current signal is connected to the PI controller’s input and the PI controllers’ output is connected to the plant’s voltage input, which builds a closed loop control system. The oscilloscope shows the current and voltage signals from the analog outputs. Under the External mode I'll connect to the target device using its IP-Address. Now I can activate the autotriggering option to visualize the real time signals on the PLECS scope. I’ll set a trigger to the output voltage. Each time the output voltage changes, a jump in the current is caused. The PI controller adjusts the input voltage to achieve the desired current setpoint. The Kp and Ki values which have been calculated analytically are optimal. Now we can change them on the fly and see the response. For example, if I multiply the Ki value by 5 an overshoot of the voltage will occur. By 10, we can see that the system is unstable. I'll now execute the model offline to verify its behavior without using the real time hardware. The real-time blocks have their offline implementations, which are visible under their masks. To perform an offline simulation, you need to replicate your real hardware setup in PLECS. In our case - we have to loop back the signals with a delay in the parental sheet. The analog signals are transmitted with a delay of one model discretization time step, which is 0.1 ms. So, now I can run the offline Simulation. We see that the offline simulation behaves the same way as the real-time execution. This video shows a PLECS demo model running in real time on the National Instruments PXI hardware. For more videos visit our website www.plexim.com. Thanks for watching!

Download

0 formats

No download links available.

Building Code for the NI PXI System from PLECS | NatokHD