LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I create a start/stop button for each separate while loop within my program, when each of them does a different task?

hey 

Thanks for the reply , I did searched for state machine.

Even I got a solution on web but couldnt able to figure somethings

Can you send me a VI example doing the same.

I Need to start a loop for some seconds and stop it and again start (reapeating the process)without stoppping the VI.

I have to log data to csv file for that I Need to monitor some parts of VI and save data in other part in same VI.

 

even i have attached the save VI

0 Kudos
Message 11 of 20
(2,288 Views)

Hi vishal,

 

I'd suggest starting your own thread with a new question.

Try and indicate what you want to do, what problems you've had so far, and which bits you're needing help with.

 

I'd also guess the State Machine might be helpful, although you can consider (for monitoring) the use of a Producer/Consumer where the Consumer is your monitoring loop. The producer could be one of the states of the state machine - note that I don't mean that you should nest loops inside one another for the SM/Producer, although you could if it is really necessary. However, a State Machine can certainly manage without that complexity!


GCentral
Message 12 of 20
(2,282 Views)

Hey

Thank you

 

Right now I am using a state machine to make timed logging of data ,

But,wanted to know how to Count the number of Elements in each column in arrray  (say 2d ).

I want to compare the number of Elements which i get for  particular seconds and stop and start the timer 

and for this time I am logging the data.

0 Kudos
Message 13 of 20
(2,241 Views)

Hello,

 

I was able to Count the Array Elements (Array size) and then took the first element to get number of Elements in each column (index array)

but, I want to compare the value with another number and ist not Happening because of different data type

one is variant and another is 64 bit double precision .

how can I compare the data or which conversion block I have to use ?

 

Picture is also attached 

0 Kudos
Message 14 of 20
(2,234 Views)

If we're looking at the top right corner, then it looks like you're not using Index Array but instead one of the OpenG VIs, perhaps array of variants to a variant, or something like that?

 

You can just compare (e.g.using equals, Greater than, whatever from the comparison palette) if you want to compare the array size. Indexing will get you either column length or row length as you already described.

 

In general you can use Variant to Data to convert a variant to a specific type, but I don't think it should be necessary here.


GCentral
Message 15 of 20
(2,230 Views)

Hello Cbutcher,

 

Thanks for your Reply, please also recommend solutions for below issues

 

1.I added the index Array block,

but, when I am running this VI , and Pressing the button to log data , Array size block is giving 50,000 samples(i have put 50k as rate and sample per channel in acquistion VI) beacuse of which select is not triggerd and i am not able to go to wait Event again.

 

2.Also, sometimes

 "Memory is full" issue Comes up: the top Level VI saving.vi was stopped at Array to spreadsheet string  A2T on the block diagram

How to optimize the Memory ?

 

3. even when I am reading the data from Reader stream from saving VI, and when Monitoring with indicator data Display is not constant it fliashes(Maybe beacuse of delay in getting the data)

 

 

Regards

Vishal

Download All
0 Kudos
Message 16 of 20
(2,198 Views)

Ok, so let me try break these down a bit:


@vishal231 wrote:

1.I added the index Array block,

but, when I am running this VI , and Pressing the button to log data , Array size block is giving 50,000 samples(i have put 50k as rate and sample per channel in acquistion VI) beacuse of which select is not triggerd and i am not able to go to wait Event again.

 


The "Array Size" here is the size of a single dequeued element. So it doesn't accumulate over time, as you've already seen.

If what you want is to repeatedly dequeue until the combined amount of data is greater than some amount, I'd suggest using a Shift Register with that value (the total target) being set at the start of acquisition (and reset each time you want to get another block) and then subtracting the size of the current block from the shift register. Check if it is less than zero, in which case you've acquired more than that number of points.

Is that what you need?

 


@vishal231 wrote:
3. even when I am reading the data from Reader stream from saving VI, and when Monitoring with indicator data Display is not constant it fliashes(Maybe beacuse of delay in getting the data)

I'm not exactly sure what you mean here. Do you mean "waveform graph 2"? Or "Current"? Or perhaps a different indicator?

WG2 will update once for each waveform, but the effect of the way it's structured will be to have most of them flicker through very quickly, then one remain on the graph until the next Dequeue operation, so it will effectively flicker every 500ms probably.

You might want to take a look at placing it outside of the For loop, and passing it an appropriate data format for multiple plots.

If you want them to append to each other, you'd need to use Shift Registers and the Append Waveform (inside the For loop is probably best to append) to store history, but beware that this will also increase your memory usage (because you'd never release previous data).

 

To store only a certain amount of history, you can search for information about "circular buffers", which essentially forget data once it is old (so for example, retain the last 5 dequeues, or the last 50, but not an infinite quantity). This allows you to know how much memory will be needed (if the dequeues are a constant length). If not, it at least bounds the quantity (and you could implement it in terms of points rather than dequeues to ensure a constant length memory buffer).


GCentral
Message 17 of 20
(2,192 Views)

Urgh. The quoting interface on these forums is so error prone - I just saw I deleted my section 2 response when trimming quotes before. Oops... I'll try remember what I wrote...

 


@vishal231 wrote:

2.Also, sometimes

 "Memory is full" issue Comes up: the top Level VI saving.vi was stopped at Array to spreadsheet string  A2T on the block diagram

How to optimize the Memory ?

 


It seems like you're logging quite a lot of data - does it have to be in a text file? If you can use binary or TDMS instead, that might be helpful for you.

TDMS is a binary file with a specific format specified by NI that is well suited to storing time-series data (i.e. how something changes over time).

 

If you can use a binary file format instead of the text file you're currently logging, you'll get the following benefits:

  • You save a lot of disk space
  • You can store more accurate data
  • You don't need to convert to strings
  • It will probably write and read the file much faster (but I'm not sure how to quantify "much faster" without testing)

If the dataset is just too large even without the string conversions, or if you must use a text file, then you could consider using a smaller data chunk (i.e. dequeue more often, smaller blocks). This will allow your system to write to disk and forget the data faster (assuming you're not keeping it all in memory for the graph as I described in my first response, which should have included some of this...)


GCentral
Message 18 of 20
(2,183 Views)

Hello 

Thaks your detailed Reply,really appreciate your effort

 

You are Right, I am storing a lot of data, I will try to store in TDMS file

 

1. I can store current data ? or how can i empty my Queue when bot using.

My data acqusition  Keeps on running but, when i want to record data i get old data in my file(takes data and record data just below from where it recorded last time though,i am running acquistion at other time)

I did added time out in streams and even in Queue but it did not worked , is it not what it should be doing?

 

2.Also,i am have 5120 samples per channel and storing These in text file  using Array to spreadsheet string but a emply line at every 5120 samples is getting stored and I am having emplty linees in my file. how to remove that single empty line?

 

3.I want to chnage the sampling rate, Right now sampling rate is 51,200 though I  have kept 50,000 as rate in sample Clock.

 

Regards

Vishal Kaushik

0 Kudos
Message 19 of 20
(2,164 Views)

M VI

Download All
0 Kudos
Message 20 of 20
(2,163 Views)