Mathematical Functions


You want square roots and some transcendental functions? We've got 'em!

I've written a PMP library unit to handle the following functions: square root, sine, cosine, tangent, log_base_2, log_base_e and log_base_10. The format is fixed point, with the last two digits representing the tenth and hundredth places. Also included is a print routine which will properly place the decimal point when it comes time to see your result.

As in the previous exercise, we'll scope out the demo on a terminal program. So, the photo, above, is the same, as is the circuit, which I'll reprint here for your convenience:


The demo simply prints out values for these various functions. Here's what the terminal shows when log_base_10 is starting to speak:


If you'd like to see the entire output for the demo, then click the following link:


Be sure to read over the source code for both the demo as well as the library unit. There's lots of information there, including details on allowable domains for these functions.

One final note. While PMP understands floating point and contains a wide variety of native transcendental functions, it is also true that these can be real memory hogs. Of course, they're great when the numbers get big. But for many common applications, the fixed-point functions I've provided will get the job done for less expense.

Click to get the source code.
Click to get the schematic PDF.

Next Project: Complex Sound Generator

No comments:

Post a Comment