Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

sub VI call resets NI9505

Solved!
Go to solution

Hi all,

 

I am working on some control code for an insturmentation trailer. We are using 2 NI 9505s to control some pumps. I have taken the pre-packaged code posted in the 9505 toutorial and it works great. The real time VI works by itself, the FPGA code works, etc. I took the controls from the real time VI and made them external to the VI through the connector pane. However, when the VI is called from the main VI it resets the modules or completely fails to ready the drive status. If the drives come out of alarm the pumps only run for a fraction of a second before going into alarm. Do I need to call the VI in any sort of a special way? I have tried using load and retain on first call but that does not seem to work. Where am I going wrong?

0 Kudos
Message 1 of 7
(4,997 Views)

Hi Ryan, 

 

Would it be possible to post your modified code here? It would be easier to see what's going on for debugging if we could look at your code. If possible upload a zip file containing all of your project's files.

 

Tim W.

Applications Engineering

National Instruments

http://www.ni.com/support 

0 Kudos
Message 2 of 7
(4,994 Views)

Tim,

 

Attached you will find a .zip with the entire project. This is development code so it does need a ton of tweaking. Thanks for your help!!

0 Kudos
Message 3 of 7
(4,984 Views)

I would like to implement PID control so that a user can select a flow rate and the duty cycle of the motors trys to keep up with that flow rate. Is there a primer anywhere on how to use the PID toolbox?

0 Kudos
Message 4 of 7
(4,983 Views)

Hi Ryan,

 

After looking at your code I have a few suggestions:

 

- First and most important: combine your FPGA code into one FPGA-level VI. It should be as easy as copy/pasting the block diagram from pump 2's FPGA VI into pump 1's FPGA VI. From there make sure you have all of the indicators and controls referenced clearly. Your FPGA can only handle one bitfile at a time and by having two it is likely switching between (or only loading one).

- There appear to be extra while loops on your top-level VI (trailer.vi) where you make calls to your pump sub-VIs. These loops have false constants wired to their stop terminals which will result in infinitely executing code. You probably don't need these nested loops and should be able to make the subVI call from the main while loop.

- The pump subVIs use the "Enable Drive" method to get the hardware up and running, however by calling this portion of code from a subVI it may be making multiple open and close references to your FPGA-level VI, which is likely causing the behavior you're seeing. I would suggest integrating the pump subVIs into your top level VI by moving the Open FPGA VI Reference and Close FPGA VI Reference functions out of the subVI and into the block diagram for trailer.vi

 

Tim W.

Applications Engineering

National Instruments

http://www.ni.com/support 

0 Kudos
Message 5 of 7
(4,974 Views)

Thanks Tim!

 

I originally had all of the FPGA references in one VI, but I segregated them into 2 different ones to keep the calls simpler. I will roll back to the old VI.

 

I kinda figured it had something to do with the enable drive. I thought there may be a way to alter the call so that it just updated the values of PWM DTY while the program runs in the background. What is the functional difference between calling the enable drive in the while loop of the main VI and the sub VI? Shouldn't that exhibit the same behavior? Should I run that outside of the main while loop so that it executes only once? Should this be done inside of a sequence?

0 Kudos
Message 6 of 7
(4,972 Views)
Solution
Accepted by Ryan_Schwingle

I believe if you put that portion of the code outside of the main while loop it should behave correctly. Consider how the example works: it opens the FPGA VI reference, enables the drive, checks the drive status, then goes into a stoppable while loop where the drive status gets updated. If the user decides to end the program it then closes out the FPGA reference and handles errors. In your program only put the "drive status" portion of code inside your main while loop while keeping the FPGA reference VIs and the enable drive outside the loop.

 

Tim W.

Applications Engineering

National Instruments

http://www.ni.com/support 

0 Kudos
Message 7 of 7
(4,970 Views)