LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making an array in a loop

Solved!
Go to solution

If you see my complete VI you will see why I need 2 loops. Each loop gets different data. The VI I posted before with 2 while loops in a  flat sequence structure is just a representation of what I'm trying to achieve. Also your VI with a case structure does not work because all Data is valid and must be recorded. 

0 Kudos
Message 11 of 15
(163 Views)

@bajajvishal11 wrote:

If you see my complete VI you will see why I need 2 loops. . 


OK, your attached PND is a snippet but your images in the post are not. If you attach code, attach the VI. If you want to show a snippet, embed it in the posts. You need two loops if two things need to run in parallel, but yours are sequential.

 


@bajajvishal11 wrote:

Each loop gets different data. 


This is not sufficient to explain the situation. Where does the data come from? Data is typically different, so that's normal.

 


@bajajvishal11 wrote:

The VI I posted before with 2 while loops in a  flat sequence structure is just a representation of what I'm trying to achieve. Also your VI with a case structure does not work because all Data is valid and must be recorded. 


You still need only one toplevel loop and a proper state machine architecture. Your two loops have almost identical code! Why would a case structure prevent data from being valid or recorded? That argument makes absolutely no sense.

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 12 of 15
(142 Views)

@bajajvishal11 wrote:

Hey, 

 thanks a lot for proposing to have a look at my complete VI. I was just scared people would call me out for putting a big VI up there. Happens in other tech forums where people just want you to ask your very specific question and leave

 


Your VI is not very big in terms of code logic, just the front panel and diagram is unbelievably large for what it does. Why do the front panel objects need to be scattered across twenty HD screens. Why is the code such a sequence worm? I cannot really look at it on my laptop, so this need to wait until I can use a bigger monitor.

 

From a quick glance, this needs to be rearchitected from scratch. Glaring mistakes are:

 

  1. Overuse of sequence structures. Pyramids of while loops.
  2. disconnected controls that are used exclusively for data storage via local variables.
  3. Greedy loops that bur CPU doing nothing except polling a stop button. (see last frame)
  4. What's the difference between "array" and "output array". "array" is empty and you never write to it, so why is it even there? "output array" is derived from an empty array and one scalar and never contains more than one element. What's the point?

LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 13 of 15
(133 Views)
Solution
Accepted by bajajvishal11

@bajajvishal11 wrote:

with initial position (2,2) which then increments in steps of 0.001

the distance at which the angle changes( rather shifts from motor X to Y ) increases by 0.002mm. Something like this:

Spiral_scan_diagram.PNG 


 

Here's one possibility to create your spiral. I am sure it can be simplified further (one loop, no sequence, no local variables. unified code). You should be easily able to adapt it to your problem and increment your stepper motors depending on the changed complex component (RE or IM). (The history trace is just for illustration. You don't really need it)

 

altenbach_0-1618418067688.png

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 14 of 15
(128 Views)

Hey Thanks a lot for that. I didn't know I could use complex number in this way in LabView. Your solution was elegant and I was able to integrate it as it is with just 2 changes in my code. It was great learning. Thanks for that. 

0 Kudos
Message 15 of 15
(88 Views)