05-15-2019 09:30 AM
Hi to everyone,
I'm using a cRIO 9074 with NI9401 and NI9220 modules. The general idea of what I'm trying to achieve is to do position control to a motor that moves a mechanism in order to do impact experiments to some plates made of composite material. I've already constructed 2 Labview Projects. The first one is the implementation of position control and uses NI9401 module for digital input (Encoder measurements) and output (PWM signal). The position control has been implemented in a Host vi (Real Time) and the Encoder measurements and the PWM signal that my controller is generating are implemented at an FPGA vi. The second project is for acquiring (analog) data (measurements) from the plate and uses NI9220 module, so again this project has a Host vi and an FPGA vi. Both projects are working perfectly fine so I want to combine them, in order to first do the position control of the motor and after that, just before impact happens, to start acquiring measurements from the plate. The problem is that when I did that combination the PWM signal was not generated and the motor was not moving even though the control loop on host was working and the analog measurents were still working fine. From my knowledge, I think that you can't run from a Host vi (Real Time vi) 2 different FPGA vis simultaneously, so I combined also the 2 FPGA vis into one in order to have one FPGA reference in my host program. I'm attaching the combined VIs (Host and FPGA)
Any help would be greatly appreciated. Thanks.
05-15-2019 09:37 AM - edited 05-15-2019 09:38 AM
Hi fanplag,
unfortunately you only attached those VIs, but not the project file containing all the (hardware) definitions of your project…
On the FPGA VI:
Why do you read the same DIO channels in two loops in parallel?
Does the 9401 even support SCTL? (I'm not sure about that.)
On the RT VI:
It's huge. It's very huge. It's too big! Clean it up!
General advice:
"Combining" two programs into one is not always (or: seldom) done by simply copying the code of both into one big VI. You really need to know how each part is working and how they (possibly) interfere with each other!
05-17-2019 11:48 AM
If you have two programs that can run "by themselves" and don't share resources, instead of trying to "combine" the code into a Master routine, just have Master call Slave-1 and Slave-2, run them in parallel. Master can handle the common setup and possible setup parameters that the two Slaves need, and can then simply call the Slaves, passing in the values they need.
But what if you need to see some indicators in the Slaves? Simply run them in sub-Panels in Master. If you want, you can also "interact" with Controls on the Slave Front Panels (but this can start getting complicated ...). The best thing is that using already-written-code as an independent sub-VIs keeps the two routines physically isolated, separately testable, and very loosely coupled (often a Good Thing).
Bob Schor
05-20-2019 05:01 AM
GerdW and Bob_Schor thank you both for your quick response and your really helpful replies. Luckily, I found what was responsible for my problem (solution). Something weird had happened with the compilation of my combined FPGA vi and the digital outputs of my module didn't work properly, so when I recompiled it, the problem was fixed.
Best Regards,
FanPlag