08-17-2021 10:24 AM
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:
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
08-17-2021 10:39 AM - edited 08-17-2021 10:41 AM
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?
08-17-2021 10:39 AM
@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.
08-17-2021 11:00 AM
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.
08-18-2021
06:58 AM
- last edited on
05-05-2025
03:09 PM
by
Content Cleaner
I'm guessing that what you are struggling with is to pass data between the loops. Read how to here.
08-18-2021 10:22 AM
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.
08-19-2021 04:32 AM - edited 08-19-2021 04:42 AM
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
08-19-2021 04:41 AM - edited 08-19-2021 04:44 AM
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!