\[ \begin{align}\begin{aligned}\newcommand\blank{~\underline{\hspace{1.2cm}}~} \newcommand\phase[1]{\enclose{phasorangle}{#1}} \newcommand\RE{\mathrm{Re}} \newcommand\IM{\mathrm{Im}}\\% Bold symbols (vectors) \newcommand\bs[1]{\mathbf{#1}}\\% Poor man's siunitx \newcommand\unit[1]{\mathrm{#1}} \newcommand\num[1]{#1} \newcommand\qty[2]{#1~\unit{#2}}\\\newcommand\per{/} \newcommand\squared{{}^2} % % Scale \newcommand\milli{\unit{m}} \newcommand\kilo{\unit{k}} \newcommand\mega{\unit{M}} % % Angle \newcommand\radian{\unit{rad}} \newcommand\degree{\unit{\kern{-0.5ex}{}^\circ}} % % Time \newcommand\second{\unit{s}} % % Distance \newcommand\meter{\unit{m}} \newcommand\m{\meter} \newcommand\inch{\unit{in}} % % Mass \newcommand\gram{\unit{g}} \newcommand\g{\gram} % % Frequency \newcommand\hertz{\unit{Hz}} \newcommand\rpm{\unit{rpm}} % % Voltage \newcommand\volt{\unit{V}} \newcommand\V{\volt} \newcommand\millivolt{\milli\volt} \newcommand\mV{\milli\volt} \newcommand\kilovolt{\kilo\volt} \newcommand\kV{\kilo\volt} % % Current \newcommand\ampere{\unit{A}} \newcommand\A{\ampere} \newcommand\milliampereA{\milli\ampere} \newcommand\mA{\milli\ampere} \newcommand\kiloampereA{\kilo\ampere} \newcommand\kA{\kilo\ampere} % % Resistance \newcommand\ohm{\Omega} \newcommand\milliohm{\milli\ohm} \newcommand\kiloohm{\kilo\ohm} % correct SI spelling \newcommand\kilohm{\kilo\ohm} % "American" spelling used in siunitx \newcommand\megaohm{\mega\ohm} % correct SI spelling \newcommand\megohm{\mega\ohm} % "American" spelling used in siunitx % % Inductance \newcommand\henry{\unit{H}} \newcommand\H{\henry} \newcommand\millihenry{\milli\henry} \newcommand\mH{\milli\henry} % % Power \newcommand\watt{\unit{W}} \newcommand\W{\watt} \newcommand\milliwatt{\milli\watt} \newcommand\mW{\milli\watt} \newcommand\kilowatt{\kilo\watt} \newcommand\kW{\kilo\watt} % % Torque \newcommand\ozin{\unit{oz}\text{-}\unit{in}} \newcommand\newtonmeter{\unit{N\text{-}m}}\end{aligned}\end{align} \]

1. Introduction to Lab Experiments#

Objective

The purpose of this lab session is to introduce the laboratory equipment and procedures that will be used to characterize the electromechanical devices studied in ECE 321. The main objectives are to:

  • Introduce the host and target computers, MATLAB/Simulink™ Real Time Workshop® (RTW), and the patch panel.

  • Practice acquiring, storing, and downloading waveforms using the digital oscilloscope.

  • Show how to load data files into MATLAB. Learn MATLAB commands to process the data.

  • Learn how to print oscilloscope and MATLAB graphs.

  • Build and run standalone Simulink models.

1.1. Introduction#

The primary focus of this lab course is to reinforce experimentally the basic principles of electromechanical energy conversion taught in ECE321 and to study the performance of different types of electromechanical devices (solenoids, motors and generators). To facilitate this learning process, the ECE323 lab has been furnished with equipment that is intended to simplify the data gathering and processing aspects of the lab. The computers used in this lab consist of a target computer (target) equipped with digital-to-analog (D/A) and analog-to-digital (A/D) converters, and a host computer (host), which is a conventional desktop PC running Windows 7 operating system and equipped with MATLAB/Simulink. This host/target computer combination serves as a signal generator, data acquisition system, signal analyzer, and print server. In this lab, we will use the computer to run a variety of packaged utilities and custom-written software.

The workstation “patch panel” is shown in Fig. 1.1 and has a variety of functions. The panel includes:

  1. Four Analog \(+/-\) Inputs.

  2. A 25-pin Digital Input port (For use with a position encoder).

  3. A 9-pin Digital Input port (For use with the Hall Effect sensors on the PM Machines).

  4. A 15-pin Digital Output port.

  5. Three high-power analog outputs, each with two BNC connectors for voltage and current measurements. The upper BNC connector is used to measure voltage and the lower connector outputs 2 Volts per Amp flowing through the banana plugs.

  6. Three high-power analog outputs, each with two BNC connectors for voltage and current measurements. The upper BNC connector is used to measure voltage and the lower connector outputs 2 Volts per Amp flowing through the banana plugs.

The patch panel is interfaced to the target computer using a 6-channel D/A board and a 16-channel A/D board plugged into the computer’s backplane. The digital oscilloscope has the ability to capture and store up to 4 channels of data. The oscilloscope is connected to the host computer through a universal serial bus (USB) connection.

_images/fig1n.png

Fig. 1.1 Patch panel.#

In addition to the standard oscilloscope probes, this lab has been equipped with an analog torque transducer and two hall-effect current probes. The current transducers are used by simply clamping the current probe onto the wire to be monitored and connecting the Tektronix TCPA300 current amplifier output to the oscilloscope or patch panel. The torque transducer is equipped with a digital readout, but also has an analog output in the back that can be connected to the oscilloscope or patch panel.

In this course, we will use the host computer to build Simulink models and the target computer D/A outputs to generate signals to drive motors and solenoids. We will then use probes, transducers, A/D inputs, and the oscilloscope to capture and display arrays of data that are useful for characterizing the electromechanical device under study. Data captured on the oscilloscope can be downloaded to the host computer through its USB connection. The data can be displayed on the computer screen, processed using the math utilities included with MATLAB, printed on the network printer, and stored on your network account for future reference.

This first lab exercise has been prepared to familiarize you with the equipment (computers, oscilloscope, transducers, patch panel, printer, power supply), the computer programs, and the basic procedures that you will be using in future labs.

1.2. In the Laboratory#

Equipment

  • Computers: Host PC (Windows 7), and Target PC (Speedgoat RealTime Target)

  • Oscilloscope: Keysight MSOX3014T 100-Mhz Digital Storage Oscilloscope

  • Printer: Network HP printer

  • Current Transducer: Tektronix TCPA300 Current Probe Amplifier

  • Torque Transducer: Himmelstein MCRT transducer with 700-series Amplifier

1.2.1. Preliminary Setup (performed once at beginning of semester)#

  1. From Brightspace, click the icon labelled Lab Files. This will download a folder labelled ECE323_Lab_Files into the downloads folder of your computer. Extract (unzip) and move this folder into C:\Users\Your Name. This folder becomes part of your ecn PC roaming profile. Navigate to the Lab1 folder in this directory. Double click the ee323lib.slx icon in the Lab1 folder to start MATLAB in the given folder (directory).

  2. In the MATLAB command window, type slrtExplorer (Fig. 1.2). After a brief (sometimes long) delay, this will open an slrtExplorer window similar to that shown in Fig. 1.3.

    _images/MatlabWindow.png

    Fig. 1.2 MATLAB top-level window.#

    _images/SLRTExplorer2.png

    Fig. 1.3 slrtExplorer window.#

    Referring to Fig. 1.3, click on add-target icon. This will create a link to a new target. Enter the name of your lab station and the IP address of the target computer in your station. Click on the Change IP Address icon. MATLAB will attempt to communicate with the target and notify you if successful. If not, see TA or instructor. Finally, click on the connect-to-target icon (Fig. 1.3), which initially displays Disconnected. The display should then change to Connected.

1.2.2. Building Target Model#

  1. The Simulink model required to execute this experiment will consist of blocks from both the Simulink Library Browser and the ee323lib.slx file. Bring to focus the Simulink ECE323lib window (Fig. 1.4). Open the standard Simulink library by clicking the Library Browser button near the top of the window. In top left corner, select New ‣ Blank Model. This will open a blank Simulink window. Save the model window as lab1.slx.

    _images/ECE323lib.png

    Fig. 1.4 Simulink EE323 library.#

  2. Construction of the Simulink model begins by copying (Ctrl-C Ctrl-V) or dragging blocks from the standard Simulink library or ECE323lib to the lab1 model window. Blocks can be moved within the model by pressing left mouse button when the cursor hovers above the desired block and dragging to the desired location. In addition, when the block handles are active, they can be used to alter the size of the block. Multiple uses of the same block will result in automatic incremental labeling of the blocks. To connect the blocks, click on an arrow of one block, hold button, and drag the mouse to the termination point. Use the model blocks from the Simulink Library Browser and the ee323lib.slx file to construct the waveform generator model shown in Fig. 1.5.

    _images/lab1.png

    Fig. 1.5 Simulink project window for Lab 1.#

  3. In the model window, double-click on the appropriate source block and use the mouse and keyboard to set up the following 50-Hz waveforms on the D/A outputs:

    Note

    Some block parameters are in radians.

    Table 1.1 Target model parameters#

    D/A

    Wave Type

    Amplitude

    DC level

    Phase Shift

    Oscope

    Scale

    Ch 1

    Sine

    \(\qty{5}{\V}\)

    \(\qty{0}{\V}\)

    \(\qty{0}{\degree}\)

    Ch 1

    \(\qty{5}{\V\per div}\)

    Ch 2

    Sine

    \(\qty{5}{\V}\)

    \(\qty{5}{\V}\)

    \(\qty{-90}{\degree}\)

    Ch 2

    \(\qty{5}{\V\per div}\)

    Ch 3

    Square

    \(\qty{5}{\V}\)

    \(\qty{0}{\V}\)

    \(\qty{0}{\degree}\)

    Ch 3

    \(\qty{5}{\V\per div}\)

  4. Simulink Real-Time (slrt) is included in the Simulink software. This software provides the link between the model code and the test hardware. When a model is initially created, default parameters define the simulation environment. Bring to focus the lab1.slx window. Select the Modeling tab. Then press Model Settings button. In the left column of newly created window, select Solver. The window should now appear similar to Fig. 1.6. Change all settings to match Fig. 1.6.

    _images/ConfigParam.png

    Fig. 1.6 Solver parameters for Lab 1.#

    Next, select Code Generation in left column of same window, which should now be similar to Fig. 1.7. Select System target file to match that in Fig. 1.7. Close given window. Bring back to focus the lab1.slx window, which should now have a tab called Real Time. Select this tab. Near top-left corner, select the target PC and press Disconnect link to connect. If everything was successful, the top-left link should now display Connected. If so, press Run on Target button.

    _images/CodeGen.png

    Fig. 1.7 Code generation parameters for Lab 1.#

    Simulink will now generate and compile code to run on target PC. This may take a minute or two. If successful, the code will automatically download to and start target model. Confirm by looking at the target display.

  5. Connect amplifier Channels 1, 2 and 3 to oscilloscope Channels 1, 2 and 3, respectively. Trigger on Channel 1. Adjust the time base to capture 2 cycles of data. Display all scope channels.

  6. Apply the D/A Channel 3 voltage to a 25-\(\Omega\) resistor. Measure the current by connecting the lower BNC connector to oscilloscope Channel 4.

  7. To download the oscilloscope data, open BenchVue on the host computer. Exit the demo screen and select the proper oscilloscope. You should see an image of the oscilloscope screen on the host computer. On the screen image tab check the boxes that invert colors (so as not to waste ink or toner when printing), black and white and click get current screen. You should see an image similar to Fig. 1.8. To save your screenshot, select Export in the lower right corner of the BenchVue window. Hit browse, and navigate to your ECE323 folder. Select the lab1 folder and hit OK. This will ensure that BenchVue saves your screenshot in the correct location on your account.

    _images/scope.png

    Fig. 1.8 Sample screen shot.#

  8. Next, on the trace data tab, select get current traces. Export the data into MATLAB. When saving the file, make sure the filename you select (e.g. lab1\data) does not include any spaces. Also, uncheck the check-box include number. This will avoid compatibility issues with MATLAB.

  9. Exit or close BenchVue. The waveform data will be stored in a file named lab1\data.mat. The data file contains an \(N \times 2\) matrix of data for each channel of the oscilloscope screen. The first column of each matrix contains the time data. The second column contains the y-axis data of the signal. Some commonly used MATLAB commands are listed at the end of this handout. For more detailed information on using any of these commands, type help command in the MATLAB command window.

  10. Create and execute an m-file containing the following commands that load four channels of oscilloscope data into MATLAB workspace:

    load lab1_data.mat
    time = Trace_1(:,1);
    channel1 = Trace_1(:,2);
    channel2 = Trace_2(:,2);
    channel3 = Trace_3(:,2);
    channel4 = Trace_4(:,2);
    

    Plot the four channels of data on the computer screen using the MATLAB commands plot and subplot. Add a title, labels, and grid. Make a hard copy printout of the plot.

  11. For each channel, compute the average and RMS values of the signals. This can be accomplished by creating MATLAB programs. Using the m-file editor, write the following MATLAB commands and save in file avg.m.

    avsum = 0.0;
    for i = 1: length(channel1)
        avsum = avsum + channel1(i);
    end
    av = avsum/length(channel1);
    

    When in the MATLAB command window, type avg. The average value of the Channel 1 data will be computed. Repeat this for Channels 2, 3, and 4. Create a MATLAB program to compute the RMS value of each channel. Do NOT use the built-in MATLAB rms command. The RMS value of a continuous signal is defined as

    (1.1)#\[\hat x = \sqrt {\frac{1}{T}\int_0^T {{x^2}(t)dt} }.\]

    The discrete counterpart is

    (1.2)#\[\hat x = \sqrt{\frac{1}{N}\sum_{n = 0}^N {{x^2}(n)} } %\hat x = \sqrt{\frac{1}{N}\sum\nolimits_{n = 0}^N {{x^2}(n)} }\]

    where \(N\) is the number of samples in an integer number of periods of the signal. For those who would like to learn more about MATLAB, there are numerous MATLAB reference books available at local bookstores. Also, there is extensive online help - simply type help from the MATLAB command line. Write the results of the calculations on the printouts of the generated plots. Do the results look reasonable?

  12. Staple and turn in all printouts with you name on top of all pages.

1.4. Postlab#

  1. Using phasor analysis, calculate \(\tilde{I}_1\) and \(\tilde{I}_2^\prime\). Express \(I_1(t)\) and \(I_2^\prime(t)\). What are their peak values? Compare the calculated results with the simulated values established in lab.

  2. Submit printouts of the generated plots and all supporting calculations. If you used MATLAB to perform calculations, submit the script file or command history.

1.5. MATLAB Command Reference#

Command

Description

load file

Load data stored in file

save array file

Store a variable array into file.mat

fft(array)

returns a complex array of fft harmonic components

^2, sqrt()

square/square root of a variable

sign, abs(array)

sign/absolute value of a variable/array

sin, cos, tan

sine/cosine/tangent of angle (in radians)

asin, acos, atan

arcsin, arccosine, arctangent

sinh, cosh, tanh

hyperbolic sine, hyperbolic cosine, hyperbolic tangent

length(array)

number of elements in an array

min, max, mean

minimum, maximum, and mean of an array

plot(x,y,x,y..)

create a screen plot of the arrays y vs x. Also used as plot(y)

title('myplot')

Add a title to a screen plot

xlabel('horiz')

Add an x axis label to a screen plot

ylabel('vert')

Add a y axis label to a screen plot

grid

Add grid lines to a screen plot

print

Dump the screen plot to the printer

whos

List current variables and sizes in memory

clear array

remove a variable/array from memory

...

ellipsis for continuation of long lines

Other Misc.

! syscommand

Execute a system command

dir or ls

list DOS files in current directory

help ?

List MATLAB commands and script (.m) files

quit or exit

end MATLAB program

linspace(x1,x2,N)

generates N points between x1 and x2

hold on

subsequent plot commands add to existing plot

subplot

create a “vector” or “matrix” of plots

figure

open a new figure window for plotting