LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating "Series" of Case Statements to Manipulate Waveform

Solved!
Go to solution

Hi All,

 

I'm trying to find a way generate an 'unknown' number series of case statements, the number of which will be determined at program start (the minimum number of which is zero, and the maximum number is not known). Assuming we are given the required number of case statements as an integer n, I would like to do the following:

 

1) A waveform signal feeds either: the first case statement (if there is more than one or more), or the waveform chart if the number of case statements is zero.

2) If another case statement is required, create it and feed in the output from the previous case statement. If there are no more case statements requried, feed the output from the last case statement to the waveform chart.

3) Repeat 2 until there are no more case statements required (# of case statements = n)

 

A simplified visual representation of what I am talking about for two cases is in the following image:

(For those wondering: The command values will be read from an array of size n.)

Loop Example Visual.png

I realize the system will not be visible this way. I'm just hoping there is way to generate this system using a loop.

 

Any help is greatly appreciated. Please let me know if you have an idea but need clarification.

 

Regards,
Stefan

0 Kudos
Message 1 of 9
(3,220 Views)

Search for ...

 

State Machine

 

and

 

Shift Register

 

The State machine will let you control the work done on the data and the Shift Register will store your results of one step to be acted on by the next step.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 9
(3,213 Views)

You need to explain your task better, because you are basically asking for a program that writes its self. 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 9
(3,211 Views)

@RTSLVU wrote:

You need to explain your task better, because you are basically asking for a program that writes its self. 

 


Spoiler
From what I learned from the Hamster Theory of RSX the self generated code would wake up and tell itself to go to sleep. Lather rinse repeat.

 

Smiley-wink

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 9
(3,204 Views)
Solution
Accepted by stefan2h

Do you have a finite set of "commands"? Create a case structure containing one case per command (and a default case wired across) and place it inside a FOR loop. Wire the data via a shift regsiter across the case structure.

Create an array of commands and autoindex on the left loop boundary and wire to the case selector.

If the array of commands is empty, the data will exit the loop unchanged. Else it will process the data with all commands in the order they exist in the array. The array can even have duplicate elements, causing application of the algorithm multiple times in a row.

Message 5 of 9
(3,181 Views)

Hi altenbach,

 

I do have a finite set of commands. I should have explained this more clearly. This sounds like exactly what I want to do, I just didn't know it. I will look into your suggestion more closely tomorrow when I am back at my workstation.

 

Thank you very much for taking the time to write such a detailed reply.

 

Stefan

0 Kudos
Message 6 of 9
(3,151 Views)

Hi again altenbach,

 

Here is my implementation for others interested. In my case I actually have a 2D array. Each row is a new command AND set of parameters that indicate magnitude, start and end times of the waveform modifications I want to make. To take care of the start and end times I used a nested case statement. This can be seen in the attached vi.

 

Thank you again.

Stefan

0 Kudos
Message 7 of 9
(3,127 Views)

Here are a couple of tips.

 

1.  Index Array is resizable.  Just drag down the bottom border.  Wire i into the top of the first element.  Wire 0 into the bottom of the first element.  Now you'll get i,0  i,1  i,2  i,3  like you do now without splitting the array wire, without needing 3 more index arrays, and without needing the extra wires and constants for the index inputs.

2.  Rather than a 2-D string array, I'd use a 1-D array of clusters.  Each element of the cluster could be a string, a double and a pair of U64's.  That way you can be sure you have the proper data entered into each one  (what would happen if you accidentally had a character in string field that was being converted to a number?).

3.  Instead of adding one in the timed loop, use the increment function.  I would actually merge the display loop with the tick count loop.

0 Kudos
Message 8 of 9
(3,120 Views)

Seems a bit convoluted.

  • The inner loop should be a FOR loop because you know the number of iterations before the loop starts.
  • You can autoindex on the string array, giving you one row per iteration
  • Index array is resizeable, only one instance needed.
  • (taking the array size belongs before the loop, because it does not change during the loop, but with a FOR loop you don't need it anyway).
  • Most of your indicators have the wrong representation (see all these corcion dots?)
  • All that "tick count" stuff with three parallel loops seems very comvoluted. What is it supposed to do?

For example the upper left of your inner loop could be simplified as follows:

 

0 Kudos
Message 9 of 9
(3,118 Views)