B2 Tutorial1

From Emagtech Wiki
Jump to: navigation, search

Tutorial Lesson 1: A Simple Analog Voltage Divider Circuit

In this tutorial, you will build a linear circuit consisting of a voltage source and two resistors. The purpose of this tutorial is to help you become comfortable with the B2.Spice A/D Workshop, which includes the Schematic Editor (for drawing circuits). A picture of the finished circuit for this tutorial is shown below:

B2TUT1 1.png

Opening the B2.Spice A/D Program

After installing B2.Spice A/D 2014, double click on the "B2Spice" icon on your desktop to start the application. Or go to the Windows START menu and navigate to the B2.Spice A/D menu and run the application from there. This will bring up a clean circuit window. The cursor will be in the form of the selection arrow. If the cursor is in the form of an hourglass, then the program is busy.


Placing the Parts

There are many different ways in B2.Spice A/D to place a part in your circuit. All these methods do the same job. So it is simply a matter of personal preference which method to choose. Generic parts can be accesses from the Parts Menu. You can also click on the Add Part Toolbox on the left side panel and browse the parts database alphabetically or using other criteria or filters such as a part's function or manufacturer.

Attention icon.png Most generic parts in B2.Spice A/D have intuitive Keyboard Shortcuts. You can easily place them in your circuit by simply typing their shortcut on your keyboard. All Keyboard Shortcuts are case-insensitive.

Once you select your part, the mouse cursor changes to a ghost of your selected part. Move the mouse to a location in the main window where you want to place your part and left-click to drop it. After placing the part, it remains selected. This allows you to duplicate or rotate the device immediately after placing it.

In many cases, you may prefer to rotate a part or flip it vertically or horizontally. While the part is selected, use the keyboard shortcuts "Ctrl+R" or "Ctrl+Alt+R" to rotate it clockwise or counterclockwise, respectively. Or use the keyboard shortcuts "Ctrl+F" or "Ctrl+Alt+F" to flip it horizontally or vertically, respectively. You can also do the same operations using the program menus or contextual menus, which can be accessed by right-clicking on the selected part.

Attention icon.png As soon as you place a new part, you can click the right mouse button to rotate the part sequentially as many times as you like.

You can easily copy, paste cut or delete an part in your circuits. First, select the part and then select the corresponding items from the Edit Menu or the contextual menu. Alternatively, you may use the standard Windows keyboard shortcuts "Ctrl+C", "Ctrl+V" and "Ctrl+X" for copying, pasting and cutting and the "Del" (Delete) Key for deleting a selected part.

Attention icon.png Using the keyboard's "Space" bar duplicates the last placed part.

For example, the keyboard shortcut for a voltage source is "V" and the shortcut for a resistor is "R". First, type "v" on your keyboard and drag the ghost of the horizontal voltage source on your screen. Then, immediately click the right mouse button to rotate the voltage source by 90 degrees and finally click the left mouse button to drop the vertical voltage source at its destination. Next, type "r" on your keyboard and drag the ghost of the horizontal resistor to the right of the voltage source and drop it. Press the keyboard's space bar to duplicate the resistor. While dragging the ghost of the new horizontal resistor to the right, click the right mouse button to make it vertical. At this stage, you should have three parts like the figure below:

B2TUT1 2.png

Drawing the Wires

There are several ways to connect parts by wires. The formal way of doing that is using the Wire Tool. Click the Wire Mode B2Wire Tool.png button of the Schematic Toolbar or select the Wire Mode item of the Edit Menu, or simply use the keyboard shortcut "Ctrl+W" to enter B2.Spice's Wire Mode. The mouse cursor turns into a cross shape. You can draw a multi-segment wire between any two points anywhere in your circuit. Each left mouse click will start a new segment. You can end a wire segment by clicking the right mouse button or double-clicking the left mouse button. Of course, to connect two parts, you should draw a wire between two pins of the two parts. Once you are done with wiring, you must return to the normal Select Mode. This is done by clicking the SelectMode B2Select Tool.png button of the Schematic Toolbar or by selecting the Select Mode item of the Edit Menu, or by simply pressing the keyboard's "Esc" (Escape) Key.

By default, B2.Spice restricts the wire segments to perpendicular lines. To be able to draw arbitrary oblique wires, you need to deselect the button labeled "Restrict Wire Drawing to Perpendicular Lines" B2Perpend Tool.png on the Schematic Toolbar.

Attention icon.png B2.Spice A/D also offers a much easier way of wiring parts without changing the drawing mode. If you click on a pin of an unselected part and start dragging the mouse, a wire comes out of that pin, stretches as long as you drag the mouse and ends wherever you drop the mouse. In this way, you can draw a wire between any two part pins and connect them.

Using one of the methods described above, connect your voltage source and two resistors. Once you are done with the wires, notice that at the points where the wires intersect the terminals of devices, there is a bold point where a connector is automatically inserted.

Attention icon.png All B2.Spice circuits require a ground. You can insert a ground using the keyboard's "Ins" (Insert) Key or by simply typing "0" on your keyboard.
B2TUT1 3.png

Insert a ground at the bottom of your circuit on the wire the connects the bottom pins of your voltage source and vertical resistor.

Sometimes you may have to clean up your circuit a bit to look better. Make sure you are in the Select Mode. You can select any part and move it around. You can also move any wire segment or wire vertex. You can simply "grab" objects and move them to a new location. All wires are rubber banded when you move objects around. Most parts have a label and a parameter value. For example, your voltage source has a label V1 and value of 1 (Volt). Your resistors have labels R1 and R2 and identical values 1K (Kilo-Ohms). You can similarly grab the part labels or part values and place them at a proper distance to avoid congestion.

Attention icon.png While you are in a specific drawing mode like Wire Mode, you can switch to the Select Mode temporarily by holding down the keyboard's "Shift+Ctrl" keys.

Setting the Component Properties

Every device in B2.Spice A/D has a label or name and a number of parameters. Almost all parts have default parameter values when they are first created and placed in your circuit. You can change either the label or the parameter values at any time. The parameter values can be modified and set permanently or they can be varied temporarily during a sweep analysis. To change the label or parameter values of a part, double-click on it to open its Property Dialog. Double-click the voltage source symbol in your circuit to open its property dialog as shown in the figure below. Change the DC voltage of the source to 5 Volts in the box labeled "Value". At this time, you will leave all the other parameters at their default choices. Next, double-click the vertical resistor to open its property dialog as shown in the figure below. Change its resistance to 2K. You will keep the horizontal resistor at its default resistance value of 1K.

B2TUT1 4.png

Running a Live Simulation

B2.Spice A/D has two distinct simulation modes. The first mode is call "Live Simulation" and it runs indefinitely until you stop or pause it. The second mode is called "Test" and is indeed a planned analysis with preset simulation parameters. In this section of this tutorial lesson, you will run a live simulation.

Note that your circuit is a simple voltage divider fed by a DC voltage source. The voltage across the vertical resistor (R2) is therefore given by:

[math]V_{R2} = \frac{R_2}{R_1+R_2} V_s = \frac{2}{3} V_s[/math]

To start a live simulation, click the "Go/Run" B2Run Tool.png button of the Main Toolbar, or select the "Go/Run" item of Simulate Menu, or simply use the keyboard shortcut "Ctrl+G". You will notice the timer window next to the Run button starts showing the passage of time. However, you won't be able to notice any other change on the screen. You can view the value of voltages, currents or powers on your circuit. To do so, you should press the buttons labeled "V", "I" or "P" on the Schematic Toolbar to display Voltage Text, Current Text or Power Text, respectively. To hide the texts, press the relevant buttons once again to deselect them. The following figures show the voltage and power texts.

B2TUT1 5.png
B2TUT1 6.png

Keep in mind that since your voltage source is DC, the voltages, currents or powers do not change a function of time. Therefore, you will continue to see fixed values of these circuit quantities. To stop a live simulation, click the "Stop/Reset" B2Stop Tool.png button of the Main Toolbar, or select the "Stop/Reset" item of Simulate Menu, or simply use the keyboard shortcut "Ctrl+E".

Before moving to the next section of this tutorial, let us verify the results that you have got so far. The current in your circuit is given by:

[math]I = \frac{V_S}{R_1+R_2} = \frac{5V}{3K} = 1.667 mA[/math]

Therefore, the powers consumed by the voltage source and the two resistors R1 and R2 are given by:

[math]P_s = V_s I = 8.33 mW[/math]

[math]P_{R1} = R_1 I = 2.78 mW[/math]

[math]P_{R2} = R_2 I = 5.56 mW[/math]

Using the Live Circuit Control Panel

Now that we have the circuit at a steady state, we can experiment with the Parameters tab in the Toolbox to see how the voltages change in response to changes in other device values. B2.Spice A/D is one of the few programs that allows interactive real-time changes in device parameters while a simulation is running, allowing you to immediately see the response to those changes.

Click on the Parameter tab of the Toolbox on the left side panel of the program window to display the Live Circuit Parameter control panel. The display should look like the following:

B2TUT1 7.png

The radio buttons at the top of the screen labeled All, Some, and Few, control how many of the available parameters to display. The Few button displays only the most basic parameters such as a device's model and its main value. Some will list even more parameters and All will list all the available parameters. For our purposes, Few is enough.

Let us change the resistance of the horizontal resistor R1 to see how it affects the output voltage across the vertical resistor. With the simulation running, click on the r1.resistance box of the Live Circuit control panel. This should make it active and allow you to change the resistor R1's value by either typing a new value in the text box in the top section, or using the slider to drag the value up or down. Let's first try changing the value by using the text box. Erase the existing value of 1K and type in 2K. Click on the return arrow next to the box or press the Enter key to accept the change. As the resistance of R1 and R2 are now equal, the output voltage should change to 2.5V. Next, use the slider to lower the resistor's value. Click on the slider bar and drag it down (to the left) slowly and watch what happens to the voltage text label. As expected, the output voltage rises. Then, drag the slider in the opposite direction to the right to increase the resistance of R1. The output voltage will drop.

You can continue to experiment with the various parameters in the live circuit control panel to investigate their effects on the circuit.

Running a DC Sweep Test

B2TUT1 8.png

To run a test, you need a little bit of advance planning. All the test results will be displayed in graphs or tables in separate windows. B2.Spice A/D offers a variety of test types for different analysis purposes. The simplest one is the DC Bias Test. As part of your test planning, you must identify your project's observables, that is the circuit quantities you are particularly interested in and would like to plot them in a graph or list them in a table. In this tutorial lesson, as you saw earlier, all the voltages, currents and powers are fixed and do not change. Therefore, there is nothing to graph. However, you can find the DC bias operating point of your circuit.

First, go back to your circuit and double click on resistor R1 and change its resistance back to the original value of 1K. Then, go to the Toolbox on the left side panel and click on the "Tests" tab. Select DC Bias option by checking the leftmost check box in the "basic" column. The Tests Dialog should look like the figure below:

B2TUT1 10.png

Click the "Setup" button in the DC Bias test row to open the test settings dialog. The Test Settings Dialog should look like the figure below:

Make sure that the Single Test tab is selected as you do not want to run a Sweep or Monte Carlo analysis at this time. Also, make sure the check box labeled "Table" is checked in the "Output Results Options" section of the dialog. Click the "Run Test" B2RunTest Tool.png button of this dialog, or alternatively, select Run Test Batch from the Simulate Menu or use the keyboard shortcut "Ctrl+B". The operating point quantities of your circuit including the node voltages and the currents and powers of all devices are tabulated in a separate window at the bottom of the Workshop as shown in the figure below:


In this case, the DC operating point of the circuit is the steady state solution for the circuit. In general, the DC operating point is the solution of the circuit with all capacitors open, all inductors shorted, and non-constant sources at their initial values.

This was a good start. But how does the output voltage (across R2) vary with respect to the voltage generated by the voltage source? To answer this question, you will next perform a DC Sweep Test. If you are still in the Test Settings Dialog, you need to go back to the Tests Dialog. To do so, click the right arrow button at the top of the dialog or click the button labeled "All Tests" at the bottom of the dialog. Uncheck the DC Bias test and instead check the DC Sweep at its leftmost check box in the "Basic" column. Then, click the "Setup" button in the DC Sweep test row to open the test settings dialog again. This time, the Test Settings Dialog should look like the figure below:

DC Sweep Setup Dialog
Edit Plot List Dialog

From the "Source" drop-down list, select "v1", with the "Property" set to "DC". Set the Start Value to 0, End Value to 5 (Volts) and Step Value to 100m (millivolts). Make sure again that the Single Test tab is selected. Also, make sure the check box labeled "Graph" is checked in the "Output Results Options" section of the dialog. Before running the test, you have to instruct B2.Spice what you want to plot at the end of the test. Click the button labeled "Preset Graph Plots...". A new dialog opens up, which looks like the figure shown above. The dialog contains a tabled titles "Signal Name" that lists all the signals available for graphing. Select v(2) from the table by highlighting it and click the button labeled "Add->" to move the signal to the other table on the right titled "Graph Name". You can add different signals and can further change the list items using the "<-Remove" button. Click the OK button of the dialog to accepts changes and close it.

Attention icon.png The voltages are defined by referring to the nodes of the circuit. v(2) means the voltage at Node 2 reference to the ground. You can see all the node numbers or labels by clicking the "Show Node Names" B2Nodes Tool.png button of the Schematic Toolbar or using the keyboard shortcut "Ctrl+Alt+N".
B2TUT1 15.png
If you display/activate the nodes in your circuit, your schematic must look like the following figure:


Now click the "Run Test" button B2RunTest Tool.png of the dialog once again to run the DC Sweep test. A new graph appears at the bottom of the Workshop on a separate tab next to the DC Operating Point table of the previous test. The graph is shown in the figure below:

The output voltage plot.

As you expected, the graph is linear with a positive slope of 2/3. You’ll notice that as you move the mouse over the graph, the location of the cursor is listed in the status bar at the bottom of the graph. Each graph has its own toolbar and menu with tools that you can use to further examine the graph. Probably, the most important and useful of these are the Tracking Crosshairs, which can be activated by clicking the "Track Selected Plot" B2TrackCH Tool.png button of the Graph Toolbar. Also, each graph has additional tabs in the Toolbox. These include Edit plots, Edit Graph, Edit Axes and Tracker tabs. These tab appear in the Toolbox side panel only when the graph is active. For example, using the Edit Graph tab, you can change the title of the graph and its background color, while using the Edit Plot tab, you can change the color of individual signals. B2.Spice A/D allows you full customization of your graphs including adding new graphs based on mathematical expression involving the existing signals.

Saving the Circuit

Now choose Save... from the File Menu or use the keyboard shortcut "Ctrl+S". Since the circuit does not have a name yet, the program will prompt you to name the circuit. Name it, then you can quit and take a break.

 

Back to B2.Spice A/D Wiki Main Page   Rarr.png   Tutorial Lesson 2