12-19-2022 11:02 AM - edited 12-19-2022 11:05 AM
I am working with NI Crio and Arduino. I have sensors connected to Arduino, this Arduino is connected to Crio, and it sends data serially to Crio.
My Labview project for this includes 3 VIs: one VI on Windows, one VI under the Crio RT target, and the third VI under Crio FPGA target.
The FPGA vi controls some thrusters, the Crio RT vi has the code for fetching data from Arduino, and the VI on Windows merges all the data together and I've also made the GUI on it. This third VI has some shared variables too since there are certain commands which the user can input through the GUI. Those commands have to go to the other 2 VIs.
I want that when I open the Labview windows VI, all other VIs in the project start running automatically.
Right now, I have to open all the 3 VIs and run them separately, otherwise, the shared variables wouldn't work.
I thought of converting the VIs under the crio RT and FPGA targets to subvi and including it in the Labview windows, but that wouldn't work would it? because the targets are different.
How can I do this?
12-19-2022 08:19 PM
Leaving aside the Arduino, you have a LabVIEW Real-Time Project here. If you are not familiar with LabVIEW programming, then you really aren't ready to undertake a LabVIEW RT Project, as this involves running LabVIEW on two (or maybe three, if you include the FPGA) "computers" at the same time.
However, to answer your question/dilemma, in a LabVIEW RT Project, it is not unusual to write the program that runs on the Remote Target (in your case, the CompactRIO) in such a way that it is "deployed" to the Target in such a way that it starts running automatically when the Target is turned on.
You have two computer programs running -- on your PC, you have the code that you refer to as the "VI on Windows", what I would call the "Host" routine. You control this, you turn on the PC, boot up Windows, start LabVIEW (or, if you've build your LabVIEW code into an Executable routine, start your Executable routine), and depend on it to "know" that somewhere out there (on the Internet), there is a CompactRIO running the "missing piece" of your code. You describe looking for "shared variables", but a somewhat more robust mechanism (but one that takes a little more programming) is to use a LabVIEW technology called "Network Streams", a method of an organized transfer of data from "LabVIEW on the Host (PC)" to "LabVIEW on the RT Remote (RIO)", or from RIO to Host.
Needless to say, it is one thing to write a computer program that runs properly on one computer, to coordinate a program that runs simultaneously on two (or three) computers, simultaneously and concurrently, exchanging information and working together to accomplish a single programmatic "goal", is significantly more complicated. You should "know what you are doing" when writing for one processor before worrying about writing a routine for two (or three) processors.
Bob Schor
12-20-2022 01:48 AM
Alright, so what should I do to "know what I'm doing"? Would love a couple of advice since I'm totally new to LV and Crio.
Is there anything I'm doing the wrong way?
Btw, this program (the LV project which runs on three computers, one on Windows, on crio RT and FPGA too) runs perfectly fine. I've tested in on my remote vehicle many times.
And I still didn't get the answer to my question.
The main VI that runs on Windows is by the name 'Host Program'
The Crio-RT program is 'send aruino data on labview(GUI recent)'
The FPGA program is 'learning9474'
12-20-2022 07:55 AM
@sarwatsarfaraz wrote:
Alright, so what should I do to "know what I'm doing"? Would love a couple of advice since I'm totally new to LV and Crio.
Is there anything I'm doing the wrong way?
Btw, this program (the LV project which runs on three computers, one on Windows, on crio RT and FPGA too) runs perfectly fine. I've tested in on my remote vehicle many times.
And I still didn't get the answer to my question.
The main VI that runs on Windows is by the name 'Host Program'
The Crio-RT program is 'send aruino data on labview(GUI recent)'
The FPGA program is 'learning9474'
I'm guessing that Bob is gently trying to say that, to give you any real help, you have to at least know some basic LabVIEW, and it would even be better if you understood some more advanced concepts. For my two cents worth of advice, I think it is perfectly acceptable to start the intermediate program separately and have the FPGA code "load n go".
12-20-2022 08:27 AM
First, thank you for attaching the Project view, showing that I was correct and you really are running a LabVIEW RT system with three processors, Host (PC), Remote (cRIO), and FPGA.
@billko pointed out something that I overlooked, so I apologize, and will try again.
As I understand it, what you want to do is the following steps:
Here's what you need to do:
So by the time the Host is ready to run the program, the Remote and FPGA code are up and running, and all the Host needs to do is "reach out and connect".
Bob Schor
12-20-2022 09:48 AM
@Bob_Schor wrote:Here's what you need to do:
- Configure your LabVIEW RT program on the Remote to start the FPGA code running shortly after the Remote starts running.
- Have your Host and Remote start some form of "hand-shaking" protocol (not unlike establishing a TCP/IP connection) to "find each other", typically by IP address. Generally I've done this making the assumption that the Host knows the Remote's IP (which is usually fixed), so can "ping" or something like that to find it. I use Network Streams when dealing with LabVIEW Real-Time, so I configure the Remote to "Listen" for a connection and the Host to try to initiate it. Since I "expect" the Remote to be on-line at a fixed IP, I set the Host to try to connect, with a 15 second timeout, and if it fails three times (45 seconds), it "gives up" and says "Remote not found" or words to that effect.
So by the time the Host is ready to run the program, the Remote and FPGA code are up and running, and all the Host needs to do is "reach out and connect".
I do the same except I use the low level TCP primitives. I just never became a fan of the Network Streams. I used to really like the STM library, but more recently found it too restrictive and have made my own library similar to it.
So to reiterate the solution:
1. You make a build for the cRIO RT. If you have it loading the FPGA, that will be taken care of for you.
2. Load the cRIO build onto the cRIO and make it "Run at start". Reboot the cRIO to complete the deployment.
At this point, the cRIO will always be ready for you and you will only need to start your Windows VI.
12-20-2022 09:55 AM - edited 12-20-2022 09:56 AM
@sarwatsarfaraz wrote:
Alright, so what should I do to "know what I'm doing"? Would love a couple of advice since I'm totally new to LV and Crio.
Is there anything I'm doing the wrong way?
Btw, this program (the LV project which runs on three computers, one on Windows, on crio RT and FPGA too) runs perfectly fine. I've tested in on my remote vehicle many times.
And I still didn't get the answer to my question.
The main VI that runs on Windows is by the name 'Host Program'
The Crio-RT program is 'send aruino data on labview(GUI recent)'
The FPGA program is 'learning9474'
See https://www.ni.com/en-us/shop/compactrio/compactrio-developers-guide.html
Review examples for cRIO.