# Lab 2: Introduction II - Multisim and MATLAB

## 1. Objectives

By the end of this laboratory session, students will be able to:

- Simulate circuits in Multisim
- Perform a DC Sweep on circuits in Multisim
- Use MATLAB to solve linear equations

## 2. Background

Multisim is a software package used to simulate circuits. Use the graphical user interface to draw a circuit of interest and select the appropriate parameters. Multisim can perform DC and AC (transient) analysis, among others.

The Matrix Laboratory (MATLAB) is used to manipulate matrices and is also a powerful tool that can be used for many applications in engineering. In this course it will be used to perform matrix calculations and to plot data.

## 3. Laboratory Equipment

- Multisim software
- MATLAB software

## 4. Procedure

### 4.1. Multisim

- Enter your Unity ID and Password on the PCs in EB3 room 4118.
- Launch Multisim From the Windows Menu (lower left corner) using the following path:
`WINDOWS`

→`ALL APPS`

→`NI Multisim 14.0`

- Follow the instructions in section 2-7.1 of the “Introducing Multisim” handout.
- Capture a screenshot of your circuit.

### 4.2. Solving the Circuit

Multisim can simulate circuits using two separate approaches: interactive simulation and analyses. An interactive solution mimics the lab experience: you place probes on the virtual circuit and the simulation produces readings. The analysis approach solves for numerical values throughout the circuit and displays tables or graphs of the results.

#### 4.2.1. Interactive Analysis

- Follow the instructions in section 2-7.2 in the “Introducing Multisim” handout.
- Record \(V\) and \(I\) values for both probes.
- Reverse the direction of
`Probe 2`

. Record the new`Probe 2`

current and voltage values.

#### 4.2.2. DC Operating Point Analysis

A DC operating point analysis is a numerical simulation of the circuit at one specific DC voltage. This simulation is often used to calculate current and voltage values in a DC circuit.

- Follow the instructions under DC Operating Point Analysis in section 2-7.2 of your “Introducing Multisim” handout. Make sure that
`Probe 2`

is back to its original direction. - Change the top resistor value to 137 \(\Omega\) and the bottom resistor to 828 \(\Omega\). Double-click on the resistors to make the change.
- Run another DC operating point analysis and record
`V(Probe2)`

and the current,`I(V1)`

value.

#### 4.2.3. What’s going on behind the scenes?

Multisim takes the circuit you draw and converts it into a text file called the “netlist”. The netlist contains an ASCII representation of all the elements in your circuit and is the input file that Multisim uses to simulate your circuit. To get the text representation of your circuit, follow these steps:

- Go to
`Tools`

→`SPICE netlist viewer`

→`Copy SPICE netlist`

- Open
`Windows Notepad`

by going to`WINDOWS`

then search for`Notepad`

and double click on the search result. - Right click and then
`Paste`

. - The text you see is the ASCII representation of your circuit.
- Take a moment to try and interpret what each line means.
- Capture a screenshot of your netlist.

### 4.3. MATLAB

In the example below, MATLAB will be used to solve for three unknown currents.

Use KVL to write three mesh loop equations for the circuit below. Remember:

- \(\Delta V=IR\)
- KVL: The algebraic sum of all voltages in a closed loop equals zero \(\left(\sum V=0\right)\).
- Current through a resistor results in a voltage drop, in the direction of the current flow.

**Loop 1:**

$$(i_1R_1) + (i_1R_3) – (i_3R_3)+ V_1 = 0$$
$$(i_1220) + (i_11000) – (i_31000) + 9 = 0$$

**Loop 2:**

$$-V_1 + (i_2R_4) – (i_3R_4) + (i_2R_2) = 0$$
$$-9 + (i_2100) – (i_3100) + (i_2220) =0$$

**Loop 3:**

$$(i_3R_3) – (i_1R_3) + (i_3R_5) + (i_3R_4) – (i_2R_4)=0$$
$$(i_31000) – (i_11000) + (i_3220) + (i_3100) – (i_2100) = 0$$

- If you are already logged in, go to step 2. Otherwise, enter your Unity ID and Password.
- Start MATLAB by going to
`WINDOWS`

→`ALL APPS`

→`MATLAB R2016a`

. Click on the icon in the upper left to open a new M file editor window, as shown below.

In the M-file

`EDITOR`

window , Enter the and solve the three equations using the`SOLVE`

function, as shown below. Take a screenshot of the script (see example below); include your name(s) in the comments.Run the M-file in the editor window by going to

`DEBUG`

the`RUN`

(the keyboard shortcut is`F5`

).Record your answers for the three currents.

Construct the circuit in Multisim. Use Multisim to determine the voltage at node \(V_x\) in reference to the ground node. Record \(V_x\). Take a screenshot of the circuit.

## 5. Results

When you draw circuit in Multisim, the program translates that drawing into a text file containing one line per element. In words, what does the text in the line below mean?

`rR1 0 4 1M`

Record the calculated V(2) and current values from Section 4.2.1. What changes when you reverse the direction of probe 2?

Record the calculated V(2) and current values from Section 4.2.2.

Attach a printout of your screenshot from Section 4.1 and Section 4.2. Label and title your screenshots (e.g. “Figure 1: Schematic 1, lab#2” , “Figure 2: Multisim DC-Sweep Voltage Plot”)

Record the calculated currents \(i_1\), \(i_2\), and \(i_3\) from Section 4.3.

Using the calculated values for currents \(i_1\), \(i_2\), and \(i_3\), calculate the voltage at the node labeled \(V_x\) in reference to the ground node.

Record the value for \(V_x\) from step #7 in Section 4.3.

Calculate the percentage error between the calculated and simulated values for \(V_x\). How large is the error? What are sources for the error(s)?

Attach a printout of your screenshots from Section 4.3. This should include a shot of the MATLAB calculation & one of the Multisim Simulation. Label and title your screenshots appropriately.