Chapter 5 Computer Prediction of Motion (using True Basic)

This material is covered in a lab session. You will not be writing your own computer programs for this course. We will discuss the basic structure of the programs. You will then make minor modifications to the programs so you can control the calculations of the motion.

Installing True Basic on your own computer is optional. True Basic is on the CD-ROM that came with the Physics 2000 textbook. I have installed True Basic on the computers in our lab room.

page 5-2 I will review X & Y coordinates on a circle.

 

The first few figures in the text are "pseudocode." Pseudocode is an outline of how the calculations will proceed, not the actual program. The actual program listing is on page 6.

 

page 5-4 Often we want the computer to repeat the calculations a number of times. This is easily accomplished by creating a loop. The statements inside the loop are performed until the termination condition for the loop is reached. What is the termination condition for Figure 3?

page 5-5 The LET statement is a command that causes the computer to calculate the expression on the right side of the "=" symbol and store the result in the RAM memory of the computer at an address identified with the symbol on the left side of the "=" symbol. This is not an algebraic statement of equality. This is a command to calculate and store.

page 5-6 Variable names are labels used to identify storage locations in RAM memory. Variable names must start with a letter.

The label "Pi" is a reserved word in TRUE BASIC that has the value 3.14156 etc. Don’t try to use the label Pi as a variable name.

Multiplication: What is the value of 3(2.1) ? Hopefully you calculated the value to be 6.3. However, the computer does not recognized implied multiplication. When you want the computer to multiply two numbers or variables you must use an asterisk * between the quantities. e.g. 3 * (2.1) or 3 * 2.1 .

True Basic allows you to plot a point on the monitor by using the PLOT command. e.g. PLOT 20,30 would display a point at the x coordinate of 20 and the y coordinate of 30. You can use variable names instead of numbers after the PLOT command.

You must tell the computer some information about the plotting window. This is accomplished with the SET WINDOW command. We will use the values given in the text for this command.

Comments If you use the "!" symbol the computer will skip the rest of the line when it executes the program. Comments are used to help humans understand the program.

 

 

page 5-8 A Working Program

Login to one of the lab computers.

Launch True Basic

Instead of typing in the program, open the Figure 5_5 file. You will find this file in the Physics 2000 folder on the C: drive.

Run the program. Let me know if it does not work.

Open and Run the Figure 5_13 program.

 

Open the Figure 5:23 program. Pages 5-16 through 5-21 give some background for this program. Read the listing and ask me if you have questions.

Run the program.

Change the Vx and Vy values and execute the program.

Change the Ay value and execute the program.

We will not run the programs that illustrate air resistance.

 

 

 

 

Copyright© 2001 - 2006 by Greg Clements Permission is granted to reproduce this document as long as 1) this copyright notice is included, 2) no charge of any kind is made, and, 3) the use is for an educational purpose. Editing of the document to suit your own class style and purposes is allowed.