|
3
Building a Notch Filter
Introduction
In this chapter you build a notch filter. Although a filter block of this type is already available from the standard block libraries, you will build this filter "from scratch" using Adder, Multiplier, and Unit Delay blocks. You will also build a system to test the notch filter and simulate it in a later tutorial chapter.
Add the Blocks
The first step is to add the blocks needed to build the filter.
- Open a new BDE design window if there is not already one open.
- Press the right mouse button and execute the following command in the popup menu:
Grid OnNote: This is the equivalent of toggling on the Grid option in the Options-Customize-Design Window dialog box.
- Using the Add-Blocks command, add one instance of each of the following blocks:
>Blocks>Math>Basic>Gain
>Blocks>Math>Basic>Add
>Blocks>Math>Basic>Add 3-Input
>Blocks>Memory/Delay>Unit Delay
Note: You can type Control-b to quickly redisplay the Add Block dialog box.
- Enlarge the design window on the workstation screen to provide more room to work. For example, if you are using the MOTIF window manager, you can click on the Maximize button or you can point to the corner and then press, drag, and release to enlarge the window.
Note: As you build the notch filter, you can change the viewing scale with the View-Zoom Out and View-Zoom To Fit commands.
- Make four more copies of the Gain block, one more copy of the two-input adder block, and one more copy of the Unit Delay block, as shown in Figure 3-1. Use the following popup menu commands:
Figure 3-1 Notch Filter Blocks
Add the Ports
A port is a connection point between adjacent levels of a design hierarchy. Adding input ports and output ports to a block diagram allows that block diagram to be encapsulated into a single hierarchical block, which can then be used in multiple designs or in different places within the same design.
The notch filter has one input and one output, so the block diagram needs one input port and one output port.
Input Port "x"
- Click on the Add-Port icon, which is the button with a picture of a short wire connected to a flag shape.
This displays the Add Port dialog box.
- In the Signal Name field, delete the default entry and type in the name "x" as shown in Figure 3-2.
Leave the port type at its default setting, Input. Also leave the Data Type button at its default setting, Double.
Figure 3-2 Add Port Dialog Box
- Click on the OK button.
The cursor changes to a cross-hair shape.
- On the left side of the design window, point to a grid dot. Press the mouse button, drag up to the next grid point, and release the mouse button.
The port is added to the "press" location and the port name is added to the "release" location.
Output Port "y"
- Click on the Add-Port icon again.
- In the dialog box, change the port direction to Output.
- In the Signal Name field, delete the "x" type in the name "y" instead.
- Click on the OK button.
- On the right side of the design window, point to a grid dot. Press the mouse button, drag up to the next grid point, and release the mouse button.
Connect the Blocks
- Move the blocks and the two ports into the positions shown in Figure 3-3.
To move port "x" or "y," it is only necessary to select and move the port pin. The label "x" or "y" moves along with the port automatically.
Figure 3-3 Blocks and Ports Moved into Position
- Add the connections shown in Figure 3-4.
It is not necessary to connect block input/output ports with wire when the ports coincide on a grid point. Such ports are considered connected, as indicated by the small diamond shape displayed at each connection point in the BDE design window.
Figure 3-4 Connected Blocks and Ports
Modify the Block Parameters
The Gain block is a signal multiplier. At the top of each block is a parameter that specifies the value of the multiplier for the block instance. The word "Value:" is a text label and the parameter itself is a number displayed in a gold color. The default setting is 1.0.
Each of the five Gain blocks in your diagram is an instance of the Gain block function. The parameter setting can vary from instance to instance of the same block function. Setting a block instance parameter does not affect other instances of the same block, nor does it affect the original library block.
To implement the notch filter, you need to modify each of the Value parameters. The correct values to use are provided in the tutorial instructions. If these values were not provided, you could use the SPW Filter Design System (FDS) to calculate them.
Modify the First Parameter
- Point to the parameter of the upper-left Gain block (displayed as 1.0) and double-click on it.
This displays the Parameter Properties dialog box, shown in Figure 3-5.
Note: Double-clicking on a parameter is the same as selecting the parameter and executing the Edit-Properties command.
Figure 3-5 Parameter Properties Dialog Box
Modify the Other Parameters
- Repeat the same procedure to set the Value parameter of the other four Gain blocks to the numbers indicated in Figure 3-6.
To enter a new value into the Parameter Properties dialog box, you can either type the value on the keyboard or click on the number keys in the dialog box keypad.
If you happen to double-click on a block rather than on a parameter, BDE displays the context window for that block. If this happens, execute the File-Close command in the context window.
If you have any difficulty selecting a parameter because is overlaps another selectable object, you can either select a small region that just surrounds the parameter or you can set the Affinity button to Parameter. After you select the parameter, execute the Edit-Properties command.
Figure 3-6 Parameter Values
Save the Detail View
The window manager's title line at the top of the design window says "Unnamed design file" because you have not yet saved the design. The Status Line just under the working area says EDIT**, which indicates that this is an editable design window. The two asterisks indicate that the design has been edited but not yet saved.
- Execute the following command:
- In the File Save As dialog box, enter the name "yourlib/notch60.detail" into the New Filename field as shown in Figure 3-7, substituting the name of your library (created in Chapter 1) for yourlib.
Note: Assigning a logical grouping is optional. For this exercise, leave the Group Name option toggled off.
Figure 3-7 File Save As Dialog Box
- Click on the OK button.
BDE saves the block diagram into the library/cell.view called yourlib/notch60.detail. The two asterisks in the Status Line after the word EDIT are removed to indicate that the design has not been edited since the last save operation. The title line at the top of the design window is revised to show the design name.
Create the Block Symbol
The block diagram you just saved is called a "detail" view because it shows the internal details of the notch60 signal-processing function. Next, you create a "symbol" view of the same notch60 function, which is a block representation of the function.
- Execute the following command:
- Opens a new design window.
- Builds the symbol view in the new design window.
- Saves the symbol view under the name yourlib/notch60.symbol.
The symbol view is shown in Figure 3-8.
Figure 3-8 Automatically Created Symbol View
The block symbol has the same ports as the detail view, called "x" and "y." The symbol and detail view share the same library name and cell name, but have different view names.
Instead of using the Auto Create Symbol command, you can create a symbol manually by adding ports, lines, a box, and text. You can also modify an automatically created symbol view to change its appearance. For example, you can use a circle instead of a box for the main body of the block. However, for this exercise, you will just use the default symbol created automatically by the Auto Create Symbol command.
Build the Test System
A typical design is built as a hierarchy of block diagrams. A design hierarchy contains multiple levels, where a single block instance at one level represents a complete block diagram at the next lower level. The design hierarchy can be nested any number of levels deep.
The top-level design is called a "system" view. In this section of the tutorial, you build a system-level block diagram to test the operation of the notch filter. The test system contains one Source block to provide a test signal, one instance of the notch60 block, and one Sink block to record the results. You will simulate this system in later chapters of the tutorial manual.
Add a Block Instance
- In the design window containing the detail model, execute the following command:
- In the empty design window, press the right mouse button and execute the following command in the pop-up menu:
- Click on the Add-Blocks icon.
- In the Add Block dialog box, toggle on the Select by Logical Name option.
- In the list box, find your library name and double-click on it.
- In the list box, double-click on the cell name "notch60/."
- In the list box, double-click on the view name "symbol."
- Add the block instance to the center of the working area.
This new block instance is a "hierarchical" block, which means that it represents a lower-level block diagram (the "detail" view of the block function).
Compare the Instance and the Symbol View
- Compare the block instance with the original symbol view displayed in the previous design window, as shown in Figure 3-9.
Figure 3-9 Block Instance and Original Symbol View
The first difference you might notice is that the instance is displayed in one color, whereas in the original symbol view, the different parts are displayed in different colors. You might also notice that the ports are displayed as crosses in the instance and as boxes in the original symbol view, and that the port name labels next to the ports are not displayed in the instance.
- In the design window containing the original block symbol, try selecting various objects in the window. You can select the box, lines, text notes, and ports as separate entities.
- In the design window containing the block instance, click on various parts of the block. You can select the whole block or individual ports only.
- Close the design window containing the original symbol view.
Add the Source and Sink Blocks
- In the design window containing the instance of the notch60 block, add one instance of each of the following blocks (specified by logical grouping):
>Blocks>Signal Gen/Store>Signal Sources>Data
>Blocks>Signal Gen/Store>Signal Sink>Data
- Move the blocks together so that they are connected as shown in Figure 3-10.
Figure 3-10 Test System Blocks
Edit the Block Parameters
- Double-click on the Library/File parameter of the Source block, which is set by default to 'test_lib/in'.
- In the Parameter Properties dialog box, change the default text string from 'test_lib/in' to 'yourlib/noisy' as shown in Figure 3-11. Substitute the name of your SPW data library for yourlib. You will create the signal yourlib/noisy later.
Note: The tutorial instructions and SPW documentation always show parameter strings enclosed in single quotes (apostrophe characters). You can either use the quotes as shown or omit them from the actual parameter string. If you use quotes, be sure to use an apostrophe character (') at each end, not the backquote character (`) or ordinary quotation marks (").
Figure 3-11 Parameter Properties Dialog Box
- Click on the OK button to put the change into effect.
- Using the same procedure, change the Library/File parameter of the Sink block from the default setting, 'out', to 'yourlib/test_out'.
Your design should appear as shown in Figure 3-12.
Figure 3-12 Completed Test System
Save the Test System
Viewing the Hierarchy
The notch60 block instance is a hierarchical block that represents a lower-level detail view. You can look at the linked detail view in the context of the block instance and set the notch60 parameters in that lower-level view. This type of view is displayed in a context window, as demonstrated in the following exercise.
View the Design Hierarchy
- Double-click on the notch60 block instance to display the detail view in a context window.
Note: Double-clicking on a block is equivalent to selecting the block and executing the File-Open Design Detail command.
A context window is similar in appearance to a design window, except for the background color and the set of available commands.
- In the context window, double-click on the 3-input adder block to display another context window containing the adder block parameters.
- In the newest context window, click on the up-arrow icon to close the window.
Note: The up-arrow icon is equivalent to the File-Close command.
- Close the context window containing the detail view of notch60.
Context Window Editing
- In the original design window containing the test system, add another instance of the notch60 block. Leave the block unconnected, as shown in Figure 3-13.
Figure 3-13 Test System with Extra Filter Block
- Double-click on the new notch60 block to display its context window.
- In the context window, double-click on the Value parameter of the upper-left Gain block.
- In the Parameter Properties dialog box, change the parameter setting from .997137 to 2.0 and then click on the OK button.
- Try selecting various objects in the context window.
You can select objects just as you can in an ordinary design window. However, you cannot do any editing other than changing parameter settings. For example, you cannot add, move, or delete any objects. There is no Add-Blocks, Edit-Move, or Edit-Delete command in the context window.
- Close the context window.
- The parameter change that you made for the new notch60 block applies only to that instance of the block. To confirm this for yourself, double-click on both notch60 blocks to display their respective context windows, verify that the parameter change appears only to the new notch60 block, and then close both context windows.
Close the Design Window
|
CoWare CoWare's Web Site Phone: 1-888-269-2738 CoWare Customer Support |