Homework 6, Use of IF Structures (14 points)
The job at the defense contractor didn't pay too well, so you've found work at a company that makes
electronic control circuits. To improve the quality of their products, the company is creating a very
large program to simulate the behavior of their proposed circuit designs. Your first job is to write 3
simple functions that provide specific voltage signals for use within the program.
Some of the products resulting from use of the final design program will be used in electrical power
plants and other applications that require an extensive Quality Assurance program. As a result, your
work must be generously commented, including a statement of the function's purpose, definitions for
all variables, and a line giving your name and the creation date.
- A real function named "vstep" provides a simple voltage step from zero to one volt. It has
two real arguments. The first is the current time, and the second argument is the time "t1" at
which the time steps up from 0 to 1 volt. The value returned for "vstep" must be zero when
time is less than "t1" and equal to one for time greater than or equal to
- A real function named "vsqwave" provides a square wave voltage. It has three real arguments.
The first is the current time. The second argument is the time "t1" at which the voltage steps
up to 1 volt, and the third argument "t2" is the point in time at which the voltage steps back
down to zero. The value returned for "vsqwave" must be zero when time is less than "t1",
equal to one for time from "t1" through "t2", and be zero when time is greater than
- A real function named "vramp" provides a ramped voltage increase from zero to one. It has
three real arguments. The first is the current time. The second argument is the time "t1" at
which the voltage starts to linearly increase from 0 to 1 volt, and the third argument "t2" is the
point in time at which the linear voltage increase reaches 1 volt. The value returned for
"vramp" must be zero when time is less than "t1", and equal to one for time greater "t2".
When time is between "t1" and "t2", the output voltage is a linear interpolation in time
between zero at "t1" and one at "t2".
I have provided the driver programs dstep.f, dsqwave.f, and dramp.f to test your functions. They
have no input, and just call the appropriate function several times with various values for arguments,
checking the results against expected values. Just add each of your functions to the end of the
appropriate driver, compile, and execute the program. It will tell you if the results look OK.
Each of the three functions will be graded as follows:
The function "vramp" includes 2 more points for correct implementation of the linear interpolation.
- 1 point for quality of comments
- 2 points for proper use of IF structure.
- 1 point for correct Function structure.
Leave your modified versions of dstep.f, dsqwave.f, and dramp.f (don't change the file
names) in your "homework" subdirectory. We will pick it up after the due date and test it.
Maintained by John Mahaffy : email@example.com