LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Passing Ramp Array Elements Iteratively to While Loop

Hello everyone,

 

I’m a student currently learning LabVIEW for a project, and I’ve been facing some difficulty with a concept. I’d be really grateful if anyone could offer some guidance or suggestions.

 

I’m working with a Ramp function for a Kikusui Electronic Load, which generates an array of values based on given start and stop values. What I want to achieve is:

  • Pass each element of the ramp array one by one to another while loop, synchronized with each iteration of that loop.

  • Once all elements of the array are sent, I want to stop sending data until I generate a new array again using the ramp function.

  • I plan to reuse this logic whenever I need to pass a new array.

My main issue is that when I place the ramp function in a separate while loop and try to pass the array using a concatenated tunnel, the whole array is passed at once, and the execution waits for the first loop to finish which stops the world loop for a while. This is affecting my timing and real-time performance.

 

I’ve tried using the iteration count of the main loop as an array index, but that approach isn’t reusable or flexible.

I’m attaching my sample VI and a screenshot of the code.

 

I’m very new to programming and LabVIEW in general, and I’m just brainstorming and learning through experimentation. If anyone could suggest a better approach, or share a similar piece of working code, it would be a huge help to my understanding and learning.

 

Thank you so much in advance for your time and support!

 

Best regards,
Varghese

0 Kudos
Message 1 of 6
(228 Views)

As a first step, learn about race conditions, for example your "numeric" (I am sure yo can come up with a more intuitive label!!) is read via a value property node (A) and that happens in parallel to the update of the indicator (B), you cannot predict what happens first, but the result will differ. Eliminate the value property node and just use a wire from the iteration terminal. There is a lot more "code smell", so this is just a first glance.

 

altenbach_0-1756824981106.png

 

Also:

  • A FOR loop with one iteration is just a glorified sequence frame
  • Your iteration value will grow forever, if you are ramping or not.
  • Naming a control "Boolean 2" does not tell us its function
  • A terminal should always show the label (current graph). (I also would not call it graph it it is a chart.)
  • All your ramp values seem to be integers, so why is there orange at all?
  • What is the holding time supposed to do?
  • Why would you need to recalculate the entire ramp with each iteration of the loop?
  • ...
0 Kudos
Message 2 of 6
(207 Views)

@Varghese89 wrote:

My main issue is that when I place the ramp function in a separate while loop and try to pass the array using a concatenated tunnel, the whole array is passed at once, and the execution waits for the first loop to finish which stops the world loop for a while. This is affecting my timing and real-time performance.

You need a simple state machine (idle, change ramp, abort ramp, ramping, etc).

 

0 Kudos
Message 3 of 6
(177 Views)

See if this rough draft can give you some ideas....

 

 

Message 4 of 6
(168 Views)

Hello Altenbach,

 

Thank you so much for taking the time to help me out, I truly appreciate your support and for sharing your rough draft VI. 

 

Just to clarify a few things from my side:

  • My goal is for the holding time to maintain a constant output value during that period, without recalculating the ramp values each iteration.

  • I only want to generate and send a new ramp after the completion of the current ramp, not during or in between.

Regarding your rough draft:

 

First of all, I want to say that it's very neat and easy to follow. I learned a lot by just going through it. I noticed there's a Chart history being maintained, and I'm curious to understand its purpose — what does it represent and how is it used in the flow?

 

Also, I’m still trying to figure out one specific part:
During the ramping state, I see that we’re accessing the ramp values one by one using the array index and showing it on chart. However, I’m unsure how to pass these individual values to a second while loop in sync with each iteration.

For example:

  • On the first iteration, I want to pass “0” to the next loop.

  • On the second, “2”

  • And so on — until the ramp completes.

  • After the final value is sent, the output should stop (idle).

Right now, it seems like the entire array is being passed out of the state machine, but I need only the current value (based on index) to be passed one at a time.

 

I’m still learning, and I know I have a long way to go, so I really appreciate your patience and guidance. If you could shed some light on how to achieve this part or point me in the right direction, I’d be incredibly grateful.

Thanks again for your time and the wonderful example!

 

BR,

Varghese

0 Kudos
Message 5 of 6
(106 Views)

@Varghese89 wrote:

First of all, I want to say that it's very neat and easy to follow. I learned a lot by just going through it. I noticed there's a Chart history being maintained, and I'm curious to understand its purpose — what does it represent and how is it used in the flow?


An chart has a history buffer and if it runs out, the oldest element gets removed. This buffer is retained between runs. I use a property node to clear the chart history by writing an empty array to it.. If you don't, the chart will show stale data from previous runs of the same session.

 

 


@Varghese89 wrote:

 

Also, I’m still trying to figure out one specific part:
During the ramping state, I see that we’re accessing the ramp values one by one using the array index and showing it on chart. However, I’m unsure how to pass these individual values to a second while loop in sync with each iteration.

For example:

  • On the first iteration, I want to pass “0” to the next loop.

  • On the second, “2”

  • And so on — until the ramp completes.

  • After the final value is sent, the output should stop (idle).

Right now, it seems like the entire array is being passed out of the state machine, but I need only the current value (based on index) to be passed one at a time.


Why would you need a second loop? Can't you just communicate with the instrument in the same loop? Just branch the wire going to the chart and also send it to the device.

 

(Of course you can complicate things by using two parallel loops. There are plenty of ways to communicate (queues, channel wires, etc.). What is your definition of "in sync"? Any hard timing requirements?)

0 Kudos
Message 6 of 6
(78 Views)