Signal Conditioning

cancel
Showing results for 
Search instead for 
Did you mean: 

sub array from a waveform array and Moving Average of consecutive ms window.

Hello, 

 

I am simulating a sine wave (with noise), 1000hz sampling, number of samples = 100. 

 

Suppose I run 1 minute (60000ms) I would like to average the signal every 100ms. that is, average the signal from 0-100, 100-200... (running average). 

 

I have stored the data from the simulated signal into an n dimention array. How do I divide it into sub-arrays, each containing data of 100ms and average the sub arrays individually?

 

or

 

I wanted to use a shift register which could allow me to store the 100ms worth of signal, average that and then move on to the next 100ms for averaging in a loop , as I am fairly new to LABVIEW, Im sort of lost as to how to go about it. 

 

Please help

0 Kudos
Message 1 of 10
(7,128 Views)

Use Reshape Array to turn it into a 2D array.  You can then use a FOR loop with autoindexing to get your means.


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 2 of 10
(7,124 Views)

Dear Crossrulz, 

 

Thank you for your replies, they've been extremely helpful. 

 

I did have a couple of questions, however

 

1.Why cant I see a smooth sine curve? am I doing something wrong?? I see a straight line when its being averaged.

2. On opening the excel file (through add-ins) No values are written down, I get black columns and rows, but a file for each run is generated. 

 

 

Also, I tried another way, (screen shot attached) when  I run the code, the y axis of the time keeps changing, but I dont see a graph. ??

 

Please Help. 

 

Thanks

 

0 Kudos
Message 3 of 10
(7,114 Views)

This is the VI with the Averaged signal. 

0 Kudos
Message 4 of 10
(7,112 Views)

Look at what that VI does:

1. Simulate 100 points at 1000 samples per second.

2. Extract an array from the Dynamic Data Type. Array length = 100.

3. Reshape array to have only two points. These are the first two elements from the 100 element array. The other 98% of the data are discarded.

3. Wire the 2-element array to an autoindexing tunnel into a for loop. Wire 50 to the N terminal of the for loop. How many times does this loop iterate?  Hint: Read the detailed help for a For loop and autoindexing tunnels.

4. Inside the loop do a point by point Mean with the sample length set to default. How many data points are used to calculate the mean? Where do those points come from on the simulated signal waveform?

5. How many points will be plotted on the Averaged Waveform Graph? What do those points represent? 

6. What data will get written to the file? How many points? What does this data represent?

 

You have multiple threads all dealing with the same issue in more than one Board. This irritates people who are trying to help and fragments the results because some people will not see all the threads. Please pick one thread and announce that you will be staying there. Then post links in all the other threads telling other readers where the discussion will continue.

 

What you appear to be trying to do is not particulalry difficult but is not trivial either. For a project like this the chances of success improve greatly when you have a good specification and design before you begin writing code. I doubt you have either a well-written specification (although you may have a pretty good idea of what you want) or a design.

 

Lynn

0 Kudos
Message 5 of 10
(7,091 Views)

Hello Johnsold. 

 

Thank you, for your guidance. I apologize for the multiple threads, I have directed all of them to this post. 

I am gathering a clearer idea as to what exactly I am looking for, Will post it as soon as I get it done. 

 

 

 

0 Kudos
Message 6 of 10
(7,031 Views)

I saw that you had posted messages to the ohter threads consolidating the discussion. Thank you.

 

I think you posted an image of a hand-written document in one of the other threads where you showed some of the timing and spatial relationships. That document is probably the starting place for your specification that I recommended earlier in this thread.  If you want some help with clarifying your ideas, you can post the intermediate steps and ask for guidance. We do no tknow what you want, but someone can probably point out places where your specification is ambiguous or unclear.

 

Lynn

 

 

0 Kudos
Message 7 of 10
(7,017 Views)

Hello Lynn, 

 

Thanks again for your help,  as any data acqusition goes, I want to acquire, analyze and save data. The averaging of the signal I obtained is the intermediate stage. The first step is to acquire data (I am recording retinal potentials-- the stimulus, is a result of 120 LED's flashing on and off). 

 

I have a 120 LED's connected together. (4 rows and 30 columns) They are switched On and Off alternatingly (that is, in a row, 15 go ON and 15 go off. -- ON OFF ON OFF... 30th LED.) The eye responds to this ON and OFF of LED's individually resulting in a stimulus (retinal potential) which is being sent into labview with the help of a USB 6009. As a stimulus is generated for every rising (LED ON) and falling (LED OFF) I want to synchronize the 2 signals (the one from the function generator and the stimulus, so that the recording is precise and I'm obtaining the data that I want at a particular moment in  time.) Achieveing this will solve the acquiring phase of the set up. 

 

I have a question posted here. about synchronizing 2 channles using USB 6009. Attahced here is a more refined image of the previous hand written document. 

 

Thank You. 

 

 

0 Kudos
Message 8 of 10
(7,013 Views)

Hello, 

 

I had a question Regarding the topic of discussion, Based on my understanding I tried to generate a block diagram, I wanted to know if I am thinking in the right direction. - My Hardware is still the USB 6009. 

Attached is the VI, The goal is to acquire a signal generated  (channel 2) corresponding to the rising AND falling edge of each transition of the function generator (coming in through channel 1). 

 

Is my use of the trigger function correct?
Can I wire 2 Trigger Functions as shown in the VI - Labview did not give out any error. If I cant, the can I use a case structure (presuming the use of my Trigger function is correct) to acquire the signal at each edge

 

Please Help,

 

Thank You

0 Kudos
Message 9 of 10
(6,939 Views)

Sorry it took me so long to get back to this topic. I have been busy with things which had to get done.

 

Here is a Vi which shows what I was describing earlier. It generates two signals. One is a square wave and the other is a sine wave of the same frequency plus noise. The nosie makes it easier to see the effects of averaging.  These two signals are what you would get by doing a two-channel analog acquisition of the LED drive voltage and the retinal response.

 

The next section finds both rising and falling edges of the square wave.

 

The analysis loop uses the edge arrays, the number of pulses to average, and the number of pulses to skip to separate segments of the noisy sine data and average it. Note that it calculates separate averages of the data when the LED is off and when it is on. You probably need this to identify the stimulated response.  It also creates a set of markers to show graphically which pulses are averaged and which are skipped.

 

Start with the default values to get an idea of how the program works. Then change to other values which might be more realistic to your project.

 

Lynn

 

 

0 Kudos
Message 10 of 10
(6,905 Views)