Voice feedback enhances engineering calculator
The screen shot in Figure 1 represents a Microsoft Excel 2002 worksheet designed to implement VFI (voice-feedback interface) for an engineering calculator. The voice-interface technique has both practical and educational aspects. It automates the common task of finding the values of two resistors for a given ratio. It also demonstrates the latest advances in natural-language programming technology with an example of the technology's actual implementation in CAD/CAE systems.A single user-defined function RR (resistor ratio) encapsulates both the computation engine and the VFI. The function uses VBA (Visual Basic for Applications) with the code placed in the standard code module of Excel File. (Click here to download a zip file containing the Excel worksheet and the listings associated with this Design Idea.)
The core search algorithm, which contains outer and inner loops, sequentially tests each pair of values, R1 and R2, to find the best approximation of the target ratio. In other words, the algorithm tries to minimize the absolute error: (ABS (R1/R2–Ratio)). The values of R1 and R2 come from the E24 EIA-standard series, but you can apply the same algorithm to any other standard series, such as E48, E96, or E192. The VFI sends the status-notification message in a verbal form instead of showing the Message Box. The VFI uses the built-in Excel 2002 Speech Object with the following syntax:
where contains the actual spoken text, and the second property is set to True for asynchronous mode. Listing 2 is an example of voice-error notification in the case that you enter non-numeric data as the ratio (data-validation error message):
Using the technique is simple. Open Excel File, switch to the Visual Basic Editor window (press Alt-F11), add the standard module, and paste the code from Listing 1. From the Debug menu item, choose Compile VBA Project, save the file with any name, and close the Visual Basic Editor window. Make sure you activate the text-to-speech tools (in the menu: Tools—Speech—Show Text To Speech Toolbar). Check whether you are in automatic- or manual-calculation mode (in the menu: Tools—Options—Calculation). Set the mode to automatic; otherwise, you'd have to use the F9 key to force a new calculation every time you enter a new ratio value. Choose any cell (for example, A2 in Figure 1) for the ratio (data-entry cell) and another cell (for example, B2) to display the results. Enter the formula =RR(A2) into cell B2. Now, every time you enter a new ratio value into cell A2, the system automatically calculates and displays R1, R2, and Relative Error, and sends the status voice notification. The notification is either "OK" to confirm the successful completion of the calculation or an error notification in the case of a data-validation or computation error. Note that some macros in Microsoft Office applications could result in potentially dangerous and harmful actions, and some may contain viruses. You use the macros at your own risk without warranties of any kind.
Is this the best Design Idea in this issue? Select at www.ednmag.com.