AOE 3054 Spectral Analysis & Programming Options.

48
AOE 3054 Spectral Analysis & Programming Options

Transcript of AOE 3054 Spectral Analysis & Programming Options.

AOE 3054

AOE 3054Spectral Analysis&Programming Options1Spectral Analysis Lab AgendaSpectral Analysis and AliasingExperiment 6b LabView Preparation6b Experimental Idea- Impulse Input (Optional)

2Spectral AnalysisOften, you will sample a signal that is not a simple sine or cosine wave but a combination of several.Fouriers theorem states that any waveform in the time domain (that is, one that you can see on an oscilloscope) can be represented by the weighted sum of sines and cosines. The combined waveform appears in the frequency domain as amplitude and phase values at each component frequency.Open ExampleVI.vi and run the vi. Adjust the 3 frequencies. What does the code do?Spectral Analysis

Spectral AnalysisNow add a spectral measurements VI to the block diagram (Express>Signal Analysis>Spectral Analysis). Select Magnitude (Peak), Result>Linear and Windowing>None on the pop up window.Input the combined signal wire into the Spectral Measurements VI and add graphical indicators to the phase and FFT outputs. This should result in.

Spectral AnalysisAmplitude and phase spectra obtained from the Spectral express VI (Express>Signal Analysis>Spectral)Spectral Analysis ExercisesVary the frequencies of the signals and understand what is happening to the amplitude and phase spectra.Spectral Analysis - AliasingOpen the Aliasing LLB (LabView Library File), then double click on the Aliasing.VI in the LLB manager screen.Follow the instructions under the Description section of the program, which provide a number of different exercises to learn about aliasing in experiments.Spectral Analysis - Aliasing

Aliasing ExerciseVary the signal frequency for a fixed sampling rate until the signal is greater than half the sampling rate. What is happening to the sampled frequency in the spectrum? Can you relate this to the way the spectrum is computed?Spectral Analysis Lab AgendaSpectral Analysis and AliasingExperiment 6b LabView Preparation6b Experimental Idea- Impulse Input (Optional)

11Experiment 6 Digital IntroductionIn the second Instrumentation Lab (Experiment 6a), you manually controlled a function generator to excite a beam and used an oscilloscope to measure the response of that beam.Week 5s Instrumentation Lab is essentially a redo of the first Experiment 6, but will incorporate new digital measurement techniques to automate most of the data taking.12Experiment 6 Digital IntroductionSpecifically, you will be using the myDAQ to output a voltage signal that will control the function generator. The myDAQ will also measure the function generator output as well as the output from the proximeter. The code you create will cycle through output voltages until the resonant frequency is found.All operations will be controlled via Labview, using a code that will be created today.Further details of Experiment 6 Digital can be found on the course website.13Automated Data AcquisitionWe will write a code that sweeps frequency and looks for resonance.LabView is not a linear programming language. You can add various functions on your block diagram and they will be all run simultaneously. To find the resonant frequency we need to perform the following operations in a specific order:Adjust the frequency on the function generator using the MyDAQ analog outputLet the beam adjust to the new frequencyTake measurements using the MyDAQ analog inputsAutomated Data AcquisitionFlat Sequence (Programming> Structures> Flat Sequence)

The flat sequence consists of a series of frames or actions that are executed sequentially. Frame 1 will be executed and then Frame 2. Add frames before or after an existing frame by right clicking on either the right or left boundary of the frame, respectively. The frames execute from left to right. Add three frames to a blank vi. This will be the building block for your code this week.Frame 1Frame 2Frame 1Frame 1 will be used to set the frequency of the signal output by the function generator, which drives the beam.Open your final VI from last instrumentation lab.Copy over the modified HW 2 subVI and DAQ assistant- the ones that convert a frequency to voltage and output it- to the Block Diagram of a new VI. Double check that the DAQ assistant is set to output a voltage on the AO0 channel (refer to previous lectures on how to do this).Label the numeric control input as Starting Frequency and place it outside of the frame structure.A picture of this is shown on the next slide.Frame 1

Frame 2The purpose of Frame 2 is to intentionally set a delay between Frame 1, which changes the forcing frequency on the beam, and Frame 3, which measures the response of the beam.This time delay allows the beam to adjust to the new frequency and settle into a consistent sinusoidal response pattern.From your Block Diagram, right click to bring up your Functions Palette. Then, go to Programming->Timing->Wait (ms), and drag and drop into Frame 2.Create an input control to the function, and keep the label as the default milliseconds to wait.How many ms is sufficient? That can be something you test in 6b to find out.

Frame 3In Frame 3, the excitation frequency output from the function generator and the beam response, output by the proximeter, will be measured for a specified number of samples.Copy and paste your final code from the previous instrumentation lab into Frame 3.Delete the components that were already copied over to Frame 1.Right click the edge of the while loop and click Replace with for loop.Note: Youll likely have to drag and expand the size of your frame structures to include everything.

Frame 3

Frame 3Create a numeric indicator to control the upper count limit of the for loop. Label it Number of Measurements.This is not to be confused with the number of samples already wired into the DAQ Assistant. To clarify, for each iteration of the for loop, the DAQ samples N number of samples to output a value for the excitation and response amplitude, frequency, and phase. The number of total iterations is set by M Number of Measurements.Also remember that all of this is occurring for a single excitation frequency.How large must M and N be to obtain accurate answers? That can be something you investigate during lab 6b.Frame 3After N iterations of the for loop, we wish to average the results to obtain a single value for both the excitation frequency and response amplitude.To do this, we must use shift registers and arrays in a similar manner as Homework 4.Create two Initialize Arrays and place them outside the loop on the left. Create a constant of 0 to wire in to the initialization value input of the arrays.Wire these arrays to your for loop. Make sure you add shift registers (right click on the for loop wall).Refer to the HW 4 help Powerpoint for a refresher on any of these materials.Frame 3

Frame 3Next we need to add somewhere to store each excitation frequency/response amplitude value from each iteration of the loop.To do this, create two Insert into Arrays (Programming->Array) inside the for loop.Wire the loop iteration counter into the Index input for each array.Wire the previous arrays from the shift registers on the left into the array input on each Insert into Array.Wire the excitation frequency output from the subVI into the New Element input of the top array.Wire the response amplitude output from the subVI into the New Element input of the bottom array.Wire the output arrays to their respective Shift Registers at the right side of the for loop.Frame 3

Frame 3Now, we need to average the results from the arrays.Add two Mean functions (Mathematics->Probability and Statistics -> Mean) outside of the for loop on the right. Wire the outputs from the for loop (at the shift registers) into these functions. Wire the mean outputs to the wall of the frame structure.Create an indicator for the response amplitude, label it Mean Resp. AmplitudeFrame 3

Automating the CodeThe code, as currently written, will excite the beam at a given frequency (controlled by a single numerical input) and measure the excitation signal and beam response for that frequency.We need to write code that will sweep through to find the resonant frequency.Our approach is based on the fact that the beams response amplitude is at a maximum at resonance.Automating the CodeFirst, create a while loop around the entire code so far except for the Starting Frequency control.We will use the while loop to start at a low input frequency, sweep through excitation frequencies and stop when resonance is reached.Automating the Code

Automating the CodeWe want to set the input frequency to increase each time the code is executed.To do this, create a numeric control inside Frame 1 and label it Freq. Increment.Multiply this number with the while loop counter (The blue icon at the bottom left of the loop).Add this number to the initial frequency input. This way, each time the loop executes it increases the excitation frequency by the frequency increment.Automating the Code

Automating the CodeNext, we need to set our condition for stopping the loop. We want this to occur when the response amplitude reaches a maximum.We will stop the loop when the response amplitude begins to decrease.To do this, right click on the right side of the while loop and Add shift register. Note that it will appear black for the time being.Wire the mean response amplitude output from Frame 3 to the shift register. This sends the final response value from one iteration back to the start of the next iteration.Underneath Frame 3, add a