LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass data to SubVI

Hi,

 

I was given the source code of a program, which measures analog data. My task is to expand this to read data from a ModBus device. I am able to read the values, but I fail to pass those values to my SubVI.

 

I am not allowed to post my code but I made a drawing, illustrating the situation:

mw42_0-1629213539175.png

 

The red part is my ModBus device, I get my correct values (green 1,2,3) within the while loop.
The upper while loop contains my SubVI. This SubVI has all the analog DAQ going within the SubVI.

What I currently fail to achieve is to pass my values (1,2,3) to the upper while loop.

I tried a queue and a stream channel, but I am not able to read ANY values from the queue or channel while in the upper while loop.

 

There has to be a major flaw in my understanding (i think). Does anyone have advice for me please?

 

Thanks

 

0 Kudos
Message 1 of 8
(2,550 Views)

We probably need to see the actual VIs, not a cartoon drawing. 😄 (mainVI AND subVI)

 

How is the subVI configured? Does it return quickly or run independently? If it returns quickly, you would just place it in the lower loop right next to the received data.

 

Why are there so many while loops? What is the loop rate of the upper loop? Why is there an inner loop in the lower code? How often does it complete?

0 Kudos
Message 2 of 8
(2,543 Views)

@mw42 wrote:

What I currently fail to achieve is to pass my values (1,2,3) to the upper while loop.

I tried a queue and a stream channel, but I am not able to read ANY values from the queue or channel while in the upper while loop.


A queue is what I would have used.  Unfortunately, you are going to have to create a simple example showing your issue for us to help figure out what you are doing wrong.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 8
(2,542 Views)

You are going to have to post some actual code for anyone to offer any real help for your problem.

 

If your code contains some proprietary code that you can't share (it does happen), just make a simple replacement sub-vi or whatever as a place holder.

 

As your issue seems to be a very general architecture problem, we probably don't need anything that would be considered proprietary anyway.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 8
(2,531 Views)

I'm guessing that what you are struggling with is to pass data between the loops. Read how to here.

Certified LabVIEW Architect
0 Kudos
Message 5 of 8
(2,494 Views)

To narrow down the issue, you can also try using the Global variable and make sure you have don’t have data flow issue. If you could get data through Global varible then issue could in the Dataflow/Architecture or in the Queue configuration.

0 Kudos
Message 6 of 8
(2,478 Views)

Thank you so much for your advice.

 

Until now I have tried a queue, a channel writer / reader and now a global variable.

 

I tried my best to create code which would be able to describe my problem, maybe I have removed too much or some important parts... Well, you see the "hot mess" as an attachment. Please keep in mind that this code was handed to me and I was tasked with "add your ModBus data to it and make it available for the SubVI". Neither myself nor the original creator are very good at this.

 

To describe the code:

The "Forum_Main.vi" has the Front Panel and handles the interaction with the user and the display of graphs (and, in this case, the connection and data aquisition with my ModBus device).

The "Forum_SubVI.vi" does everything cDAQ related (create DAQtask, aquire analog data, calculate data, fill waveform with said data).

Now, my SubVI needs my ModBus information because this information is necessary for some calculations within the SubVI. And that is my problem because I cannot get my ModBus data to the SubVI.

 

Addendum: I also tried to place my ModBus code directly into my SubVI, but that did not work at all because my cDAQ device stopped aquiring / displaying data.

 

Thank you all for your input, I am sorry that I have to be so scarce with my code.

 

Edit: Forgot my "Global 1.vi" attachement

Download All
0 Kudos
Message 7 of 8
(2,459 Views)

Hi mw,

 


@mw42 wrote:

Until now I have tried a queue, a channel writer / reader and now a global variable.


Right now you store your Modbus data in 3 global variables: just read those global variables in your subVI (at the right place at the right time)!

 


@mw42 wrote:

Well, you see the "hot mess" as an attachment.


Yes, even after deleting most of the code this code still is a mess…

 

You really need to think about proper program design!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 8
(2,454 Views)