abstract - uw faculty web serverfaculty.washington.edu/lum/temp/aa448/lab_1_equipment... · web...

45
Lab 1: Equipment Setup and Filtering Abstract The main goal of this lab is to become familiar with lab equipment, to configure the xPC Target environment for future experiments, and the design and implement a low-pass filter using operational amplifiers (op-amps) and resistor/capacitor networks. Introduction This laboratory covers the topics of Introduction to Lab Equipment o Oscilloscope o Signal Generator o Power Supplies o Multimeter o Kepco Power Amplifier o Dynamic Signal Analyzer (DSA) Configuration of the xPC Target Environment o Introduction to Simulink o xPC Target Settings o xPC Target Libraries o xPC Target Scope o Execution of the xPC Target Realtime Controller o Access of the xPC Target data structure in in Matlab for analysis and plotting Implementation of a second-order, low-pass filter using op-amps and RC networks o Schematics of a second-order, low-pass filter o Derivation of the transfer function of the low-pass filter o Implementation of the low-pass filter using op-amp AD711 o Experimental determination of the low-pass filter using the DSA o Testing of the low-pass filter using xPC Target Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Upload: leliem

Post on 20-Jul-2019

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Lab 1: Equipment Setup and Filtering

AbstractThe main goal of this lab is to become familiar with lab equipment, to configure the xPC Target environment for future experiments, and the design and implement a low-pass filter using operational amplifiers (op-amps) and resistor/capacitor networks.

IntroductionThis laboratory covers the topics of

Introduction to Lab Equipmento Oscilloscopeo Signal Generatoro Power Supplieso Multimetero Kepco Power Amplifiero Dynamic Signal Analyzer (DSA)

Configuration of the xPC Target Environmento Introduction to Simulinko xPC Target Settingso xPC Target Librarieso xPC Target Scopeo Execution of the xPC Target Realtime Controllero Access of the xPC Target data structure in in Matlab for analysis and plotting

Implementation of a second-order, low-pass filter using op-amps and RC networkso Schematics of a second-order, low-pass filtero Derivation of the transfer function of the low-pass filtero Implementation of the low-pass filter using op-amp AD711o Experimental determination of the low-pass filter using the DSAo Testing of the low-pass filter using xPC Target

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 2: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

ContentsAbstract.......................................................................................................................................................1

Introduction.................................................................................................................................................1

Introduction to Lab Equipment...................................................................................................................3

I. Signal Generator..............................................................................................................................3

II. Oscilloscope.....................................................................................................................................3

III. Multimeter...................................................................................................................................4

IV. Power Supplies............................................................................................................................5

V. Kepco Power Amplifier....................................................................................................................6

VI. Dynamic Signal Analyzer (DSA)....................................................................................................8

Configuring the xPC Target Environment....................................................................................................9

I. Introduction to Simulink..................................................................................................................9

II. xPC Target Environment Settings...................................................................................................12

III. Simulink Model Template for Building xPC Target Models........................................................14

IV. xPC Target Function Libraries....................................................................................................19

V. Accessing xPC Target Data in Matlab.............................................................................................24

Second-Order Low-Pass Filtering Using Op-Amps and RC Networks.........................................................25

I. Schematics of a Second-Order Low-Pass Filter..............................................................................25

II. Derivation of the Transfer Function of the Low-Pass Filter............................................................26

III. Implementation of the Low-Pass Filter Using Op-Amp AD711..................................................26

IV. Experimental Determination of the Second-Order Low-Pass Filter Using the DSA....................26

V. Testing of the Second-Order Low-Pass Filter Using xPC Target.....................................................29

VI. Modifying the Second-Order Low-Pass Filter for Audio Filtering...............................................30

Items to Address in Report........................................................................................................................31

Bibliography...............................................................................................................................................32

Appendix A: Configuring Secondary Ethernet for xPC Target Usage.........................................................33

Appendix B: xPC Target Explorer Settings for Older Matlab Versions.......................................................35

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 3: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Introduction to Lab Equipment

In this section, you will familiarize yourself with the functionality and features of some common lab equipment that we will use throughout the quarter.

I. Signal Generator

An Instek GFG-8216A function/signal generator is available in the lab and is shown in Figure 1. This unit can be used to produce specified output waveforms.

Figure 1: The Instek GFG-8216A function/signal generator on top of the GW GPC-3030D power supply.

Perform the following actions using the signal generator.

1. Familiarize yourself with different functions available in the signal generator.2. List the types of signals that the signal generator can provide.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 4: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

II. Oscilloscope

An Aligent 54622D or a Tektronix TDS 210 mixed signal oscilloscope is available in the lab (depending on your lab station). The Aligent oscilloscope is shown in Figure 2. The oscilloscope can be used to measure both steady state and time varying input signals.

Figure 2: The Aligent 54622D mixed signal oscilloscope.

Aligent 54622DPerform the following actions using the oscilloscope and signal generator

1. Verify that the probe settings are appropriate for the set of probes attached to the scopea. Press hard key “1” or “2” (associated with the channel you are setting upb. Press soft key “Probe”c. Use the circular arrow knob to adjust the gain of the probe if needed (ie 10:1 or 1:1)

2. Display and measure a square wave of different frequencies (1 kHz, 5 kHz, 10 kHz, etc.)3. Display and measure a sine wave of different frequencies (1 kHz, 5 kHz, 10 kHz, etc.)4. Explore the “Measure” function and use it to determine the signal frequency and period.5. Save the scope display to a data file.

a. Press “Run/Stop” to pause the scope display.b. Setup the save settings

i. Press hard key “save/recall”ii. Press soft key “formats”

iii. Select “CSV” and ensure that it is saving to disc with appropriate lengthiv. Place floppy disc in scopev. Press hard key “quickprint” to save to disc.

6. Use Matlab to plot the data from the scope.

Tektronix TDS 210

1. Perform similar procedures as described above (except for saving data).

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 5: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

III.Multimeter

A GW GDM-8145 digital multimeter is available in the lab and is shown in Figure 3. The multimeter can be used to measure steady state voltages and currents. It can also measure resistances.

Figure 3: The GW GDM-8145 digital multimeter.

Perform the following actions using the multimeter and power supplies.

1. List the different capabilities available in the multimeter.2. Use the multimeter to measure the voltage from a power supply.3. Use the multimeter to measure the current from a power supply.4. Use the multimeter to measure the resistance of different known resistors. Compare the results

with the known resistor values.

IV. Power Supplies

The GW GPC-3030D will be used as the primary power supply in the lab. This unit was shown previously in the bottom of Figure 1.

Note that this power supply has effectively 3 independent power supplies. Variable voltage/current supply on left. Warning: potentially harmful to other equipment Variable voltage/current supply on right. Warning: potentially harmful to other equipment Fixed 5V 3A output

Warning! Use caution when operating due to potentially high voltages!

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 6: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Warning! Voltage levels output by the power supply can be harmful to other lab equipment, never directly connect variable voltage/current supply to other equipment!

Perform the following actions using the power supplies

1. Familiarize yourself with the two power supplies.2. Use the power supply to generate +15V and -15V supply signals.

a. Place power supply in series mode.b. Use the negative slave as the -15Vc. Use the positive master as the +15Vd. Use the negative master or positive slave as the 0V (you can also add a jumper between

these and the slave or master GND to tie this to ground)3. (OPTIONAL) Observe the problem related to current limiting by adjusting the “current” knob.

a. Turn both current knobs to maximumb. With the power supply in series mode, slowly lower the master knob unit the current

limiter activates.

V. Kepco Power Amplifier

There are two different Kepco Power Amplifiers (depending on which lab station you are at). The large Kepco Power Amplifier is shown in Figure 4. This is used to amplify and input signal by a constant gain. This can either operate in voltage or current gain mode.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 7: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 4: Dynamic Signal Analyzer (DSA) sitting on top of the large Kepco Power Supply

Warning! Output voltages from power supply can be dangerous!

Warning! No not allow input voltages to exceed +/-10 volts as this will damage the equipment!

Perform the following actions using the power supply, Kepco amplifier, and multimeter.

1. Familiarize yourself with the input and output of the Kepco power amplifier.2. Use the Kepco power amplifier to produce an output voltage of 15 V. Warning: Do not allow

input voltages to exceed +/- 10 volts as this will damage the equipment!3. Determine the gain in the Kepco power amplifier. Observe the sign of the gain.4. Observe the output limiting functionality of the amplifier. Set the output limits to +/- 15V.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 8: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

VI. Dynamic Signal Analyzer (DSA)

The Dynamic Signal Analyzer (DSA) is shown in Figure 4. This can be used to simultaneous generate input signals and measure corresponding output signals.

The following is optional for week 1, you will get plenty of experience with the DSA during week 2. Perform the following actions using the DSA.

1. Familiarize yourself with the DSA panel. List the primary function of a DSA.2. Identify the different types of inputs and outputs from the DSA.

In later sections, we will use the DSA to obtain the Bode plot of a Butterworth low-pass filter.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 9: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Configuring the xPC Target Environment

In this section, we will configure the xPC Target environment so that it can be used to read in analog values from sensors and then output analog signals to actuators.

I. Introduction to Simulink

Simulink will be the main simulation environment that we will use to design and test our systems and models. This section is used to familiarize yourself with using Simulink as a standalone simulation package.

1. Open Matlab2. Type “simulink” or click on the colorful Simulink icon to open the Simulink application.3. Explore and familiarize yourself with some of the block available in the Simulink Library Browser

window (Figure 5).4. Open a blank Simulink window from the menu in the Simulink Library Browser window. All

Simulink model files will be saved automatically with the file extension .mdl.5. In the opened “Untitled” Simulink window,

a. Build the Simulink model shown in Figure 6.b. Change the configuration parameters to (note: the below directions are for an older

i. Stop Time: 30 (run for 30 simulated seconds)ii. Type = Variable-Step

iii. Solver = ode23 (see Figure 7).iv. In the option “Data Import/Export”, make sure to de-select the “Save options/

Limit data points to last” box (see Figure 8).6. Save the model as “lab1_standalone_model.mdl”.7. Run the simulation by clicking on the solid right arrow or by selecting “Start” from the

“Simulation” drop-down menu.8. Observe the response of the system via the scope in the model by double clicking on the

“scope” block.9. Write a short Matlab script called “lab1_standalone.m” to run the “lab1_standalone_model”

model, extract the data generated by the Simulink, and create a plot similar to the output of the “scope” block.

10. (OPTIONAL) Repeat relevant sections where the transfer f unction block is replaced with an equivalent state-space model block. Perform the simulation and compare the results with those with the transfer function.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 10: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 5: Simulink Library Browser Window

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 11: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 6: Simulink model to investigate the step response of a second-order transfer function

Figure 7: Solver tab showing modified settings for stop time, type, and solver options.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 12: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 8: Data Import/Export tab showing unchecked “Limit data points to last” box.

II. xPC Target Environment Settings

We can now configure the host PC for xPC Target.

1. Make a note of your lab station using Figure 10 and Table 1.2. Ensure that primary and secondary Ethernet adaptors on the host machine are configured

correctly. This has likely been performed already. If you are having trouble connecting the host and target machine, see Appendix A: Configuring Secondary Ethernet for xPC Target Usage.

3. Start Matlab (this document was tested with R2012a).4. In the Command Window, type “xpcexplr”, press “enter”, and wait for a window to open.5. Set the settings in the xPC Target Explorer window as shown in Figure 9. This configures the

settings for the host PC (mainly configures how to send the complied controller application to the target PC). You can use this screen to make a boot floppy or boot CD if necessary Warning: Most lab stations already have a boot disc created so you most likely do not need to perform this step. xPC Target Settings for older versions of Matlab are documented in Appendix B: xPC Target Explorer Settings for Older Matlab Versions.

6. In the Command Window, type “xpcsetCC('setup')”, press “enter”, and choose a compiler for xPC Target.

7. Place the target boot disc in the target PC and start the machine. Verify that the target PC boots to the xPC Target RTOS.

8. In the command window, type “xpctest”, press “enter”. This runs a test suite to ensure that configuration settings are correct.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 13: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

The xPC Target configuration is now set for your account. Each student needs to repeat this configuration procedure for their account.

When done, you can close the “xPC Target Explorer” window.

Figure 9: xPC Target Explorer settings

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 14: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 10: Lab station numbering

Table 1: Hardware components for xPC Target computers (these are settings for 2013, hardware may be different on current hardware)

Station Ethernet Adaptor A/D and D/A Card

Encoder Card Notes

1(UWAALAB63)

3COM 3C905C-TXM B

PCI-DAS 1602/16

PCI-QUAD04 None

2(UWAALAB62)

3COM 3C905C-TXM PCI-DAS 1602/16

PCI-QUAD04 Analog Out 1 may be faulty.Analog In may be wired incorrectly.

3(UWAALAB61)

3COM 3C905C-TXM PCI-DAS 1602/16

PCI-QUAD04 None

4 (UWAALAB60)

3COM 3C905C-TXM PCI-DAS 1602/16

PCI-QUAD04 Requires boot disc to have Target Driver: THREECOM_3C90X (auto mode does not work)

5(UWAALAB65)

3COM 3C905C-TXNM

PCI-DAS 1602/16

PCI-QUAD04 None

6(UWAALAB64)

3COM 3C905C-TX PCI-DAS 1602/16

PCI-QUAD04 None

III.Simulink Model Template for Building xPC Target Models

We will now create a blank Simulink model template which we can use to build models for future experiments.

1. Open a blank Simulink model.2. In the opened “Untitled” Simulink window, open the Configuration Parameters (Simulation >

Configuration Parameters)a. In the ‘Solver’ Option

i. Stop Time: inf (to set to infinite run time)

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 15: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

ii. Type = Fixed-step (for digital control at a fixed sample time)iii. Solver = ode1 (euler) (for conversion of continuous filters to discrete filters

using the Euler integration technique) (see Figure 11).iv. Fixed-step size (fundamental sample time): T (will need to define this variable

before running system)b. In the ‘Data Import/Export’ option

i. Make sure to de-select the “Limit data points to last” box (see Figure 12).c. In the ‘Code Generation’ option

i. In the option “System Target File”, click “Browse” and select “xpctarget.tlc” as shown in Figure 13..

d. In the ‘xPC Target options’ optioni. Change the ”Signal data logging buffer size in doubles” to “1000000” as shown

in Figure 14.3. The model will not be used for simulation, rather it will be used to compile code and send it to

an external machine (the xPC machine). Change the model type from “Normal” to “External” as shown in Figure 15.

4. The Simulink model is now configured for use with xPC Target. Save the model as “xPC_template.mdl”. This model can now be used as a Simulink model template to build real-time controllers for all control lab experiments in this class.

Figure 11: Setup of the Simulink model template (Solver option).

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 16: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 12: Setup of the Simulink model template for xPC Target (Data Import/Export option).

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 17: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 13: Setup of the Simulink model template for xPC Target (Code Generation option).

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 18: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 14: Setup of the Simulink model for xPC Target (xPC Target options).

Figure 15: Changing model type from “Normal” to “External”.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 19: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

IV. xPC Target Function Libraries

Below are screen captures of some of the libraries available in xPC Target which we will use to program our real-time controllers using Simulink. These blocks are accessed through the Simulink Library Browser as shown in Figure 16.

Figure 16: xPC Target Library in the Simulink Library Browser.

Determine the hardware associated with your lab station from Table 1.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 20: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

1. Open you “xPC_template.mdl” and rename it “xPC_stationX” where X is the station you are working at.

2. Find the appropriate A/D, D/A, and incremental encoder blocks from the xPC Target blockset and drag them into your model (all hardware is manufactured by Measurement Computing).

3. Configure the parameters of your blocks. Appropriate parameters for the various blocks are shown in Figure 17, Figure 18, and Figure 19. Note that some minor changes to these parameters may be required if you are at a station with a broken channel or encoder. Also note that the input coupling may need to be changed to “differential (8 channels)” for some stations.

4. Connect an xPC specific scope (xPC Target > Misc > Scope (xPC)) to the output of the A/D and encoder. You may want to lower the ‘Number of Samples’ option in the scope (this is the number of samples that the scope must collect before refreshing itself in the window)

5. Connect a sin wave with amplitude of 1 and frequency of 2 Hz to channel 1 of the D/A and connect a pulse generator with amplitude of 1 and period of 1 second to channel 2 of the D/A (note: you may have to define the variable T in the workspace in order to change the parameters of the pulse generator block). Your Simulink model should now appear similar to Figure 20.

a) PCI DAS1602/16 (note that input coupling may need to be changed to “single-ended (16 channels)”

b) CIO DAS1602/16

Figure 17: Appropriate parameters for A/D (analog input) blocks (choose one based on station hardware).

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 21: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

a) PCI DAS1602/16 b) CIO DAS1602/16Figure 18: Appropriate parameters for D/A (analog output) blocks (choose one based on station hardware).

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 22: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 19: Appropriate parameters for quadrature encoder block. Alternatively, you may wish to change the ‘Count Speed’ to ‘4x’ model for greater angular resolution.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 23: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 20: Simulink model with hardware blocks (actual blocks may be different depending on your station’s hardware)

We can now test the setup. Before executing your real-time code, the Simulink model you created must be complied to C-code. This is done automatically via the Real-Time Workshop toolbox in Simulink.

1. Type “T = 0.001” into the Matlab command window and press enter.2. Compile your code, using “Tools” > “Code Generation” > “Build Model (Ctrl + B)”. Alternatively,

you can click on the “Build Model Button” as shown in Figure 21.3. Once the model has been complied and successfully downloaded to the xPC Target machine,

you must connect to the target machine by pressing the “Connect to Target” button as shown in Figure 21. Once a connection is successfully established, the “Play” button becomes active.

4. Connect the analog output channels to the oscilloscope and connect the encoder channel to the DC motor on your station.

5. Press the play button and verify that the signals are showing up on your oscilloscope. Also spin the DC motor to verify that the encoder functions. Which of the scopes on the xPC target monitor respond?

6. Stop the model and disconnect the analog outputs (D/A channels) from the oscilloscope and connect them to the analog inputs (A/D channels). Run the model again and verify that the systems functions as expected.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 24: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 21: Building model and connecting to xPC Target machine.

V. Accessing xPC Target Data in Matlab

You can save various signals during real-time execution of the model by adding “Out1” blocks (Simulink > Sinks > Out1) to the appropriate signal. Add these blocks to your model to save data. Data acquired during real-time control of experiments will be saved to a data structure named “tg” at the specified sample time. Sample Matlab code to extract this data is shown in Figure 22. In this example, the model collects 5 signals (two outputs, two inputs, and one channel of encoder data).

Figure 22: Sample Matlab code to extract data from the tg data structure.

1. Collect some data using the previously described setup.2. Plot the data to ensure that it appears reasonable.3. Ensure that the D/A and A/D are not connected together. Execute your code with the sinusoidal

output from the D/A. Notice that the xPC Target Scopes on the target PC may appear to be oscillating as well. Plot the data to show that this behavior is an artifact.

Stop: You have completed the operations for the first week of lab 1.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 25: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Second-Order Low-Pass Filtering Using Op-Amps and RC Networks

We now investigate the analysis and implementation of a second-order low-pass filter using op-amps and RC networks.

I. Schematics of a Second-Order Low-Pass Filter

We will use a low-pass filter to filter noise from our temperature sensor in the Lab 2. This involves constructing the low-pass filter shown in Figure 23.

Figure 23: Wiring diagram for second-order low-pass filter using op-amp AD711

Note on the power supply The Op-Amp AD711 in the Butterworth low-pass filter requires +V s=15V and −V s=−15V .

To establish these two DC power sources from the GPC-M Series Model, the “Tracking” setting must be placed in “Series” with the left switch engaged (in position) and the right switch disengaged (out position). Note that the power supply can be current-limited in this setting. This condition occurs when you see a red light under the label “c.c” and a green light under the label “c.v.”. To resolve this problem, increase the current setting by turning the “current” knob clockwise until the red light goes off and the green light turns back on.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 26: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

II. Derivation of the Transfer Function of the Low-Pass Filter

Figure 23 shows the implementation of a second-order low-pass filter sometimes referred to as a Butterworth filter. With proper selection of the resistances R1 and R2 and capacitances C1 and C2, we can establish the desired corner frequency. The wide bandwidth of the AD711 permits a corner frequency as high as several hundred kilohertz. However, mechanical and thermal systems that we will investigate cannot respond this fast, so in our control experiments, the appropriate corner frequency is usually in the range of 0.1-10 Hz.

We will discuss in class the derivation of a transfer function for op-amps and RC networks.

1. Determine the transfer function of the low-pass Butterworth filter shown in Figure 23.2. For simplicity, we will use R1=R2. Determine appropriate constraints on R1, R2, C1, and C2 so

that the filter has a critical damping ratio and a natural frequency of ωn ,d rad/s. 3. For this experiment, we desired a natural frequency of approximately 2/ π Hz. Assume

resistance in the range of [1kΩ,50kΩ ]. In lab we will use values of R1=R2=10kΩ and C1=44 μF and C2=22μF . Show in the lab write up that these yield an appropriate corner frequency.

4. Provide a bode plot of the theoretical filter derived in the previous step.

III. Implementation of the Low-Pass Filter Using Op-Amp AD711

We can now build a physical implementation of the previously analyzed filter.

1. Use a breadboard and wire the schematics of the previously analyzed filter.2. Verify that that the DC gain of the filter is unity using a DC power supply. Recall that a unity DC

gain implies that at steady state, the output is of equal magnitude of the input. Vary the magnitude of the input voltage and verify that the DC gain is independent of amplitude.

3. Provide a sine wave input in voltage of amplitude 1 V at a constant frequency. Observe the output voltage of the filter. Determine the amplitude and phase of the output signal in relation to the input signal for the following frequencies f= {0.1,1,10 } Hz. Compare these results with theoretical results derived earlier.

IV. Experimental Determination of the Second-Order Low-Pass Filter Using the DSA

We will now use the DSA to obtain a frequency domain representation of the second-order, low-pass filter. We must first connect the DSA to the filter by performing the following steps.

1. Set voltage limits of the Kepco power amplifier to +/-5 volts. Warning: Do not skip this step!

Warning! Ensure voltage limits are set before proceeding further!

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 27: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

2. Connect the Source of the DSA to the Programmable Input ports of the Kepco power amplifier and also to Channel 1 of the DSA.

3. Connect the output ports of the Kepco amplifier to V ¿ of the Butterworth low-pass filter.4. Connect the output V out of the Butterworth low-pass filter to Channel 2 of the DSA.

The DSA can be used to generate a bode plot of the system using two methods,

Sine-Sweep: The DSA will generate sine waves at different frequencies to be used as input sources and analyze the resulting output waveform.

Random Noise: The DSA will use random noise as an excitation and collect sets of data depending on the number of averages you define in DSA. The DSA will collect multiple sets of data for Fast Fourier Transform (FFT) analysis.

Obtain experimentally determined bode plots of system by performing the following steps

1. Obtain an experimentally determined bode plot of the filter using the sine-sweep method. This can be done by using the DSA settings shown in Table 2.

2. Save the resulting bode plot to a floppy disk using the “Save/Recall” command in the “System” section of the control panel, then press the soft keys “Save Data”, “Save TRACE”, “into file”, enter the appropriate file name (limited to 7 characters) using the keyboard and press “Enter”.

3. The data saved must be converted to a Matlab file format (.mat ) using the DSA/MATLAB DOS program “sdftoml.exe”. Go to the website and down load this application to the same directory as the DSA file.

4. Convert the binary data from the DSA to a Matlab file. Open Matlab, change your working directory to the location of the data and sdftoml.exe application and enter the following command

!sdftoml filename.dat /x /b

A file named “filename.mat” will be saved under the same directory. Ensure that the filename of the .dat file is not too long and does not contain special characters (if you cannot convert the file, try shortening the filename). Note that the data variables are frequency (rad/s) (real data array) and frequency responses of the transfer G ( jω ) (complex data array). Create arrays of magnitude and phase of G ( jω ).

5. Repeat these steps using random-noise excitation mode. This can be done by using the DSA settings shown in Table 3.

6. Compare these experimentally determined bode plots to the theoretical bode plots derived in the “Derivation of the Transfer Function of the Low-Pass Filter” section.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 28: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Table 2: Settings to use to setup the DSA for sine-sweep mode

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 29: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Table 3: Settings to use to setup the DSA for random noise mode

V. Testing of the Second-Order Low-Pass Filter Using xPC Target

We can now obtain an experimentally determined step response of the filter using xPC Target.

1. Verify that the voltage limits on the Kepco power amplifier are +/-5 volts. Warning: Do not skip this step!

Warning! Ensure voltage limits are set before proceeding further!

2. Connect the output of the data acquisition board D/A Channel 1 (If Channel 1 is broken, then use Channel 2) to the programmable input of the Kepco power amplifier.

3. Connect the output of the Kepco amplifier to V ¿ of the Butterworth low-pass filter.4. Connect the output V out of the Butterworth low-pass filter to the input of the data acquisition

board A/D Channel 1 (If Channel 1 is broken, use Channel 2).5. Use your Simulink template model. Configure the model to have a sample time T = 0.001 sec.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 30: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

6. Connect a step input of magnitude 0.5 volts to the input of the D/A block. Also define an output (sink) to record the step input.

7. Create an xPC Scope to show the output of the A/D block (xPC Target > Misc. > Scope (xPC)). Also define an output (sink) to record the output of the A/D block (the output of the filter).

8. Click “Connect to Target” and click “Run”. Let the real-time data acquisition run for approximately 15 sec. Verify that the Kepco amplifier is not saturating.

9. Save and plot results of the run in Matlab command window. Compare the experimental results with theoretical step responses of the low-pass filter derived previously.

10. Try various frequencies of sin wave inputs with varying amplitudes (0.1 volts, 1 volt, etc.). Ensure that the Kepco voltage limits are in place. Does the filter behave in a non-linear fashion for certain test conditions?

Figure 24: Example Simulink model used to output a step in voltage to channel 1 D/A and then measure the response on channel 1 of the A/D.

Some notes about the xPC Target system

1. Try not to leave unconnected inputs/outputs from the D/A or A/D system (connect with terminators). This can lead to unwanted noise in signals.

2. There may appear to be cross talk between channels in the A/D. Once again, use terminator or other connections to ameliorate this problem.

VI. Modifying the Second-Order Low-Pass Filter for Audio Filtering

We would now like to modify the filter to work in the frequency range of audio signals. Humans can hear frequencies in the range of 20Hz to 20 kHz.

1. Modify your filter so that the cutoff frequency is approximately 50 Hz (Hint: The easiest way to do this is to change the resistors)

2. Connect an expendable audio source such as a cheap CD player, radio etc. to the filter (connect the tip or ring from the audio source to the input of the filter as shown in Figure 25).

3. Connect the filter output to the input of a set of powered speakers (connect the output of the filter to either the tip or ring of the speaker connectors as shown in Figure 25).

4. Simultaneously monitor the input and output of the filter on the oscilloscope.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 31: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

5. Play various songs through the filter and listen to how they sound. What does the filter do to the audio signal?

6. Provide a trace of the unfiltered and filtered signal from the oscilloscope.7. Suppose you wanted to capture the unfiltered and filtered signal on channels 1 and 2 of the xPC

A/D. Do you anticipate problems with this? Provide a very brief discussion; there is no need to collect actual data.

8. I am thinking of purchasing a Behringer Eurolive B1500D-Pro. How might this circuit be used in this product?

Figure 25: Using low pass filter in an audio application.

Items to Address in Report

An incomplete list of items to address in your lab write up include

Answers to questions posed during the lab session and in the lab sheet. A schematic of data acquisition hardware (host/development PC, target PC, D/A, A/D, encoders,

etc.) Be sure to label and describe the function of each component. Screenshot s of relevant Simulink models and settings. Wiring and connect diagrams of relevant circuits and components. Derivation of necessary equations and parameters (ie resistance and capacitances of 2nd order

filter). Discussion and comparison between lab data and simulation results for relevant or interesting

sections.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 32: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Bibliography

[AD711] AD711 specification sheet.[SDFTOML]

SDFTOML user manual and syntax

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 33: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Appendix A: Configuring Secondary Ethernet for xPC Target Usage

The host machine has two Ethernet adapters. The primary Ethernet adaptor is used to connect to the outside world and the UWAA network. The secondary Ethernet adaptor is used to exclusively communicate with the target PC. The secondary Ethernet adaptor may need to be modified so that packets are routed correctly from the host machine to the target machine.

1. Within Windows, go to Control Panel > Network and Sharing Center > Change Adaptor Settings. Hopefully the adaptors have been setup and appear as shown in Figure 26.

2. Ensure that the primary Ethernet adaptor (Broadcom NetLink Gigabit Eithernet) does not have an IP address starting with 192.xxx.xxx.xxx.

3. Ensure that the secondary Ethernet adaptor (Realtek PCI GBE Family Controller) has a static IP address of 192.168.0.x (as long as x is not equal to 1 because that is the IP address of the target machine).

a. If IP address is not of the proper form, change it to this form (you may need administrator access to modify the IP address of the adaptor, see Brian Leverson or Josh Bean).

4. Verify that both adaptors are set correctly by running an ‘ipconfig’ command from the command line. A correctly configured output is shown in Figure 27.

Figure 26: Network connection settings for primary and secondary Ethernet adaptors.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 34: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 27: Correctly configured IP settings for Ethernet adaptors.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 35: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Appendix B: xPC Target Explorer Settings for Older Matlab Versions

Figure 28: xPC Target environment setup window (xpcexplr main window).

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 36: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 29: xPC Target environment setup window (xpcexplr complier configuration).

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 37: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 30: xPC Target environment setup window (for Target Driver NE2000).

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 38: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 31: xPC Target environment setup window (for Target Driver I82559).

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013

Page 39: Abstract - UW Faculty Web Serverfaculty.washington.edu/lum/TEMP/aa448/lab_1_equipment... · Web viewPower Supplies Multimeter Kepco Power Amplifier Dynamic Signal Analyzer (DSA) Configuration

Figure 32: xPC Target environment setup window for creating a boot floppy or boot CD.

Christopher Lum AA448 – Control Systems Sensors and Actuators Winter 2013