LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help Needed for an Application Recording and Storing Values in an Array

Solved!
Go to solution

@phg wrote:

a) This would happen if the VI is stopped and the 'internal array' in the SubVI has some values (but less than 5), the values remain there when the main VI is started again- so there needs to be some initialization here (?)  Right-o!

b) Still working on that:

- Perhaps I need some logic to check if the VI is at the first iteration, and if so, intialize the 'internal array' inside the SubVI for that case alone?

Initialization needs to be done inside the Do Once loop.  On the Synchronization Palette, there's a very useful "First Call?" function that might help you out.

Would these be the videos you referred to?
http://www.ni.com/academic/students/learn-labview/

That's one of them.  Hooovahh, the LabVIEW Overlord (self-proclaimed, but I'm happy he's there) published a pretty good list somewhere.  I'll look for a link ...

 

Ah, they now appear in the Community's Unofficial Forum Rules and Guidelines.

 

Looking For Free Training

Many times new users of NI hardware or software just don't know where to start.  They will ask a question but without knowing the terms, or the intended purpose, they will not be able to form a proper question.  Here are some free training tools primarily focused on LabVIEW and NI hardware to help get started.

 

NI Learning Center

NI Getting Started

-Hardware Basics

-MyRIO Project Essentials Guide (lots of good simple circuits with links to youtube demonstrations)

-LabVEW Basics

-DAQ Application Tutorials

-cRIO Developer's Guide

 

Learn NI Training Resource Videos

3 Hour LabVIEW Introduction

6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required

 

The best way to learn, is to follow the tutorials, then ask lots of questions. 

 

 


Bob Schor

Message 11 of 16
(1,946 Views)

It works!

 

Works great, and with lot less code than what I had imagined

 

My application is for a real time application, so I need the timed loop, and my question then is:

 

Should I make the "run once" loop inside the SubVI a timed loop as well, or won't that make any difference?

 

Thanks

0 Kudos
Message 12 of 16
(1,942 Views)
Solution
Accepted by topic author ghp_1

No, no, no, the sub-VI wants to run "as fast as possible".  Its timing is "set" by being called from the Timed Loop -- it runs exactly once per Timed Loop.  Note that you can "push" the speed of this sub-VI by changing its execution properties to "In-line Subroutine", since you never need to interact with (or debug) its innards.

 

Bob Schor

Message 13 of 16
(1,935 Views)

Ahh, that makes perfect sense

 

I'm currently trying to take this one step further towards the actual application, for this I need:

 

1. Have the array from "the previous iteration" available to some piece of code (that part is working now)

2. Have some code perform a mathematical operation on every element in the array. For example add 0.013 to every value in the array

3. Record the result from step 2 in an array, and make that available for the next iteration

 

I realized the same code could be used, and simply used the same SubVI (actually had to make a copy of it for it to work)

 

I've tried setting this up, however I'm getting a strange result

 

To analyze it i replaced the random number with the iteration counter for the main loop, so I expect first: array of zero, then array of 1,2,3,4,5 then array of 6,7,8,9,10 where we previously had a random number

 

Then I expect to get as the "math output" the array from the previous iteration, but with 0.013 added to every number

 

This is almost what I get, except the last value is always incorrect (in the "math output" algorithm), can't understand why

 

The size of both stored arrays are the same

 

(What I've called "current_iteration_k" is simply the size of the "internal array" in the SubVI (the one that goes from 1 to 5), I figured this should tell me where I'm currently at in every iteration)

 

Any suggestions? Screenshot of the code below, the SubVI is as you proposed

 

Thanks!

 

UPDATE/EDIT: Think I found the solution; seems like I need to take the "previous array" that I feed to the math operator from BEFORE the SubVI, and not after it

 

Almost_There.png

0 Kudos
Message 14 of 16
(1,925 Views)

I tried checking '"In-line Subroutine" in the SubVI properties page, however then it said the VI is not executable when I tried to run the main program

0 Kudos
Message 15 of 16
(1,922 Views)

Try also setting "Shared Clone Reentrant" (or something like that).

 

BS

0 Kudos
Message 16 of 16
(1,909 Views)