LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cRio and PID for servo control

Hi, I'm using a cRio to control a servo valve with a PID controller. I have a simple functional code (in attach) that does what I need, but I cannot perform more than 100 cycles per second. I'm doing something wrong in my program, it's impossible that it won't be possible to go much faster. My problem is that I am self-taught in LabView (not to mention that my background is in Civil Engineering…). I would like to ask if you could give me a clue as to what I'm doing wrong, I'm somewhat stuck... Maybe I have to compile the code to run within cRio (I'm not doing it, I still don't know how to do it). Any advice would be welcome!

0 Kudos
Message 1 of 6
(177 Views)

Hi number,

 


@numifar wrote:

I have a simple functional code (in attach) that does what I need, but I cannot perform more than 100 cycles per second. I'm doing something wrong in my program, it's impossible that it won't be possible to go much faster.


You use a lot of IONodes (for all hardware IO) in your cRIO VIs: they are not known to be "very fast". They also use the ScanEngine, where you need to be configure the cycle time.

 

So the questions are:

  • Which cRIO do you use?
  • Which IO modules do you use?
  • How did you configure the ScanEngine?
  • Can you use the FPGA (aka do you have the FPGA module available/licensed)?

Even though your project file (from LV2012) is shown as "corrupted" by my LabVIEW (LV2019) I guess the ScanEngine is set to a samplerate of 100Hz (Period = 10000 µs):

<Property Name="target.IOScan.Period" Type="UInt">10000</Property>

@numifar wrote:

Maybe I have to compile the code to run within cRio (I'm not doing it, I still don't know how to do it).


When you run a VI then you execute compiled code.

When you start a VI, that is called on your cRIO target, then you run code compiled for the cRIO.

You don't need to "compile code to run within cRIO" specifically, all you need to do is to place a VI in the correct target tree of the LabVIEW project.

 

I also recommend:

  • Don't use property nodes for no good reason. (There are several "value" properties in your VI.)
  • I would use boolean algebra instead of the Select node. ("IF X=false THEN X ELSE Y" is the same as "X AND Y")
  • Depending on the cRIO they don't offer any UI, so it doesn't make sense to place tab containers and graphs on a realtime VI…
  • This looks heavily like Rube-Goldberg:
    You better don't use the Formula node here, use different names for input/output variables, don't compare floats for equality, use better datatypes ("save" shouldn't be float), …
    (An alternative code is also shown in the image.)
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(158 Views)

Hello GerdW,

 

Thanks for your reply, and sorry for my missing name in this forum (my first time…). It’s Nuno. The cRio and IO modules are at the University, but Friday I‘ll have the information you request (tomorrow is national holiday).

 

For what I understand, I’m using Scan Engine and I should used FPGA. I’ll see if I’m licensed. I also understand that I don’t need to worry about compile the code, so that is not the problem. I’ll remove all property nodes, select modes and formula nodes in a new version of the code. You refer that it is not common to have UI on real-time VI, and I have. What you say makes sense, but it is working... Can this be part of the problem for my slow code? I have play with the time step of the loop on the real-time VI but it doesn’t have any effect… Friday I’ll add the missing information to see if I can correct my code, or if I should start a new one.

 

Thanks, best regards. Nuno

0 Kudos
Message 3 of 6
(109 Views)

Hi, just checked and I have an cRio 9074, with several I/O modules. But I’m only using modules NI9263 and NI9205. Regarding FPGA, I don’t have it installed. I’ll fix this as my next step.

 

numifar_0-1714139614471.jpeg

 

0 Kudos
Message 4 of 6
(81 Views)

Hi numifar,

 


@numifar wrote:

Hi, just checked and I have an cRio 9074, with several I/O modules. But I’m only using modules NI9263 and NI9205. Regarding FPGA, I don’t have it installed.


With a cRIO9074 you only can choose between using the ScanEngine or use the FPGA to access your module IOs.

The ScanEngine is quite limited on this old cRIO due to its limited resources (FPGA size, RAM, CPU power), so pushing it to 100Hz is already hitting its limits.

You might want to read this article from NI.

 

When you need higher sample rates then your choice is to handle the IOs in the FPGA: you need to install the FPGA module and activate it with your (valid!?) license.

Be warned: this old cRIO requires an old version of the FPGA compile tools, which only come with older LabVIEW versions. And those older FPGA tools aren't supported on modern Windows. You may have luck when you can use the NICompileFarm service to create the bitfiles…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(65 Views)

Hi GerdW,

 

My license gives me access to all features available for LabVIEW up to version 2013. Since the FPGA module I need is old and cannot be download directly from the NI webpage, I asked technical support to send me a link to the module FPGA (2012 version). In this field, I don't expect any problems. Regarding the Windows version, I was not aware of that problem. Fortunately, I ended up being lucky. I am using the resources already installed, that is, a computer with Windows 7 (32 bits). I hope it supports FPGA modules…

 

I'm not going to close this post right now, I would like to share to what frequency I can go using FPGA (with SCAN ENGINE I achieve 100Hz, I hope to reach 1kHz with FPGA).

 

Regards

Numifar

0 Kudos
Message 6 of 6
(42 Views)