LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating an array in a 'for' loop (resetting loop count)

Solved!
Go to solution

Hi,

 

I am trying to integrate an acceleration signal coming from a CRIO analogue input to obtain the speed and then further integrate to get the displacement of a vibration system.

I understand that in order to perform the integration, an array has to be fed in. My problem is that I could not buffer the signal in a buffer block as I couldn't find any buffer blocks. so I decided to create my an array of data using a 'for' loop. The 'for' loop nests inside a timed loop. The problem that I got stuck at is how to reset the 'for' loop in order to refill the buffer again at every iteration of the outer timed loop.

 

I have attached the code if that helps. Note that I am using labview 2013.

 

I would be gratefull if someone who had encountered a similar issue before can help me.

 

Regards

Ali

0 Kudos
Message 1 of 5
(3,258 Views)

Dear  Ali_H,

 

you can use "Integral x(t) PtByPt VI"  inside your timed loop. That will add and process new data on the given wire after each loop.

 

The current configuration: a for-loop and the integral thereafter, does nothing else, but results in a <value>*1000*1e-6.

 

Cheers,

0 Kudos
Message 2 of 5
(3,242 Views)
Solution
Accepted by topic author Ali_H

You could use an initialized shift register as the inputs to your for loops, build your array from that. However, you do realize, don't you, that your program as written runs the for loops as fast as the computer can spit the answers out, so the output array may well contain multiple points which occurred before the input has updated? Assuming your cRIO thingy (I haven't worked with these) has timing built into its data acquisition routine, I would suggest putting that inside the loop to get one data point per reading.

 

And do you really only want your distance graph to update only every thousand speed points (million acceleration points)?

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 3 of 5
(3,226 Views)

Your for loop just creates an array of identical element (same as Initialize array) and I am not quite sure why that would make sense to you.

 

can you explain in a few more sentences what you are actually trying to do. If you are getting one point at a time, maybe one of the ptbypt tools would be useful.

 

 

(EDIT: sorry, I did not see that this has been answered already. I still had the unanwered question open from last night and thought it has not been answered)

0 Kudos
Message 4 of 5
(3,201 Views)

Dear Altenbach,

 

Many thanks for your reply.

 

I need to make it clear that I have not had enough hands-on with labview, I have only used it for sometime in the past and now I have to in order to perform some active damping on a 50Hz running machine. I must stress the fact that what i find more intuitive to do in a different programming language (matlab or C) is not as straightforward in labview. so please bear with me if my code has basic mistakes Smiley Happy.

 

All what i am trying to do is obtain the speed and position from an acclerometer signal. unfortunately i dont have a position sensor so i have to measure acceleration then perform time integrations in order to obtain the speed and position respectively. I am using a compact Rio (later in FPGA mode) to take physical measurements of acceleration from the vibratory machine and where i managed to do this bit successfully. when it came to performing the integration, i had to create an array inside my timed loop since i couldn't find a buffer block. I implemented a 'for' loop inside a timed loop in order to build the array. however i got stuck at resetting the count of the 'for' loop in order to refill the array with new values at every new iteration of the outer timed loop. unfortunately, even a sensible answer has been suggested before, i dont seem to have been capable of doing it yet. I really spent all my day trying to figure a way out but not achieved it yet, nevertheless I have learnt many many things by playing around.

 

I would be gratefull if you could comment on a possible way of doing what i am trying to do.

 

Kind Regards

 

Ali

 

 

 

 

0 Kudos
Message 5 of 5
(3,186 Views)