07-29-2023 06:35 PM
Hi, I am a new user of LabVIEW. I encountered an issue with the output element from an array with a time delay. I have attached a picture of my block diagram for demonstration.
The method I used was exporting the element from the array using indexing. But it seems that only the last value can be exported out of the loop. So I am wondering if it is possible to make the 'Numeric' varies in the same pattern as the 'element' that is within the loop. Many thanks!
07-29-2023 06:45 PM
I think you forgot to attach the image.
07-29-2023 06:46 PM
07-29-2023 06:48 PM
Sorry about this. I have reuploaded the picture and please have a check.
07-29-2023 07:31 PM - edited 07-29-2023 07:45 PM
You need to learn the basics of dataflow. There are learning resources listed at the top of the forum.
To get better help, attach your VI, not a picture!
(For your reference, here's equivalent code that does exactly what yours does. Arguably simpler! Right? Of course this is not the solution because you want a different behavior, which is not entire clear.)
07-29-2023 11:34 PM
@altenbach wrote:
(For your reference, here's equivalent code that does exactly what yours does. Arguably simpler! Right? Of course this is not the solution because you want a different behavior, which is not entire clear.)
The Magic 8-Ball says "I think the OP wants the vi to act as if Altenbach's For loop added a Shift Register, initialized with an empty array of DBL, and a build Array (concatinating) wired from SR in and Autoindexed element to SR out and an indicator as DBL[].
Pointless code, but it may be practical for leaning basics about Loops, Tunnels, etc...
07-30-2023 05:40 AM
Sorry for the unclear question, let me describe it in more detail.
First, my purpose is to output the element in the array continuously with a time delay. I understand that it can be simply achieved by adding the array to for loop and using autoindexing, creating an indicator within the loop and adding the wait function. The element in the array can be indicated one by one. However, I need these numbers for further programming. This can be interpreted to mean that elements in the array are delayed and input into the other function.
Second, from the equivalent code, I can see that the 'Element' indicator can display the element within the array with a 2s time delay. But these numbers can not be extracted from the loop due to the principle of loop operation. So what I am asking can also be interpreted as are there any methods to output the ELEMENT from the array with a time delay without using for or while loop?
I am not sure if I explained it a bit clearer, so if there are still questions feel free to ask. Many thanks.
Kind regards,
Jerry
07-30-2023 06:31 AM - edited 07-30-2023 06:35 AM
@Jerry0117273 wrote:
Sorry for the unclear question, let me describe it in more detail.
First, my purpose is to output the element in the array continuously with a time delay. I understand that it can be simply achieved by adding the array to for loop and using autoindexing, creating an indicator within the loop and adding the wait function. The element in the array can be indicated one by one. However, I need these numbers for further programming. This can be interpreted to mean that elements in the array are delayed and input into the other function.
Second, from the equivalent code, I can see that the 'Element' indicator can display the element within the array with a 2s time delay. But these numbers can not be extracted from the loop due to the principle of loop operation. So what I am asking can also be interpreted as are there any methods to output the ELEMENT from the array with a time delay without using for or while loop?
I am not sure if I explained it a bit clearer, so if there are still questions feel free to ask. Many thanks.
Kind regards,
Jerry
Clearer! 😀
You could use a Notifier to update the Notification Data (as a scalar DBL) to each consumer of the data. You can also use Queues or Channel Wires for that. You could even use a User Event. The choice depends on how many listeners you have and how you use use the data.
I know some posters will say that you could use Local, Global or Shared Variables. They are technically correct but, those are really poorer choices because they break dataflow and are too easy to missuse.
07-30-2023 08:52 AM
@JÞB wrote:
Pointless code, but it may be practical for leaning basics about Loops, Tunnels, etc...
Yes, that was my only "point". 😄
07-30-2023 08:59 AM
@Jerry0117273 wrote:
First, my purpose is to output the element in the array continuously with a time delay.... This can be interpreted to mean that elements in the array are delayed and input into the other function. ... But these numbers can not be extracted from the loop due to the principle of loop operation.
I think you are dealing with a mental block here. You are using terms such as "output" and "extracted", etc. that are very vague. What processes the data later as input? We need to complete picture!
Maybe that further processing can be done inside the loop right there? Maybe you can branch the array wire and process the same elements elsewhere?
Can you be very specific what should happen with these "outputs", whatever that means? Maybe instead of explaining the convoluted mechanics, explain it from the perspective of the user. What does he do and what should happen as a function of his interactions and time?