|
4
Using the Signal Calculator
Introduction
This chapter is an introduction to editing signals with the Signal Calculator (SigCalc). The chapter lessons explain how you create, display, select, edit, and save signal files. At the end of the chapter, you create a signal file that is used in the simulation of the notch60 test system.
Invoking SigCalc
- In the File Manager window, click on the SigCalc icon.
This displays the SigCalc window.
- In the SigCalc window, execute the following command:
- Scroll down the list and double-click on "test_lib/."
This changes the list box to show the signal files within the selected library.
- Double-click on the file name mary.sig.
This displays the signal file test_lib/mary.sig as a waveform.
The SigCalc window should look similar to the one shown in Figure 4-1.
Note: Your SigCalc window might look somewhat different from the one shown in the figure because of the display option settings that are carried over from session to session. If you do not see the calculator keypad, click on the Calc button to display it.
Figure 4-1 Signal Calculator Window
SigCalc Window Features
The SigCalc window has two main sections: the calculator and the signal display area. The calculator works just like an ordinary pocket calculator, except that it performs calculations on signals as well as numbers.
The signal display area shows a set of signals. The signals can come from signal files stored on disk, from the TMP signal window in the calculator, or from the signal generation commands of SigCalc.
Generating Signals
On the left side of the SigCalc window is a palette of command icons for generating and analyzing signals. Each icon performs the same function as the corresponding pull-down menu command, as indicated in Figure 4-2.
Figure 4-2 Command Icon Palette
Note: Additional icons may be present, depending on whether certain optional add-on products are installed.
- Click on the Gen-Sine icon in the palette.
This displays the dialog box shown in Figure 4-3.
Figure 4-3 Gen-Sine Dialog Box
- To use the default settings, click on the OK button.
The new signal is generated and displayed. It is inserted at the top, above the signal "mary.sig."
- Click on the Gen-Square icon to display the Generate Square Wave dialog box.
- Change the Number of Points value to 8000. Leave the other settings at their default values.
- Click on the OK button, and the square wave is generated and inserted at the top.
- Click on the S3 button in the signal display frame for the mary.sig signal. This selects signal S3 and places a copy in the TMP window of the calculator, as shown in Figure 4-4.
Figure 4-4 SigCalc Window Features
Generating More Signals
You do not need the calculator now, so you can remove it to make more room for signals.
- Click on the Calc button to remove the calculator.
For now, you also do not need the original signal, called mary.sig. That signal is designated S3 and is currently selected.
- To remove the selected signal from the signal display area, press and hold the right mouse button and select the following command:
Generate a Triangle Signal
Generate a Sawtooth Signal
Generate a Phasor Signal
- Click on the Gen-Phasor icon to display its dialog box.
- Change the value of the Frequency field to 0.005.
Leave the other field settings at their default values.
- Click on the OK button, and the complex phasor signal is generated.
The phasor has real and imaginary components, which are displayed separately.
Generate a White Gaussian Noise Signal
The signals are displayed in order, starting with the most recently created signal at the top of the signal display area, as shown in Figure 4-5.
Figure 4-5 Signal Display Area
Signal Display Area Features
The signal display area contains multiple signal windows, sequentially labeled S1, S2, S3, and so on. A signal waveform is made up of discrete data points connected by line segments. The horizontal axis marks the number of samples, while the vertical axis marks the amplitude. The vertical axis is marked with the most extreme values of the current scale on the left side of the signal window.
By default, all signal windows show the same range and number of data points. However, a lengthy signal plot might not fit within the window width, and a shorter signal plot might not completely fill a window. When a signal does not have enough data points to fill a signal window, the unused space is filled with null points displayed as cross-hatching on the horizontal axis. The total number of signal windows changes as you add signals to and cut signals from the SigCalc window.
Text fields at the top of the signal display area provide data about signal windows, signal selections, and target designations.
Signal Cursor
In the default operating mode, a single signal cursor moves as a unit, marking the same point number in all signal windows. Initially, the signal cursor rests at the left edge of the signal windows, crossing the first data point. The signal data fields (Point#, Time, and Value) provide information about the data point marked by the cursor and change automatically in response to signal cursor movements.
Move the Signal Cursor
Move the signal cursor as follows:
Text Fields
Text fields to the right of each signal window display information on the adjacent signal waveform. The data fields are explained in Table 4-1.
Table 4-1 Signal Window Text Fields
Edit Signal Window Text Fields
You can edit these text fields to set the signal characteristics (except for the Type field).
To edit the Point# field:
Adjusting the Horizontal Scale and View
All the signal windows show the same range of points. You can control the point range by editing the Win Size (window size), Win# (window number), and Shift (shift value) fields, located just above the top signal window.
Changing the Window Size
The Win Size value is the number of points plotted in each signal window. If it is not already set to 1000, set it to that value:
Changing the Window Number
Signal plots are divided into sections, each section equal to the window width (now set to 1000). The Win# text field shows which section is on display.
Changing the Shift Value
The Shift value indicates the point or time value by which a signal plot is offset with respect to a full plot segment or window width display. You can change this value so that portions of two consecutive windows are displayed rather than one whole section.
- Point to the Shift text field and click.
A temporary input field is displayed.
- Edit the Shift field, change the value from 0 to 500, and press the Return key.
The signal window shows points 500 through 1,499.
- There is a scroll bar at the bottom of the signal display area. Move the scroll bar slider all the way to the left.
This returns the view to points 0 through 999.
Selecting Signals
To edit a signal, you must first select a range of data points. The selected points are highlighted in the signal window with a distinct background color. The selection range can be as small as a single data point or as long as an entire signal.
Selecting a Whole Signal
To select a whole signal, use the following procedure:
- Click on the Calc button to display the calculator palette and TMP signal window.
- Click on the S1 button to select signal S1, the WGN signal.
The whole signal waveform is highlighted, and a highlighting rectangle is displayed around the signal window, showing that the whole signal is selected. Your selection is also displayed in the TMP window.
- Point anywhere on the S3 (sawtooth) signal waveform and double-click.
The whole signal is selected, just as if you had clicked on the S3 button. The previous selection is canceled
- Point to the empty area just to the right of the S1 button and click once.
This empty space is a "null" area in the signal display frame. When you click on it, your previous selection is canceled and nothing is selected.
Selecting a Range of Points
- Point to any data point in the S1 (WGN) waveform.
- Click on the signal waveform without dragging the mouse.
A single point is selected.
- Press and hold the left mouse button, drag the mouse to the right, and release the mouse button.
The range over which you drag the mouse is selected, and only that section is highlighted. There is no highlight rectangle around the signal window because only part of the signal is selected.
Using the Select-Range Command
When you need to select a range of points with greater precision, use the Select-Range command.
- Select all of signal S1.
- Execute the following command:
Select-Select RangeThis command displays the dialog box shown in Figure 4-6.
Figure 4-6 Signal Selection Dialog Box
- In the dialog box, enable the Range button.
This activates the Point Min and Point Max fields.
- Edit the input field of the Point Min field to read 100. Edit the input field for the Point Max field to read 299. Leave other settings as is.
- Click on the OK button.
Points 100 through 299 are selected for signal S1.
Selecting Multiple Signals and Data Ranges
You can select multiple signals or signal ranges.
- Hold down the Control key and select any three signals.
Each new selection is added to the previous selection. Only the first selected signal is displayed in the TMP signal window.
- Point to a null area and click to cancel the selection.
- Hold down the Control key and use the mouse to select some signal ranges repeatedly within S1.
With the Control key pressed, selection works as a toggle: unselected points in the previous selection become selected, and vice versa.
- Point to a null area and click to cancel the selection.
- Hold down the Shift key and use the mouse to select a signal range repeatedly within S1.
Using the Shift key extends the current selection. When you press the mouse button to select, SigCalc looks for the nearest point in the same signal that is already selected. All points from that point to the mouse pointer location are selected automatically.
- Point to a null area and click to cancel the selection.
Selection Field
A selection indicator field ("Select=") is displayed at the top of the SigCalc window. It shows the current selection in text format. The examples in Table 4-2 illustrate the syntax used to describe the current selection.
Table 4-2 Selection Indicator Syntax and Explanations
Adjusting the Vertical Scale and View
The vertical (amplitude) scale of a signal window is automatically adjusted each time the signal is redrawn in order to accommodate the signal's most extreme values in the viewing range.You can override the default scale by using the View-Scale commands.
Scale Override
- Select the whole S3 (sawtooth) signal.
- Execute the following command:
View-Change Scale-OverrideThe dialog box shown in Figure 4-7 is displayed.
Figure 4-7 Override Scale Dialog Box
Auto Scale
- With the S3 signal still selected, execute the following command:
View-Change Scale-Auto ScaleThe ends of the scale are adjusted to accommodate the most extreme values of the signal, -7 and +7.
- With the S3 signal still selected, hold down the Control key and select S1 and S2).
- With S1, S2, and S3 all selected, execute the following command:
- Click on the OK button in the dialog box.
The change is applied to all the selected signals.
Scope Scale
- With the S1, S2, and S3 signals still selected, execute the following command:
View-Change Scale-Scope ScaleIn the Scope Scale mode, the minimum and maximum values are set to round values, like an oscilloscope's voltage range selections: ...1, 2, 5, 10, 20, 50, and so on. The smallest round value that accommodates the entire signal is used at the positive and negative ends of the scale.
- Point to a null area and click to cancel the selection.
- Click on the Calc button to remove the calculator.
Designating a Target
The Target Marker is a triangular arrow on the left side of the signal display area. The Target Marker is shown in Figure 4-8. When you generate a new signal or perform an operation that creates a new signal, it is added to the SigCalc window at the point designated by the Target Marker.
Figure 4-8 Target Marker and Related Items
Using the Target Marker
Use the Target Marker by following these steps:
- Point to the bottom of the target bar, below the Target Marker.
- Click the left mouse button a few times.
The Target Marker moves down one step at a time.
- Click a few times above the Target Marker.
The Target Marker moves up one step at a time.
- Click the middle mouse button, and the Target Marker jumps immediately to the mouse pointer.
The Target Marker always stops at the middle of each signal window and at each border between signal windows. A colored highlight border visually defines the target.
If the target is a signal plot, the highlight border surrounds the entire signal display frame. If the target is a border between two signal display frames, the target border is highlighted.
When the Target Marker points to a border, an editing command inserts a new signal at that point, creating a new signal window, and signals below the target point are pushed down and renumbered.
When the Target Marker points to the middle of an existing signal window, the new signal is inserted into that window. The manner in which the insertion takes place depends on the target mode, which you set with the Target Mode option button at the top of the signal display area. The current setting is displayed on the button, which initially is Replace.
For a complex signal, the marker can point to the border between the two components, which designates the whole signal as the target, or it can point to one component only, which designates only that component as the target.
Changing the Target Mode
To change the target mode, follow these steps:
- Click on the Win Size field and change the window size to 2000.
- Make the Target Marker point to the center of signal S1.
- Point to the Target Mode option button (shown in Figure 4-8).
- Press and hold the mouse button, select the option [Insert] from the menu, and then release the mouse button.
The Target Marker changes in appearance to indicate the Insert mode.
- Double-click on the Gen-Triangle button.
This generates a triangle wave and inserts it into signal window S1, pushing the existing signal to the right.
- Set the target mode back to the default setting, Replace.
- Double-click on the Gen-Triangle button again.
This generates a triangle wave and inserts it into signal window S1, replacing the existing signal.
- Place the Target Marker at the top of the Target Bar, above S1 (the default position).
The four target operating modes are summarized in Table 4-3.
Using Cut, Copy, and Paste
Use the Edit-Cut, Edit-Copy, and Edit-Paste commands to cut a section from a signal, or to copy part or all of a signal from one place to another. The following exercises demonstrate the use of these commands.
Cutting and Pasting
- Click on the S2 button to select the whole complex phasor signal.
- Execute the following command:
- Execute the following command:
Edit-Paste-NormalThe complex (phasor) signal is inserted at the Target Marker location and the other signals are renumbered.
- Select a range of points in the signal S3 (the sawtooth signal).
- Execute the following command:
Edit-CutThe selected points are removed from the signal. Signal points to the right of the selection are moved to the left, filling in the gap left by the cut points, and the signal's total length is reduced.
- Move the Target Marker to the border between S2 and S3. The Target Indicator field at the top is updated.
- Execute the following command:
Copying and Pasting
- Select all of signal S4.
- Execute the following command:
- With the Target Marker still between S2 and S3, execute the following command:
- Select all of S3 and S4: click on the S3 button, hold down the Control key, and click on the S4 button.
- Execute the following command:
Edit-CutBoth signals are removed from the display, and the signals below them are renumbered sequentially.
Note: The contents of the Clipboard are not visible.
- Click on the Calc button to bring back the calculator.
Using the Calculator
The calculator works just like a hand-held calculator, except that it performs mathematical calculations on signals as well as numbers.
The features of the calculator are shown in Figure 4-9.
Figure 4-9 Calculator
Keypad and Math Palette Buttons
Figure 4-10 describes the purpose of each button in the calculator keypad and Math palette.
Figure 4-10 Keypad and Math Palette Keys
You can use the calculator to perform numeric and signal calculations.
To perform a numeric calculation, click on the numeric keypad buttons as you would for an ordinary pocket calculator. The results are displayed in the Numeric field.
To perform a signal calculation, click on the signal buttons (S1, S2, and so forth) to select the desired signal and then click on the appropriate keypad buttons and function palette buttons. The calculation results are displayed in the TMP window.
For both numeric and signal calculations, the calculation sequence used to obtain the final result is shown in the Expr (Expression) field.
Calculation Exercises
The following exercises demonstrate the use of the calculator. For each exercise, perform the actions and button sequences in the order shown. The first few exercises show you how to perform calculations on simple numeric values. The remaining exercises show you how to perform calculations on signals.
In general, the Numeric and Expr fields are cleared automatically when you start a new calculation. If you make a mistake, click on the Clear button to clear these fields and start over.
Set Up the SigCalc Window
Before you begin the exercises, set up the SigCalc window using the following procedure:
- Execute the following command:
- A dialog box warns you that the deleted signals cannot be recovered. Click on the OK button.
- Using the Win Size field, set the signal window size to 1000.
- Execute the following command:
- In the dialog box, set the Floating Point Precision to 4 and then click on the OK button.
- Generate a new sine wave signal and a new square wave signal using the default signal-generation settings.
The Calculator's Expr field and TMP window should be empty.
Exercise 1: Add Numbers
Calculate the sum of numbers entered on the keypad. Use the sequence of actions shown in Table 4-4.
Each time you key in a numeric value, the value is echoed in the Numeric field. When you press the Execute (=) button in the keypad, the expression is evaluated. Parentheses are inserted around the calculated expression in the Expr field and the result is displayed in the Numeric field. There is an implicit execute operation associated with the addition + button when a calculation is pending in the Expr field.
Exercise 2: Use the Math Function Keys
Calculate the trigonometric sine of p/3 using the sequence shown in the Table 4-5.
Some Math functions, such as sin, ln, and square root, operate immediately on the expression in the Expr field. Others, such as X raised to the power of Y, require that you enter another value, followed by the = button to perform the calculation. Still others, such as integration, operate only on signals and do not work on simple numeric values.
If you wish, perform some numeric calculations of your own choice using the keypad and Math functions. When you are done, press the calculator's Clear button and continue with the next exercise.
Exercise 3: Store/Recall a Numeric Value
Calculate the square of the constant e and store the resulting value in Register R1 for future use. To verify that the value was saved, recall it from that register. Use the sequence shown in Table 4-6.
There are four registers available for storing numeric values, designated R1 through R4. By default, R1 is the active register when SigCalc is invoked.
In the remaining exercises, you perform calculations on signals rather than numeric values.
Exercise 4: Add Signals
Calculate the sum of signals S1 and S2. The matching points of S1 and S2 are added, resulting in a new signal in the TMP window. When the User Action column says "Click on the S1 button," you can either click on the S1 button in the signal display area, or click on the S and 1 buttons in the calculator keypad. Use the sequence shown in Table 4-7.
Note: For a two-digit signal such as S12, you would click on the S button twice, followed by the two digits.
Table 4-7 Add Signals Exercise Select: Expr Field TMP Signal Window S1 button S1 S1 + button in keypad S1+ S1 S2 button S1+S2 S2 = button in keypad (S1+S2) Result of Expr
Exercise 5: Multiply Ranges of Points
Multiply a range of points in S1 with a different range of points in S2. Use the sequence shown in Table 4-8.
Exercise 6: Signal/Numeric Calculation
Add 3.0, a constant, to every point in signal S1 and then calculate the natural logarithm of the result. Use the sequence shown in Table 4-9.
The "ln" function operates on the last item in the Expr field. In this case, it operates on the sum of S1 and 3.0 because the whole expression (S1+3) is enclosed in parentheses in the Expr field.
Exercise 7: Signal/Numeric Calculation
Add the natural logarithm of 3.0 to every point in signal S1. Use the sequence shown in Table 4-10.
In this case, the "ln" function operates on the numeric value 3.0, because "3" was the last item typed into the Expr field. The sum S1+3 had not yet been calculated, and was therefore not considered a single item. Compare this calculation with the previous example.
Exercise 8: Calculate and Store a Signal
Add the value of 2p, a constant, to every point in Signal S1 and then calculate the arc tangent of the result. Store the signal into the signal display area. Use the sequence shown in Table 4-11.
When you click on the calculator's Store button, a copy of the TMP signal is inserted into the signal display area at the target position, creating a new S1 signal. Existing signals are renumbered in sequence.
The [Store] button stores a signal in the same manner that the Store R button stores a numeric value, except that the signal goes into the signal display area rather than a register. However, there is no Recall button to recall a signal; simply select a signal to copy into the TMP window. Signal display area storage is temporary; when you exit from SigCalc, the signals are lost. For permanent storage, you can save the signal as a disk file, as explained later in this tutorial chapter.
If you wish, perform some signal calculations of your own, using the signal selection buttons, keypad, and Math palette. Leave the Target Marker at the top of the signal display area, above S1.
You can type expressions directly into the Expr field and execute them by pressing the Return key. For example, enter "S1+S2+S3" into the Expr field, press the Return key, and the sum of the three signals is displayed in the TMP window.
Editing the Simulation Input Signal
The signal "mary.sig" is a speech signal that was sampled at a rate of 8,000 times per second, converted to digital format, and stored as a signal file. The whole signal contains about 47,600 data points, about 6 seconds of speech.
The signal's sampling frequency is 8,000, but the notch60 filter you are going to test was designed to operate with a sampling frequency of 2,000. To obtain the same signal waveform at the new sampling frequency, you must resample it by a factor of 4.
Load the Signal
- Execute the following command:
- In the dialog box, click on the OK button
- Execute the following command:
- Find the file name test_lib/mary.sig and double-click on it.
- Using the Win Size field, set the window size to 47600.
The signal is displayed as signal S1, as shown in Figure 4-11. The figure also shows the words corresponding to the waveform.
Figure 4-11 Signal "mary.sig"
Play the Signal
If you are running SPW on a Sun SPARCstation, you can "play" the speech signal through the computer's audio output port and listen to the spoken words.
If you are running SPW on any platform other than a Sun SPARCstation, please skip this part and continue with the next subsection, Resample the Signal.
- Select S1, the speech signal.
- Execute the following command:
- Find the library name "demo/" and double-click on it.
- Find the user program name "play" and double-click on it.
This displays the "SPW: demo/play" control window.
- In the control window, click on the Start button.
After a brief delay, the user program plays the signal through the computer's audio speaker.
- In the control window, execute the following command:
Resample the Signal
To resample the signal, follow these steps:
- Select S1, the speech signal.
- Using the calculator palette option button, change from Math functions to Filter functions, as shown in Figure 4-12.
Figure 4-12 Math and Filter Palettes
- Click on the Decimat button.
- In the dialog box, enter the value 4 into the Factor field.
The Filter option should be toggled on, with the Number of Coefficients set to 25; this invokes an anti-aliasing filter that is applied to the signal before resampling takes place.
- Click on the OK button.
The signal is resampled. The new signal is displayed in the TMP window. The sampling frequency of the signal changes from 8000 to 2000, and the number of points is reduced by a factor of 4.
- For a better view of the signal, set the Win Size value to 5000.
- Click on the Store button.
The new signal is copied to signal window S1, as shown in Figure 4-13.
Figure 4-13 Edited Simulation Input Signal
Add a 60-Hz Sine Wave
Next, you generate and add a 60-Hz sine wave to the speech signal. This serves as some 60-Hz noise that can be filtered out by the notch60 filter.
- Click on the Gen-Sine button in the command icon palette.
- In the Generate Sine Wave dialog box, set the sine wave characteristics as follows:
- Click on the OK button to generate the signal, as shown in Figure 4-14.
Figure 4-14 60 Hz Sine Wave
- Using the calculator, add the 60 Hz sine wave (S1) to the speech signal (S2) and click on the execute (=) button.
The sum of the sine and speech signals is generated and displayed in the TMP signal window.
- Move the Target Marker to the border between S2 and S3.
- Click on the Store button, and the signal is copied to a new S3 signal window, as shown in Figure 4-15.
Figure 4-15 Sum of S1 and S2 in S3
Enter Comment Line
You can use the long, narrow box at the top of a signal window to enter a comment line for that signal.
Save the Signal File to Disk
Because the 60 Hz sine and "Noisy Mary" signals are new, their file name text fields contain empty rectangular boxes.
Exiting SigCalc
|
CoWare CoWare's Web Site Phone: 1-888-269-2738 CoWare Customer Support |