electronic-devices-9th-edition-by-floyd pp18a

38
© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved. Electronic Devices, 9th edition Thomas L. Floyd Electronic Devices Ninth Edition Floyd Chapter 18

Transcript of electronic-devices-9th-edition-by-floyd pp18a

Page 1: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Electronic DevicesNinth Edition

Floyd

Chapter 18

Page 2: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Programming Basics

Three levels of programming languages are:

SummarySummary

Machine language that is composed of 0s and 1s that make up a set of instructions (commands) that a specific processor can interpret and carry out. It is the most primitive language, and is not used by humans.

Assembly language that uses English-like mnemonics to replace the groups of 0s and 1s of machine language. Assembly language can produce very efficient code but is machine dependent.

High-level languages that has a number of easily understood instructions that replace groups of assembly mnemonics. High-level languages tend to use natural language commands and are usually portable, meaning they can be used on different processors.

Page 3: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Programming Basics

SummarySummary

Simple instructions are those that perform a basic task like ADD.

Conditional instructions are instructions, such as “JNZ” (jump if not zero) that evaluate specific conditions (such as whether or not a value is zero) and affects the sequence of program execution based on the result.

Looping instructions are instructions that allow a set of instructions in the program to execute more than once. In C++, the while statement is an example. The program will repeat a set of instructions as long as the looping condition is true.

Branching instructions are instructions that change the sequence of program execution. An example is JMP, which is an unconditional jump instruction.

Four basic types of instructions:

Page 4: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Programming Basics

SummarySummary

An algorithm is a sequence of instructions that describe how to solve a problem. One way to graphically illustrate an algorithm is with a flowchart. The following are some symbols used with flowcharting:

Page 5: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Automated Testing

SummarySummary

Automated testing includes software and a hardware components. The Test Controller is a PC, workstation, or dedicated processor that sets up the test equipment, controls the sequence of test operations, makes the appropriate connections to the unit under test (UUT), and records the data.

Page 6: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Automated Testing

SummarySummary

The Test fixture houses Switching Control and Switching Circuitry and has a means of connecting to the unit under test (UUT). One common method is to use spring loaded contact pins (called a “bed-of-nails”) that make connection to the UUT at points determined by the software.

Page 7: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Automated Testing

SummarySummary

The Test Equipment and Instrumentation are stimulus and response instruments that are controlled by the test controller. Stimulus instruments can send a voltage, current or digital pattern to the UUT. Response instruments make measurements of the result.

Page 8: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Automated Testing

SummarySummary

The Unit Under Test (UUT) (sometimes referred to as a Device Under Test) can be a simple bare board that is tested for continuity looking for shorts or opens or may be a fully completed board. Tests range from component tests, functional tests, and may include fault analysis tests. Faults are sometimes tested without power due to uncertainty in the type of fault.

Page 9: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Electrical Measurements

SummarySummary

All electrical measurements have a loading effect on the UUT. For voltage and resistance measurements, the measuring instrument is connected in parallel and loading is generally small. Current can be measured by applying Ohm’s law to a known series resistor or adding a small “sense” resistor to the circuit to develop a voltage for measurement. Example: Give the basic steps required to measure the collector current of Q1 using a DMM connected to Port 4. Assume a +10V dc source is already connected to TP1 and a ‒10V dc to TP4.

Solution: Set the DMM to DC Volts. Connect pin A of Port 4 to TP1 and pin B to TP2. Measure the voltage and apply Ohm’s law.

Page 10: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

SummarySummary

Electrical Measurements Practical considerations for auto test:

Always begin in a known state by deactivating voltage and signal sources. All sources should be configured properly before connecting them.

Test controllers need to be configured to wait after configuration to ensure that the test system and UUT are stable.

Diagnostics and self-tests can ensure that the test system is functioning properly and will find a fault when there is one but does not indicate a fault when none exists.

Page 11: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Simple Programming Basics

SummarySummary

The simplest type of programming is the simple sequential program, where the steps are executed sequentially until the program is completed.

BEGIN

END

INSTRUCTION

INSTRUCTION

INSTRUCTION

Example: An auto test program is set up to measure the resistance of a resistor (the UUT) and calculates the current if 10 Vdc is applied to it. It prints out the expected current. Show the flowchart.

Solution: See flowchart.

Page 12: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Simple Programming Basics

SummarySummary

A sequential program can be described with pseudocode, which uses generic descriptions rather than specific instructions.

Example: Write a pseudocode for the flowchart from the previous example, which stated: “An auto test program is set up to measure the resistance of a resistor (the UUT) and calculates the current if 10Vdc is applied to it. It prints out the expected current.”

Solution: procedure MeasureResistance begin

disconnect instrumentsselect ohms function on DMMconnect DMMmeasure resistancecurrent = 10 Vdc divided by resistanceoutput current

end MeasureResistance

Page 13: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Conditional Execution

SummarySummary

It is much more useful to be able to test specific conditions and alter program execution based on the result. Program decisions are shown in a diamond box on a flowchart. The answer is limited to one of two possible outcomes, so decision questions must generate a “TRUE/FALSE” or a “YES/NO” answer.

Page 14: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Conditional Execution

SummarySummary

Example: Show a partial flowchart that measures a power supply voltage and tests to see if it is set between 4.75 Vdc and 5.25 Vdc. If so, close the master switch; if not, print the words “Power supply out of range”.

Solution:

Page 15: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Conditional Execution

SummarySummary

Example: The previous example can be written as pseudocode. It is necessary to make sure the master switch is closed only if both voltage conditions are not true. Notice that it is embedded within the second else loop to accomplish this.

procedure TestVoltage begin

measure voltageif V < 4.75 VDC then begin if

print “PS Out of Range” end ifelse begin else if V > 5.25 VDC then

begin if print “PS Out of Range” end if

else begin else close master switch end else end else

end TestVoltage

Page 16: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

SummarySummary

Conditional ExecutionSometimes it is useful to be able to select from multiple options. The CASE instruction is a special type of nested IF-THEN-ELSE instruction that can select alternative actions based on a specific criteria. It performs alternative actions based on the specific value of a variable.

DOES YES

NO

ALTERNATIVE2

NO

DEFAULTACTION

YES

ALTERNATIVEN

ALTERNATIVE1

NO

YES

EQUAL?

DOESEQUAL

?

DOESEQUAL

?

Page 17: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Program Loops

SummarySummary

Another important programming feature for virtually all computer programs is the loop. A program loop is a set of instructions that can be executed repeatedly.

INSTRUCTION

LOOP

PROGRAMLOOP

INSTRUCTION

A conditional loop will execute only if some condition (such as a counter value) is satisfied. Most program loops are conditional.

An unconditional loop is a set of instructions that will execute indefinitely, but there are certain cases where this is intentional. Normally there will be a procedure for interrupting the loop to perform alternate instructions.

Page 18: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Program Loops

SummarySummary

Three structures for conditional loops are the FOR-TO-NEXT loop, the WHILE-DO loop, and the REPEAT-UNTIL loop.

The FOR-TO-NEXT loop uses a counter or index value to determine when to exit the loop.

The WHILE-DO loop performs the loop instructions as long as some condition is met. This is useful in automatic test systems. This type of loop may be done zero times if the condition is not met.

The REPEAT-UNTIL loop checks the specified condition at the end of the loop, a REPEAT-UNTIL loop will always execute at least once.

Page 19: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Program Loops

SummarySummary

The text illustrates a program for multiplying positive integers using a pseudocode description. (See Example 18-10.) The basic problem is solved by adding the multiplicand to itself a number of times equal to the multiplier and storing the result as the product. The flowchart is shown here.

How would you convert the flowchart shown to pseudocode, using a WHILE-DO loop?

Page 20: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

SummarySummary

The solution is shown. Note that a correct solution can be obtained if the multiplier is zero because for this case the WHILE-DO statements will not be executed.

procedure MultiplyPositiveIntegers begin

set product to 0input multiplicandinput multiplierwhile (multiplier is not 0)

begin while-do add multiplicand to productstore new productsubtract 1 from multiplier

end while-dooutput product

end MultiplyPositiveIntegers

Program Loops

Page 21: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

SummarySummary

A flowchart is shown here that does the loop test at the end of the loop. This type of loop will always be executed at least once and represents the REPEAT-UNTIL instruction.

Program Loops

What does S represent after exiting the loop?

S represents the sum of the digits from 1 to 100.

Page 22: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

SummarySummary

Branching instructions are used to transfer control to other parts of a program instead of executing the next sequential instruction. Conditional branching instructions are based a condition such as a count reaching a certain value. The conditional statements and looping instructions are special cases of conditional branching instructions. The flowchart illustrates a conditional IF-THEN-ELSE branching instruction.

Branching and SubroutinesIF CONDITION

IS

TRUE?

YES

NO

EXECUTEIF SECTION

EXECUTEELSE SECTION

Page 23: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

SummarySummary

Branching and Subroutines

Unconditional branching instructions transfer control to another part of a program without making any tests. The JMP (jump) instruction is an unconditional branch instruction. The programmer specifies the location in memory, usually using a label to represent a specific location in memory. Notice in the example shown that the word there is a label and that instruction 3 is skipped.

instruction 1instruction 2JMP thereinstruction 3

there instruction 4

Page 24: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

SummarySummary

A subroutine is a sequence of instructions, usually written separately from the main program, that accomplishes a specific task in a program. It is a powerful programming tool; a task that needs to be performed more than once can be coded once and used multiple times. Subroutines simplify programming by avoiding repetition.

Branching and Subroutines

In the example shown, the subroutine “GETKEY” is called from the MAIN program. Each time it is called, it is equivalent to inserting the GETKEY instructions at the place of the CALL.

Page 25: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Selected Key TermsSelected Key Terms

Program

Programming language

Flowchart

A series of instructions that has a computer perform some specific task or achieve some specific objective.

A set of instructions and rules for their use that allow programmers to provide a processor with the necessary information to accomplish some specific task.

A graphical means of representing the organization and process flow of a program using distinctively-shaped interconnected blocks.

Page 26: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Selected Key TermsSelected Key Terms

Pseudocode

Automated test system

Test controller

A textual means of representing the organization and process flow of a program using generic descriptions of program operations.

A system that operates under the control of an automated controller to conduct tests on a component, circuit, or system.

The component in an automated test system that executes the test code that defines the test tasks, configures the other components in the test system, and coordinates the activities of the test system components.

Page 27: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

Selected Key TermsSelected Key Terms

Conditional execution

Program loop

Branching

Subroutine

The selective processing of program instructions based upon the validity of some condition.

A sequence of execution in which a program returns to a previous point of execution.

Redirection of program execution to some program location other than what immediately follows in memory.

A sequence of instructions, usually written separately from the main program, that accomplishes a specific task in a program.

Page 28: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

1. The flowchart symbol used for an input/output operation is

a.

b.

c.

d.

Page 29: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

2. The flowchart symbol used for a decision operation is

a.

b.

c.

d.

Page 30: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

3. The two parts that are housed within the test fixture of an automatic testing system are

a. switching control and switching circuitry

b. test equipment and instrumentation

c. test controller and the unit under test

d. test equipment and the unit under test

Page 31: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

4. The main reason test controllers need to be configured to wait after configuration to ensure that the

a. power dissipation is not excessive

b. test system and UUT are stable

c. test controller is powered on

d. program has time to perform a self-test

Page 32: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

5. A type of program loop that checks the specified condition at the end of the loop is a

a. FOR-TO-NEXT loop

b. WHILE-DO loop

c. REPEAT-UNTIL loop

d. all of the above

Page 33: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

6. An instruction that performs alternative actions based on the specific value of a variable (allowing multiple options) is the

a. CALL instruction

b. WHILE-DO instruction

c. JUMP instruction

d. CASE instruction

Page 34: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

7. For the flowchart shown, the number of times the Subtract one from C instruction will be performed is

a. 0

b. 1

c. 100

d. not enough information to tell

Page 35: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

8. An instruction which is an example of an unconditional branching instruction is a

a. IF-THEN-ELSE instruction

b. WHILE-DO instruction

c. REPEAT-UNTIL instruction

d. none of the above

Page 36: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

9. The process of redirecting program execution to some program location other than what immediately follows in memory is called

a. branching

b. calling

c. looping

d. repeating

Page 37: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

10. A sequence of instructions, usually written separately from the main program, that accomplishes a specific task in a program is called a

a. program segment

b. subroutine

c. loop

d. case

Page 38: electronic-devices-9th-edition-by-floyd pp18a

© 2012 Pearson Education. Upper Saddle River, NJ, 07458. All rights reserved.

Electronic Devices, 9th editionThomas L. Floyd

QuizQuiz

Answers:

1. c

2. d

3. a

4. b

5. c

6. d

7. c

8. d

9. a

10. b