<<

EXAMENSARBETE INOM TEKNIK, GRUNDNIVÅ, 15 HP STOCKHOLM, SVERIGE 2020

Automated Testing of Digital Components

BABAK KABIRI

KTH SKOLAN FÖR ELEKTROTEKNIK OCH DATAVETENSKAP

Automated Testing of Digital Components

Babak Kabiri

Examinator: Carl-Mikael Zetterling ​

Supervisors: Johnny Öberg ​

Abstract

In today's technological companies digital and components are abundant. Many companies use these components to manufacture a wide variety of electronic products such as , tv’s, cars, etc. But after their use, these components are thrown away easily and are an additional contributor to our growing climate change. There is a need for a more effective way to deal with these components. Companies could save a lot of time and energy to have a system that could test these components.

The goal of this study is to present a suitable method for testing digital components by developing a test program for testing the various integrated circuits and thus identifies which circuits are faulty and which ones are not. The economical and efficiency side of building such a program is discussed and If it is worth the time to produce such a system, or if it's much better to throw the components away. The intent is also to give companies a way of being more efficient and environmentally friendly.

This program was made by using integrated circuits from the course IE1204 and IE1205, where students use these components for their labs. After the course has ended there is no certainty if the integrated circuits work properly or not. The goal of the program is then to test them and find out the faulty ones.

An Arduino Uno and the Arduino programming language have been used to write the code for this project. The Arduino Uno was connected to a breadboard which then ran the program for testing. To that breadboard, various integrated circuits, such as gates, were connected. The Arduino program then tested their truth tables to see if they worked properly or not.

Because of time restriction more complex components have not been included in this thesis.

Keywords- Automatisation, Testing, Logic Gates, , Digital Components ​

2

Sammanfattning

I dagens tekniska industri finns det rikligt med digitala komponenter och elektronik. Många av dessa komponenter används för att bygga större elektronik såsom datorer, tv apparater, bilar, etc. Men efter deras användning slängs dessa komponenter tveklöst och är dessutom en orsakande faktor i vår växande klimatförändring. Det finns ett behov av en mer effektiv lösning för hanteringen av dessa komponenter. Företag kan spara mycket tid och energi med att inneha ett sådant system.

Målet med detta projekt är att presentera en metod för att testa digitala komponenter. Att utveckla ett system som kan testa diverse integrerade kretsar och veta vilken som fungerar adekvat. Utvecklandet av ett sådant systemet ur ett ekonomisk och effektivitetsperspektiv diskuteras. Om det är värt att utveckla ett sådant system, eller om det är mycket bättre att bara slänga dessa komponenter. Målet med detta projekt är också att bana väg för företag att bli mer effektiva och miljövänliga.

Tillvägagångssättet kring hur detta system har utvecklats är genom att använda integrerade kretsar från kurserna IE1204 och IE1205, där studenter använder dessa komponenter för deras labbar. Efter att kursens avslut finns det ingen garanti ifall dessa integrerade kretsar fungerar eller inte. Målet med programmet är då att testa dessa och hitta de trasiga komponenterna.

En Arduino Uno och programmet Arduino har använts för att skriva koden till detta projekt. Arduinon har varit kopplad till en breadboard som har kört programmet för testing. Till denna breadboard har diverse integrerade kretsar, logiska grindar, varit kopplade.

Arduino programmet har sedan testat de olika sanningstabellerna för att testa vilken logisk grind som är kopplad och fungerar.

På grund av tidsbegränsning har mer komplexa integrerade kretsar blivit presenterade som en beskrivning av hur man kan fortsätta arbetet för att programmet skall inkludera mer komplexa komponenter.

Nyckelord- Automatisering, Testing, Logiska Grindar, Sanningstabell, Digitala Komponenter ​

3

Abstract 2

Sammanfattning 3

1 Introduction 6 1.1 Background 6 1.2 Problem Definition 6 1.3 Purpose 6 1.4 Goal 7 1.5 Method 7 1.6 Delimitations 7 1.7 Outline 8

2 Theoretical Background 9 2.1 Analog and Digital Circuits 9 2.2 Logic Gates 9 2.2.1 AND Gate 10 2.2.2 OR Gate 11 2.2.3 NOT Gate 12 2.2.4 NAND Gate 13 2.2.5 NOR Gate 14 2.2.6 XOR Gate 15 2.2.7 Summary 16

3 Method 17 3.1 Work Process 17 3.2 Data collection 17 3.3 Data analysis 17 3.4 Data Validity 18

4 Implementation 19 4.1 Hardware Design 19 4.2 Software Design 20

5 Results 23 5.1 Results from the Arduino 23 5.2 Reliability Analysis 25 5.3 Validity Analysis 26 5.4 Discussion 26

6 Conclusions and Future work 28 6.1 Conclusions 28 6.2 Limitations 28 6.3 Future work 29 6.4 Reflections 29

4

References 30

Appendix 31

5

1 Introduction

Digital electronics is the basis for everything related to electronic products. It is what builds our computers, lights our homes and enables us to read everywhere. Given this fact, it makes sense to use them properly. In this chapter, the reader will be given an introduction to the project.

1.1 Background

As part of the courses IE1204 and IE1205 at KTH, there is a section where students are required to do laboratory work. It involves using integrated circuits to do various assignments.

After the completion of the laboratory work, students are then required to hand in those lab kits. The lab kits are then re-used for the subsequent years students. Lab kits are the building blocks of this study.

To be able to use these integrated circuits it is necessary that they work properly and can be safely used by the students while all the complexities are abstracted away.

1.2 Problem Definition

It is of vital importance that the integrated circuits used for these labs work properly. In every lab kit, there are twenty integrated circuits and every pair of students has to have these. It is therefore a tedious process for both the students and course coordinator to make sure they work.

Those who work on this course have to test these components one by one which takes a lot of time and energy.

How to automate the testing of integrated circuits used in the student’s lab kits?

1.3 Purpose

The purpose of this study is to discuss and build an effective system that can test the integrated circuits of the student’s lab kits. This study can hopefully be beneficial to other institutions or complementary in other industries or sectors where testing already exists.

6

1.4 Goal

The goal of this study is to deliver a system that can test integrated circuits used in the courses IE1204 and IE1205 and to document the result in a technical report. This report will describe the process of making such a system and the requirements.

The following is what is presented in this study: - The development and implementation of testing lab kits - The presentation of the program for testing logic gates

1.5 Method

To do a proper degree project, it is crucial to have appropriate methods and methodologies. They help steer and plan the project in a way to achieve the desired outcome. Given this fact it is important to distinguish if the research or project is of a qualitative or a quantitative character. Quantitative research is about gathering and analyzing data to explain a phenomenon, whereas qualitative research is about understanding a phenomenon to create new theories and ideas. In this research qualitative method is used. [1, p. 3]

Research tasks can be achieved with the aid of diverse research methods. The empirical research method is one of those methods used in this project, and it gains knowledge by getting proofs based on evidence from experiments, observations, or experiences. From the observable evidence that is collected, data are analyzed with qualitative methods to explain the situation. [1, p. 2] ​

The empirical research method was relevant in this project because it was important to observe and test the integrated circuitry. Once an understanding had been established of the underlying mechanics then one could find a more efficient way to test the components.

Since the data collected in this research is through a qualitative method and the data is limited to truth tables and the output of the components their validity has been through induction. If there had been a large amount of data then the deduction would have been used. [1, p. 6] ​

1.6 Delimitations

Even though the aim of this project is to test all the integrated circuits in the lab kits, the testing of more complex integrated circuits such as , adders and inverters will not be presented due to time limitations and the complexity of testing such components. This thesis will solely focus on the development for testing logic gates.

7

1.7 Outline

The outline of this thesis consists of the following:

Chapter 2 presents fundamental background information ​

Chapter 3 presents descriptions and reasoning behind methods and scientific ​ methodologies used during the project

Chapter 4 details the development process ​

Chapter 5 presents and briefly describes the results of the project, which also discusses the ​ validity and reliability of the methods and results, before concluding the problem.

Chapter 6 presents the conclusions drawn from the project results and evaluations. ​

8

2 Theoretical Background

This chapter outlines a detailed presentation of the theoretical background of this thesis with all the essential information from diverse sources including literature and practical studies.

2.1 Analog and Digital Circuits

The difference between analog and digital circuits is that analog signals process signals that change constantly. Digital circuits however process signals that just contain two levels or states, logic “0” and logic “1”. ​ ​ ​ ​

A logic “1” represents a high voltage, 5 volts, which is referred to as a HIGH value, while a ​ ​ ​ ​ ​ logic “0” represents a low voltage, such as 0 volts or ground, and is commonly referred to ​ as a LOW value.[2] ​ ​ ​ 2.2 Logic Gates

The digital logic gate is the foundation upon which all digital electronic circuits and -based systems are constructed. This gate is an that carries out logical decisions depending on the kinds of signals which are provided as input values. There is usually more than one input but only one output.

A single logic gate function with multiple inputs can be made from combining individual gates or circuits with combinational and sequential types.

In digital logic design, only two voltage levels or states are allowed and these states are generally referred to as Logic “1” and Logic “0”, or HIGH and LOW, or TRUE and FALSE. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ These two states are represented in and standard truth tables by the binary digits of “1” and “0” respectively. ​ ​ ​ ​

9

2.2.1 AND Gate

“If both A and B are true, then Y is true” [3] ​ ​ The Boolean expression for a digital logic AND gate is of the following: ​ ​ Y = A × B (1)

The digital logic AND gate is constructed in a way so that only when all of the input signals ​ ​ are HIGH the output will also be HIGH. Conversely, the output of the AND gate will return a ​ ​ ​ ​ ​ ​ LOW only when any of its inputs are LOW. ​ ​ ​

10

2.2.2 OR Gate

“If either A or B is true, then Y is true” [4] ​ ​

The Boolean expression for a digital logic OR gate is of the following: ​ ​ Y = A + B (2)

When one of the inputs to the digital logic OR gate is HIGH its output will also be HIGH, no ​ ​ ​ ​ ​ ​ matter what the other input signals are. However if one wants to return a LOW value from ​ ​ the output all of its inputs has to be a LOW or a logical 0. ​ ​ ​ ​

11

2.2.3 NOT Gate

“If A is NOT true, then Y is true” [5] ​

The Boolean expression for a digital logic NOT gate is of the following: ​ ​ Y = A (3)

The digital logic NOT gate is the easiest to understand. It is constructed as an and ​ ​ will invert the input signal either from a LOW to a HIGH and vice versa. ​ ​ ​ ​

12

2.2.4 NAND Gate

“If both A and B are true, then Q is NOT true” [6] ​ ​

The Boolean expression for a digital logic NAND gate is of the following: ​ ​ Y = A × B (4)

To be able to understand the underlying mechanics of the logical NAND gate one has to be ​ ​ familiar with the AND gate and NOT gate first. ​ ​ ​ ​

The logical NAND gate works similarly to the AND gate only that the outputs are reversed. ​ ​ ​ ​ When all of the NAND gates inputs are HIGH or a logical 1 the output will be LOW. One ​ ​ ​ ​ ​ ​ ​ ​ might say it's the complementary form of the AND gate. ​ ​

13

2.2.5 NOR Gate

“If both A and B are NOT true, then Y is true” [7] ​ ​ The Boolean expression for a digital logic NOR gate is of the following: ​ ​ Y = A + B (5)

The digital logic NOR gate is built using a combination of the logic OR gate and the logic ​ ​ ​ ​ NOT gate. Similar to the NAND gate one can view it as a complementary or the reverse to ​ ​ ​ the logic OR gate. ​ ​

The output of the logic NOR gate is usually LOW because if any of its inputs are HIGH the ​ ​ ​ ​ ​ ​ output will be turned LOW. Only when both of the outputs are LOW or a logical 0 the gate ​ ​ ​ ​ ​ ​ will be a HIGH or logical 1. ​ ​ ​ ​

14

2.2.6 XOR Gate

The Boolean expression for a digital logic XOR gate is of the following: ​ ​ Y = (A ⊕ B) = A × B + A × B (6)

In previous sections we have seen that the digital AND, NAND and NOT gates can be used ​ ​ ​ ​ ​ ​ to construct other logic gates such as the NAND and NOR gates. ​ ​ ​ ​

There are also two types of hybrid logic gates that are constructed by using a combination of other logic gates. These are the XOR and XNOR gate and they are used for building ​ ​ ​ ​ arithmetic logic circuits, computational logic comparators and error detection circuits.

For the XOR gate the output will only be HIGH or the equivalent to a logical 1 when its two ​ ​ ​ ​ ​ ​ inputs are different to each other. For instance when one input is HIGH and the other is ​ ​ LOW the output will always be a HIGH or a logical 1. But when its inputs are the same the ​ ​ ​ ​ ​ outcome will be always a LOW or a logical 0.[8] ​ ​ ​ ​ ​

15

2.2.7 Summary

Tabel 1 Two-input logic gates with its corresponding truth table summarized

Inputs Truth Table Outputs For Each Gate B A AND NAND OR NOR EX-OR 0 0 0 1 0 1 0 0 1 0 1 1 0 1 1 0 0 1 1 0 1 1 1 1 0 1 0 0

Table 2 Truth Table of NOT Gate

Inputs Truth Table Output

A NOT

0 1

1 0

16

3 Method

3.1 Work Process

One of the things that were paramount at the beginning of the project was to understand how integrated circuits worked. Therefore the previous labs that the students had been working on where to some help.

Arduino programming language is used in the labs for programming the circuits. Since I had not been familiar with this language before it was necessary to gain the basic knowledge of the underlying language. It was necessary to understand how one communicates with the breadboard in Arduino. Loops, arrays, and calling functions are things that I looked at as well.

It is also important to understand which is input and output for integrated circuits because the connections are paramount to write programs. Otherwise, one might burn or damage the circuits.

3.2 Data collection

Amongst the different kinds of data collection methods available, the case study method is used as it makes it possible to empirically investigate either single or more events to attain the desired result. Qualitative methods use small sample sizes of data to get the desired results.

The data collected in this research is from the truth tables of the different kinds of integrated circuits. It was essential to see how the different kinds of circuits behaved because the test system made in Arduino could check if the output of the program corresponded with the output of the logic gates. The data from the output of the program was also collected for the analysis stage.

3.3 Data analysis

When one collects data for making a system, the need for analysis is crucial. Data analysis methods are one aid in those situations. One inspects, cleans, transforms, and models data.

So long as the initial hypothesis has not been disproved with a validated theory, iterations are continuously carried out with analytic induction and grounded theory until they are disproved.

All the data analysis in this project goes through the Arduino Uno and the Arduino program. The logic behind the program is that the Arduino Uno processes the signals from the logic gates and if the output of the logic gates corresponds with the truth table value belonging to it, then that would mean the logic gate works.

17

3.4 Data Validity

To ensure that the project being carried out has an acceptable degree of quality, it needs to be validated and verified. The discussion of validity, dependability, confirmability, transferability and ethics are essential when one carries out a qualitative research method with an inductive approach.

Validity makes sure the rules one has set up for the research are followed. Respondents can confirm this by showing that the results are correctly understood.

Dependability corresponds to reliability and is the process of judging the correctness in conclusions, using auditing.

Confirmability tells the other readers that research has been conducted in good faith without any personal biases.

With transferability, it means that one creates an in-depth description that can act as a database for other researchers.[1, p. 7] ​

The methods, implementations and results that are presented in this thesis are ways to confirm the thesis. The reader can get the same results by replicating or developing the project further.

First, the validity of the result will be carried through an inspection phase to ensure that all the connections are correct. Secondly, the truth table of the corresponding logic gate will be compared to the output of the program. There will also be led lights connected to the breadboard and the led lights will be turned on in accordance with the values of the truth table.

18

4 Implementation

4.1 Hardware Design

To have an understanding of the hardware and to present the workflow and processes, it was crucial to have a bird’s-eye view and the block diagram is an example of a functional representation of that view presented in graphs.

The blocks presented in the picture above are objects in the hardware and the arrows show how they are connected. As one can see the devices being tested are connected to the breadboard and in turn, are connected to the Arduino which communicates with the software. The integrated circuits that are shown in the picture are tested IC’s for this project

19

4.2 Software Design

At the heart of the software that is for testing integrated circuits lies in how to extract the signals coming out the logic gates and comparing them to the corresponding truth table. The Arduino program will firstly send output signals from the Arduino to the input of the logic gates, secondly, it will read the output value of the logic gates into a variable. That variable will then be stored in different positions depending on which input signals the logic has.

After it has calculated all the values for the different positions they are added into a value. This value is then compared with different truth table values. If the program finds the right value for the logic gate the program will then print the name of the logic gate it has found, if not the program will show an error message.

To give a more detailed look at how the truth table value is calculated:

● The first iterations result will be placed in position 0 (value 1) ● The second iterations result will be placed in position 1 (value 2) ● The third iterations result will be placed in position 2 (value 4) ● The forth iterations result will be placed in position 3 (value 8) ● This way we create a variable for the case statement.

For example, this is the truth table of a NAND gate:

The Y column of the truth table will be converted into the number, in this case, 7 which is then used in a case statement.

20

21

Figures 9 and 10 outline a comprehensive view of the functionality developed and if one wants to dive deeper there is the full code at the appendix section with commentary.

As one can see that not all integrated circuits in the student lab kit were tested in this project. However, if one wants to continue with this project it is important to understand what type of integrated circuitry one wants to test. This project tested two-input logic gates such as NAND, AND etc, but if one wants to test three and four-input logic gates it is vital to understand its truth table. For instance, if one has three and four input logic gates one will have 8 and 16 combinations respectively. This shows that case statements in the code have to extend and include these outputs. However if one can find a more efficient solution it will be less of a burden.

22

5 Results

In this chapter, results from the measured data from the logic gates connected to the Arduino are presented. Then the economical side of the project will be presented and a discussion about the benefits of testing.

5.1 Results from the Arduino

When testing an with an Arduino Uno, one has to first connect it to a breadboard, and use jumper wires for connecting both the Arduino Uno to the breadboard properly and connecting the integrated circuit. It is important to know the right way GND and VCC are connected to avoid damaging the integrated circuit and thereby preventing testing as a result. Fig. 11 shows a more illustrative explanation of testing a NAND Gate.

23

Fig. 12 is illustrating the testing of a faulty NAND gate and Fig. 13 is illustrating the ​ ​ ​ successful attempt at testing all four NAND gates inside an integrated circuit.

This project tested the integrated circuits: 74HC00, 74HC02, 74HC08, 74HC32, 74HC86. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ For the reader not familiar with integrated circuits in the lab kits, this means the logic gates NAND, NOR, AND, OR, and XOR. The code in the appendix can be applied to all of these ​ ​ ​ ​ ​ ​ ​ ​ ​ integrated circuits but one has to be mindful of how they are connected. In chapter 2 the reader became familiar with how all gates are designed and connected inside an integrated circuit.

In table 3 testing four IC’s which is the scope of this project took about half an hour. First by wiring for one IC and then rewiring for another. For the whole lab kit assuming one has developed the right code, will take roughly 2.5 hours. Mind you, the calculations are not counting with a , as that will take much faster. To the right column one can see how much replacing an integrated circuit costs. If one decides to throw all the components away and buy new ones.

24

In table 4 for each IC the cost is 3 kr and an hourly wage for a student is 150 kr. To the right ​ ​ side of the table one can see how much the cost will be for paying a student packing the lab kits. Mind you, this is only for one student alone, as the cost will be lower if several students pack lab kits.

Further discussion and reflections on the benefits of testing versus buying new components will be presented in 5.4

Table 3 Calculation of Time For Testing Integrated Circuits

Integrated Circuit(s) Time (Hours) Cost (kr)

5 0.5 15

20 2 60

2000 200 6000

Table 4 Time Spent Packing Lab Kits

Packing (lab kits) Time (Minutes) Payment for Student (kr)

1 5 12,50

50 250 625

100 500 1250

5.2 Reliability Analysis

Failures and faults are similar and common defects that can occur in logical circuits. A logical circuit is said to have failed if it deviates from its expected or specified behavior whereas it is said to have developed a fault if it has any physical internal or external defect.[9, p. 12] ​

● Is the data coming from the logic gates to the Arduino reliable? ● How can one be certain something isn't wrong with what the program is showing?

These are hard questions to answer but there are a few landmarks that can consider indicating one has reliable data. The first is that the case statement in the Arduino

25

code compares the summed value of the different kinds of truth tables. This means that the printed statement shows that all four logic gates inside the circuit are connected and working. If not then the code prints an error message that something is wrong.

The second landmark is to use something called an Integrated circuit tester, there are many varieties of them but I had no hands-on experience.

5.3 Validity Analysis

How can one validate one's results? There are several points one has to keep in mind to know if the data is valid or not. First is that one has to be certain the connections are correct and the wiring is correct as well. Connecting LEDs to the power rails on the breadboard is a simple way of checking one has power coming from the Arduino to the breadboard.

Secondly, it is important to debug the program that checks the truth tables. There was this incident early in the project where the program didn’t find the gates. It turned out to be that the Arduino program calculated the value of the truth tables wrongly, even though all connections were right.

The third option is to use an integrated circuit device tester. As I wrote about it in 5.2 I had never accessed such a tool. If one has an integrated circuit device and the tester presented in the project one can be certain data are valid or not coming out of the logic gates

5.4 Discussion

If one can imagine an ideal scenario where one student is capable of testing five hundred lab kits for every hour then it would take him four hours to complete the task of testing. Teachers then have to pay him six hundred kr as a result for his work. This is the process one has to imagine there is no printed circuit board involved and no testing system.

Without a printed circuit board, one has to first connect an integrated circuit to a breadboard with jumper wires to test it and then to rewire to test another. This is a tedious project and it will take roughly two hours to test all integrated circuits in the lab kits. In this scenario one has a testing system and not a printed circuit board.

With a PCB and a testing system the time for testing all lab kits could be reduced to one hour. If one has all the integrated circuits connected at the same time, which takes the majority of the time for testing, then it is only the matter of running the program and waiting for the results.

Questions arose at the beginning of the project that was related to the cost and benefits of testing integrated circuits versus not testing and throwing the components away.

The first alternative is to buy new lab kits and throw away the old ones. This is equivalent to the cost of a hundred lab kits which is 6 000 kr and packing them which takes about 8 hours. Depending on how much KTH has a budget for buying new electronics every year, and how many faulty components there are overall after students’ lab sessions have ended it might be more effective to throw away components and buy new ones. But then again one has to test the components inside the lab kit to know the scope of the problem.

26

The second alternative is to return the lab kits without testing them. If the components are not tested then students are oblivious to which component works properly and which one does not. Imagine then being a new student to the course and not having enough experience with programming to know how to test them. It would be costly for both the students and teachers to first teach a student on how to test them without any automated system and then to pay them for testing lab kits after their laboratory work is done.

The third alternative is returning the kits after testing. Both the students and teacher can be rest assured which components are fully working and which ones are not. Also one can be sure at which limit the components will fail to work. As we can see, returning the kits after testing is the most cost-effective and less costly way to go.

27

6 Conclusions and Future work

During this degree project, the development of a program that automatically tests the connected components.This chapter presents the discussion and analysis of the results and also presents and future improvement opportunities.

6.1 Conclusions

In the world of electronics, there is always this race for the latest and greatest. Companies in the technology space are constantly optimizing their systems and making product innovations that exceed their previous versions. There is then the pending question of what to do with obsolete electronics. Can we say testing of electronic components is a good method for reducing electronic waste?

In my opinion, all institutions that use electronic components could benefit from testing their equipment or components as it significantly reduces the cost of time and financial resources spent in checking for malfunctioned components.

Some of the major factors that can affect the efficient testing of electronic components institutions or companies can be dependent on the available financial resources. For instance, universities could benefit from testing their equipment before handing them out to students. For larger companies, there is the issue of competition with other large companies and being outcompeted for not delivering the latest technologies that can afford to replace their electronics. These companies can benefit from testing not out of an economical issue rather for identifying what tools are broken so nothing can go wrong during the manufacturing of new products.

The lab kit consisted of twenty integrated circuits to be tested. The goal of the project was to create programs that could test all integrated circuits, make a printed circuit board (PCB) in which all the different types of logic gates could be connected and tested at the same time but due to the lack of time and circumstances beyond my control, only the logic gates have been tested here.

6.2 Limitations

The goal of the project was to be able to make a system that would test all the components in the student’s lab kits. Unfortunately, it was very hard to accomplish due to a lack of programming skills. It wasn’t that the concepts of the flip or multiplexers were hard to understand but implementing the testing of those in Arduino were challenging.

28

6.3 Future work

The future work on this project would be to understand the rest of the integrated circuits. This means for more complex circuits like multiplexers, decoders, and adders it is important to first figure out how many inputs and outputs there are. This will give an understanding of how many combinations there are for the underlying truth table.

6.4 Reflections

This project helps reduce the time spent testing the integrated circuits in the lab kits and minimize the cost of having to buy new components every year. It helps with having an environmentally healthy mindset and to be effective. If one can detect faults in systems early and stop them from happening one is very likely to make better progress as a company or institution. Overall the concept of automating the testing of electronics is very useful.

29

References [1] A. Håkansson, “Portal of Research Methods and Methodologies for Research Projects and Degree Projects,” Comput. Eng., p. 7, 2013. ​ ​ [2] “Digital Logic Gate Tutorial - Basic Logic Gates,” Basic Electronics Tutorials, Aug. 20, ​ ​ 2013. https://www.electronics-tutorials.ws/logic/logic_1.html (accessed Jun. 14, 2020). [3] “Logic AND Gate Tutorial with the Logic AND Gate Truth Table,” Basic Electronics ​ Tutorials, Aug. 20, 2013. https://www.electronics-tutorials.ws/logic/logic_2.html ​ (accessed Jun. 14, 2020). [4] “Logic OR Gate Tutorial with Logic OR Gate Truth Table,” Basic Electronics Tutorials, ​ ​ Aug. 20, 2013. https://www.electronics-tutorials.ws/logic/logic_3.html (accessed Jun. 14, 2020). [5] “Logic NOT Gate Tutorial with Logic NOT Gate Truth Table,” Basic Electronics Tutorials, ​ ​ Aug. 20, 2013. https://www.electronics-tutorials.ws/logic/logic_4.html (accessed Jun. 14, 2020). [6] “Logic NAND Gate Tutorial with Logic NAND Gate Truth Table,” Basic Electronics ​ Tutorials, Aug. 21, 2013. https://www.electronics-tutorials.ws/logic/logic_5.html ​ (accessed Jun. 14, 2020). [7] “Logic NOR Gate Tutorial with Logic NOR Gate Truth Table,” Basic Electronics Tutorials, ​ ​ Aug. 21, 2013. https://www.electronics-tutorials.ws/logic/logic_6.html (accessed Jun. 14, 2020). [8] “Exclusive-OR Gate Tutorial with Ex-OR Gate Truth Table,” Basic Electronics Tutorials, ​ ​ Aug. 21, 2013. https://www.electronics-tutorials.ws/logic/logic_7.html (accessed Jun. 22, 2020). [9] P. K. Lala, “An Introduction to Logic Circuit Testing,” Synth. Lect. Digit. Circuits Syst., ​ ​ vol. 3, no. 1, pp. 1–100, Jan. 2008, doi: 10.2200/S00149ED1V01Y200808DCS017.

30

Appendix // Declaring variables int truthTable00; int truthTable01; int truthTable10; int truthTable11; int truthValue1; int truthValue2; int truthValue3; int truthValue4; int x, y, z, w;

// Initializing variables int inputPin1 = 2; int inputPin2 = 3; int inputPin3 = 4; int inputPin4 = 5; int outputPin1 = 6; int outputPin2 = 7; int led1 = 8; int led2 = 9; int led3 = 10; int led4 = 11; int ledError = 13; int Result = 0;

/* Void setup declares pins as Input/Output and initializes the serial monitor */ void setup() { pinMode(inputPin1, INPUT); pinMode(inputPin2, INPUT); pinMode(inputPin3, INPUT); pinMode(inputPin4, INPUT);

pinMode(outputPin1, OUTPUT); pinMode(outputPin2, OUTPUT);

pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT);

31

pinMode(ledError, OUTPUT);

Serial.begin(9600);

}

/* The loop function calls truth_Value function and returns outputs from logic gates to sum the values and store them in the truthValue variables. */ void loop() { truth_Value(false,false); truthValue1 = truthValue1 + (x*1); truthValue2 = truthValue2 + (y*1); truthValue3 = truthValue3 + (z*1); truthValue4 = truthValue4 + (w*1); truthTable00 = x; digitalWrite(led1, truthTable00); // Write the output of the logic gate to the LED.

truth_Value(false,true); truthValue1 = truthValue1 + (x*2); truthValue2 = truthValue2 + (y*2); truthValue3 = truthValue3 + (z*2); truthValue4 = truthValue4 + (w*2); truthTable01 = x; digitalWrite(led1, truthTable01);

truth_Value(true,false); truthValue1 = truthValue1 + (x*4); truthValue2 = truthValue2 + (y*4); truthValue3 = truthValue3 + (z*4); truthValue4 = truthValue4 + (w*4); truthTable10 = x; digitalWrite(led1, truthTable10);

truth_Value(true,true); truthValue1 = truthValue1 + (x*8); truthValue2 = truthValue2 + (y*8); truthValue3 = truthValue3 + (z*8); truthValue4 = truthValue4 + (w*8); truthTable11 = x; digitalWrite(led1, truthTable11);

/* The if statement compares the truthValues from all four logic gates and if they are the same it will then be stored in the variable Result. If not Result will be zero. */

32

if((truthValue1 == truthValue2) && (truthValue1 == truthValue3) && (truthValue1 == truthValue4)){ Result = truthValue1; }else{ Result = 0; }

/* The switch case compares the Result value and prints the outcomes as well as turns on the corresponding LEDs. */ switch(Result){ case 6: Serial.println("This is an XOR gate."); digitalWrite(ledError, LOW); break;

case 7: Serial.println("This is an NAND gate."); digitalWrite(ledError, LOW); break;

case 8: Serial.println("This is an AND gate."); digitalWrite(ledError, LOW); break;

case 14: Serial.println("This is an OR gate."); digitalWrite(ledError, LOW); break;

default: Serial.println("ERROR: NO GATE IS FOUND."); digitalWrite(ledError, HIGH); }

// Reset the truth table values delay(1000); truthValue1 = 0; truthValue2 = 0; truthValue3 = 0; truthValue4 = 0; }

/* The Truth_Value function will go through the truth table by sending signals from the Arduino Uno to the inputs of the logic gate. The output will then be read and stored in variables x, y, z, and w. */

33

void truth_Value(int output1, int output2){ digitalWrite(outputPin1, output1); digitalWrite(outputPin2, output2); delay(500); x = digitalRead(inputPin1); y = digitalRead(inputPin2); z = digitalRead(inputPin3); w = digitalRead(inputPin4);

}

34

TRITA-EECS-EX-2020:698

www.kth.se