LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build Array

Solved!
Go to solution

Hi Guys

Need some help over here

My goal is following

1. Create an array based on values programitlitly beeing passed into the array

2. This should happen everytime  when a boolean value goes true.

3.The array building function should wait 6 s when the value goes true before storing it into the array

 

My problem is that when i press True, and   start changing the value to desired value before 6 second passes, the value passed to the array after 6 seconds is the start value before i changed to the desired value betwwen 1-6 seconds.

It drives me crazy

And the desired value needs to come inside  from an sequense structure

Se the attached value

 

0 Kudos
Message 1 of 46
(3,962 Views)

All you need is a single case structure containing your terminals, the 6 second delay and the "build array node". Wire directly, and don't use the local variable. Make the button latch action, so it automatically reverts to false when the new value has been read by the code.

 

You should also initialize your shift register and place a small delay inside the big loop.

 

What you have is several race condtions. The following three nodes all execute in parallel:

  • case structure 1
  • case structure 2
  • local variable read

In particular, when you press the button, the local variable is read before the first case reads the terminal, meaning the value from the local variable is stale. LabVIEW does not execute left to right. Execution order is determined only by data dependency.

 

In general it is not a good idea to stall code for long times. You might simply want to start a timer whenever an element is added and disable the button for a given amount of time.

0 Kudos
Message 2 of 46
(3,950 Views)

@torkil wrote:

And the desired value needs to come inside  from an sequense structure 


Why? Your sequence frame has absolutely no function here.

0 Kudos
Message 3 of 46
(3,948 Views)

Thx

U havent got a photo of the solution.?

Its 4 o clock passed midnight in my country and im a little tired.

Have been working on this for 14 hours now so im kinda tired.

 

Thx in advanced

 

0 Kudos
Message 4 of 46
(3,947 Views)

This is a part of a big big code im working on.

The sequense does some heavy sampling(Timed structure on 1000 Hz) and maths in my code,to big to post here but it summuns the issue

The sequense structure start the sampling when a button is pushed on the front. Then it samples for 6 seconds, does some heavy math and return a value shown in a array on the front

Smiley Happy

0 Kudos
Message 5 of 46
(3,946 Views)

torkil wrote:

The sequense structure start the sampling when a button is pushed on the front. Then it samples for 6 seconds, does some heavy math and return a value shown in a array on the front


It still does not mean that there has to be a sequence structure. Sampling will start for six seconds and the heavy math (whatever that is) cannot start until the sampled data is ready. Thus execution order is fully determined without any sequence structure.

 

Anyway, here's some code skeleton that starts sampling for 6 seconds when the button (latch action!) is pressed, then appends the result to the existing array. Makes sense?

 

 

0 Kudos
Message 6 of 46
(3,913 Views)

Thx

I have ried a lot of codes also this version before

The problem is when i take a sample the build array stores the start value coming out of the sequence   not the new value made after 6 seconds that i want to

An example is when i press the button to take a sample and the start value is sett to 0 and before the 6 seconds have gone i changes the value to 4 i want it to put that value into the array not the 0

 

 

0 Kudos
Message 7 of 46
(3,890 Views)
Solution
Accepted by topic author torkil

Put the numeric terminal in the second frame of the sequence. This way it will only get read after the 6 seconds.

Message 8 of 46
(3,842 Views)

hi i need help on this

0 Kudos
Message 9 of 46
(3,762 Views)

@dalrezaz wrote:

hi i need help on this


First of all, don't hijack another thread.  Start a new one for any new problems.

Secondly, please post the actual VI when possible.  Posting word documents to get around the BMP restriction is annoying.  If you have to post an image, make it a png or jpg.

 

Now from what I can tell from your picture, you need to change the data type for the Spreadsheet String to Array function.  I used a 1D array in the snippet below.  I don't know if you need it to be a 1D or 2D since I don't know what you are trying to accomplish.

spreadsheet string to array.png


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 46
(3,749 Views)