Sep 2, 2015 - Figure 4.23: Voltage sensing card simulation circuit (DC) . ..... at 10bit resolution, which provides a scale of 0 to 1023. More advanced ..... 230V AC is applied to the primary side of the transformer and the voltage obtained ...... The circuit used for displaying saw tooth is the same as that of the pulse generator.
DESIGN AND CONSTRUCTION OF ARDUINO BASED OSCILLOSCOPE/LOGIC ANALYSER
A PROJECT
BY
OSISIOGU, UKACHI OLUWASEUN NAU/2010364149
SUBMITTED IN PARTIAL FULFILMENT FOR THE AWARD OF BACHELOR OF ENGINEERING (B.ENG), IN ELECTRONIC AND COMPUTER ENGINEERING, NNAMDI AZIKIWE UNIVERSITY, AWKA, NIGERIA
SEPTEMBER, 2015
i
APPROVAL This is to certify that this project carried out by OSISIOGU, UKACHI OLUWASEUN (2010364149) have been supervised and approved as meeting the requirement for the award of the degree of Bachelor of Engineering (B.Eng.) in Electronic and Computer Engineering, Nnamdi Azikiwe University, Awka, Nigeria.
……………………………
………………………
Engr. Prof. (Mrs.) C.C. Okezie
Date
(Supervisor)
……………………………
………………………
Engr. Prof. Mrs. C.C Okezie
Date
(HOD)
……………………………
……………………… Date
(External Examiner)
ii
DEDICATION I dedicate this project work to Almighty God for His grace and infinite love towards me and to my darling parents for their encouragement morally, academically and financially.
iii
ACKNOWLEDGEMENT My gratitude goes to the H.O.D Engr. Prof (Mrs) C.C. Okezie and my wonderful lecturers; Engr. Prof. V.E Idigio, Engr. Dr. Ken Akpado, Engr. Dr. Ohaneme, Engr. Dr. A.C.O Azubogu, Engr. Dr. Ifeagwu, Engr. Dr.Tony Isizoh, Engr. Dr. T.L Alumuna, Engr. Dr. (Mrs) S.U Nnebe, Engr. Obinna Oguejiofor, Engr. Ndum, Engr. Steve Ufuorah, Engr. Ezeagwu, Engr. Okorogu, Engr. Ajakor U.C and Mr. Gerald Nwalozie and who has impacted a lot of knowledge in me turning me into the man that I am today. My profound gratitude goes to my parents Prof. & Mrs. U.A. Osisiogu for their support, care and prayers throughout my stay in the university as an undergraduate. I am also thankful to God for my siblings Onyekachi, Tochukwu and Ayo – Oluwa for their love and encouragement.
iv
ABSTRACT In the world of electronics engineers, students and hobbyists (target group) are somewhat limited on the kind of insight that is needed in this dynamic world of electronics where technology is always advancing by the hour. The purpose of this project is for the reader to build an equipment that would help them in gaining more insight into the electronic equipment they come across. The Arduino based oscilloscope is being built to have the capacity to plot up to six waveforms, but comes with a 10bit resolution and has a bandwidth of 5 KHz. The methodology applied in implementing this design is the Universal design methodology. After reading this article the reader is to be equipped with every necessary information needed to make an oscilloscope and then begin to have more insight into most circuits they come across.
v
Table of Contents TITLE PAGE ........................................................................................................ i APPROVAL ........................................................................................................ ii DEDICATION ....................................................................................................iii ACKNOWLEDGEMENT ................................................................................... iv ABSTRACT ......................................................................................................... v Table of Contents ................................................................................................ vi List of Figures ...................................................................................................... x List of Tables ..................................................................................................... xii CHAPTER ONE .................................................................................................. 1 1.
INTRODUCTION ........................................................................................ 1 1.1 Background of Project.............................................................................. 1 1.2 Problem Statement ................................................................................... 2 1.3 Aim and Objectives of the Project .............................................................. 3 1.4 Significance of the Project ....................................................................... 4 1.5 The Scope of the Project .......................................................................... 5 1.6 Project Outline ......................................................................................... 5
CHAPTER TWO ................................................................................................. 7 vi
2. LITERATURE REVIEW ................................................................................. 7 2.1
Practical Arduino Approach .................................................................... 8
2.2 GRIET Approach ..................................................................................... 9 2.3 MATLAB Approach ................................................................................ 9 2.4 GIRINO Approach ................................................................................. 10 2.5 Other Microcontrollers Approach........................................................... 10 2.6 LCD Approach ....................................................................................... 10 CHAPTER THREE ............................................................................................ 12 METHODOLOGY, SYSTEM DESIGN AND ANALYSIS ............................... 12 3.1 Methodology .......................................................................................... 12 The Universal Design Methodology (UDM)............................................... 12 3.1.1
Concept ......................................................................................... 13
3.1.2
Specifications................................................................................ 14
3.1.3
Choosing Technology and Tools ................................................... 14
3.1.4
Schematic Design ......................................................................... 15
3.1.5
Simulation..................................................................................... 15
3.1.6
Design Review .............................................................................. 15
3.1.7
Implementation ............................................................................. 16
3.1.8
Testing .......................................................................................... 16
vii
3.1.9
Final Product................................................................................. 16
3.2 System Design and Analysis .................................................................. 16 3.2.1
Hardware Subsystem .................................................................... 18
3.2.2
The Software Subsystem ............................................................... 48
CHAPTER FOUR .............................................................................................. 57 4. SYSTEM IMPLEMENTATION, TESTS AND RESULTS ........................... 57 4.1 SYSTEM IMPLEMENTATION .............................................................. 57 4.1.1
Hardware Subsystem Implementation ........................................... 57
4.1.2 SOFTWRE SUBSYTEM IMPLEMENTATION ............................... 62 4.2 SYSTEM TEST AND RESULTS ............................................................ 66 4.2.1 Hardware subsystem test.................................................................... 66 4.2.2 Test for the Arduino base oscilloscope system ................................... 74 4.3 System Integration .................................................................................... 80 4.4 Performance Evaluation ......................................................................... 81 4.5 Packaging the system ............................................................................. 81 4.6 Bill of Engineering Measurement and Evaluation (BEME). ................... 82 CHAPTER FIVE ................................................................................................ 85 CONCLUSION AND RECOMMENDATION .................................................. 85 5.1 Conclusion................................................................................................ 85
viii
5.2 Recommendations .................................................................................... 87 REFERENCES ................................................................................................... 89 APPENDIX A .................................................................................................... 92 APPENDIX B .................................................................................................... 93 APPENDIX C .................................................................................................... 95
ix
List of Figures Figure 3.1: Flow Chart of the UDM process ....................................................... 13 Figure 32: Block diagram of the hardware subsystem ........................................ 18 Figure 3.3: Diagram of the voltage divider circuit .............................................. 20 : Figure 3.4: Block diagram of the voltage sensing card. .................................... 21 Figure 3.5: Block diagram of HCPL7800A ....................................................... 23 Figure 3.6: High voltage measurement with conversion to an isolated ground reference input (Voltage sensing card schematics). ............................................ 25 Figure 3.7: 5V power supply circuit ................................................................... 28 Figure 3.8: Dual rail 15V power supply circuit. .................................................. 29 Figure 3.9: Diagram of the Arduino Board ......................................................... 32 Figure 3.10: An illustration of the Arduino IDE ................................................. 38 Figure 3.11: An illustration on how sampling frequency works. ......................... 41 Figure 3.12: Fivebit SARADC based on charge redistribution ......................... 43 Figure 3.13: Block Diagram of Software Subsystem .......................................... 48 Figure 3.14: Flowchart of the algorithm of the code used in plotting .................. 50 Figure 3.15: MegunoLink Pro Software ............................................................. 53 Figure 3.16: An example of a plot using MegunoLink........................................ 55 Figure 4.17: PCB on eagle.................................................................................. 60
x
Figure 4.18: Implemented PCB .......................................................................... 61 Figure 4.19: Arduino IDE programming ............................................................ 63 Figure 4.20: Time plot example .......................................................................... 64 Figure 4.21: Time plot features........................................................................... 66 Figure 4.22: The voltage divider schematics....................................................... 67 Figure 4.23: Voltage sensing card simulation circuit (DC) ................................. 69 Figure 4.24: Simulation results of the voltage sensing card (DC) shown with an oscilloscope. ....................................................................................................... 70 Figure 4.25: The simulation circuit for an AC input. .......................................... 71 Figure 4.26: Arduino oscilloscope potentiometer test. ........................................ 75 Figure 4.27: Squarewave test on the Arduino Oscilloscope ................................ 76 Figure 4.28: Squarewave test on the simulation software ................................... 76 Figure 4.29: Sawtooth pulse test on the simulation software .............................. 77 Figure 4.30: Sawtooth pulse test on the Arduino oscilloscope ............................ 77 Figure 4.31: Test for the plot of two input waveforms. ....................................... 78 Figure 4.32: Test for plotting six waveforms ...................................................... 79 Figure 4.33: Plotting waveforms and their operations........................................ 80
xi
List of Tables Table 3.1: The Arduino Uno specifications ........................................................ 31 Table 4.2: Results gotten from the calculations .................................................. 68 Table 4.3: The results obtained from the simulations.......................................... 73 Table 4.4: Possible results to be obtained from the board ................................... 74 Table 4.5: BEME ............................................................................................... 82
xii
CHAPTER ONE 1. INTRODUCTION 1.1 Background of Project One of the major needs of any engineer is the capacity for such person to have every available and vital insight into the system that is to be developed as it undergoes the process of analysis needed in order for an efficient system to be produced. In the context of this project, an electronics engineer, students, hobbyist are being considered to have a design in their minds and in order to build an efficient electronic system it essential that they have every vital information needed to create an efficient system. It is therefore frustrating when such persons are not able have this vital information and thus cannot be able to produce a system (circuit) to its maximum efficiency. Most electronic engineers, students and hobbyists find it difficult to be able to purchase the necessary equipment needed to give them the vital information they need when they develop their circuits, probably due to lack of funds, or more still these equipment may be difficult to obtain, especially in developing countries. Measuring instruments like the multimeter, the oscilloscope and others are essential in the field of electronics engineering. It is important to say here that the need for measuring instruments improves accuracy and also gives the engineer the understanding needed to create an efficient system. Without measurements we will 1
not be able to live in this modern world [1]. The system discussed in this report will help engineers to make vital measurements as circuits are being designed. 1.2 Problem Statement The vital information that is needed can be extracted with use of measuring instruments. In this report the oscilloscope/logic analyser is being considered. An oscilloscope/logic analyser has the capacity to make a system designer to see into the circuit. It gives the system designer the ability to extract vital information like the amplitude of the signal in real time, the frequency of the signal, the spectral density and other necessary information. With the above mentioned information that an oscilloscope can give to a designer it is therefore expedient that every circuit designer should be able to have such equipment so that such a person can have insight into what is being developed, and therefore be able to create more efficient systems that will perform optimally. However, that is not the case because such a measuring instrument (oscilloscope) is quite expensive. Most oscilloscopes have a price range of 30,000 to 100,000 NGN [2] and this has resulted to making the purchase of such equipment difficult for students, hobbyists, and even some institutions. In additions most of these oscilloscopes can only show two waveforms at a time and some of them do not give designers the liberty to save the image or waveform being produced by a circuit on a PC (Personal Computer) so that it can be analysed at the convenience of the electronic engineer.
2
In order to solve this problem the creation of a cheaper oscilloscope/logic analyser will be vital. The Arduino based oscilloscope/logic analyser will be helpful. The Arduino based oscilloscope has the benefits of being cheap, can save waveforms on the PC, and can also show more than two waveforms of which most oscilloscopes do not have the capacity to do. Though the possession of a vital measuring instrument like the oscilloscope/logic analyser is beneficial, it can be difficult to obtain due to cost related issues. However, the Arduino based oscilloscope/logic analyser which is relatively cheap and can also perform some additional functionality that most oscilloscopes/logic analysers do not have will be helpful in tackling this problem [3]. 1.3 Aim and Objectives of the Project This project is aimed at designing and constructing an effective hardware and software needed for the functionality of the Arduino based oscilloscope/logic analyser. Particularly, the objectives that must be accomplished in order to produce the system (Arduino based oscilloscope/logic analyser) are To construct a voltage sensing card that will read values between 0340 V peak values for AC and that same amount for DC and still be able to give an output of 5 V To program the Arduino to use its Analog Digital Converter (ADC) to read values from the analog inputs pins convert these signals and then send them to the PC for plotting 3
Install the software called MegunoLink Pro so that the PC in use can plot the data received from the Arduino Uno. Package the system in such a way that it would be useful and seen as an oscilloscope. 1.4
Significance of the Project
The significance of this project is the potential it has to show that an Arduino based oscilloscope can be as useful as most oscilloscopes. The system will be able to perform like the conventional oscilloscope and then be useful in the electronics lab and also as a personally owned instrument. The other papers related to this field of study to the extent of my knowledge were not able to give a welldetailed report on this project. This report will be able to deal with such challenge so most people will be able to build a similar device without doing much additional research on how to develop the device. With the above mentioned significance in mind most hobbyist, students and engineers can easily build this device, save cost and use it for their own private use and also for commercial purposes. Various academic and research institutions that may not be able to afford the conventional oscilloscope can also use the knowledge contained in this report to provide such measuring instrument for their electronics laboratory.
4
1.5
The Scope of the Project
In this project an oscilloscope/logic analyser based on Arduino will be built. The Arduino is programmed and interfaced with a PC that will enable it to plot graphs for outputs from the serial monitor of the Arduino. The Arduino will be programmed in such a way that it displays the output waveforms as the oscilloscope does. The voltage is stepped down at the initial stage using a potential divider circuit such that voltage ranges from between 05 Volts. This is then given as input to the Arduino and the output is noted from the serial monitor. Arduino gives values only, so it is interfaced with the software called “MegunoLink” and graphs are plotted for the outputs from Arduino. Hence, Arduino works as an oscilloscope when analog inputs are given and works as a logic analyser for digital inputs. Arduino can display 6 analog and 8 digital waves which cannot be done by many oscilloscopes. Nevertheless, this system has some limitations. The Arduino can only provide a 10bit resolution and can measure frequencies for only 5 KHz. In addition, this system will operate at a 10bit resolution in the region of 5 KHz depending on the channels being monitored. 1.6
Project Outline
To ensure clarity as well as a detailed understanding of this report, this report is presented in six chapters. Chapter one presents the general introduction, problem statement, objectives of the project, the significance of study and the scope of this report. Chapter two presents the literature review, this chapter covers the 5
explanation of the Arduino hardware and the commonly used and related theory used in the design of the Arduino based oscilloscope/logic analyser and the software MegunoLink. Chapter three presents the methodology and the manner of approach used in the project in order to actualize the objective of this project. Chapter four deals with the system analysis and design of the project, chapter five deals with simulation results and system evaluation and chapter six deals with the conclusions and recommendations for future work. The other relevant information is put in the appendices.
6
CHAPTER TWO 2. LITERATURE REVIEW In the field of Engineering the need for accurate measurement for the analysis of circuits is vital and therefore a lot of work has been undertaken to ensure that accurate measurements are being made in order to aid the analysis of circuits (systems) Therefore, the oscilloscope has found its way to be one of the most important tools used in the field of Electronics Engineering, and has helped in numerous ways in the analysis of analog and digital signals. However, in order to gain better understanding of these signals the oscilloscope has evolved. However, this evolution in the oscilloscope world has made the affordability of the instrument reduce to an extent because the evolution came with better functionalities than the older ones but with a huge price. In order to solve this problem, engineers began to look for ways to still make these oscilloscopes cheap enough but still be able to have the functionalities of the oscilloscopes. Therefore the digital scope was introduced into the market. These type of oscilloscope will be able to measure the measured signal but this time will be interfaced with a PC. Conventional oscilloscopes come with their own screens but these digital scopes uses the screen and the processing power of the PC to plot the desired graphs. Nevertheless this equipment was still expensive. 7
With the introduction of Arduino, Raspberry Pi and so on. It became easier for hobbyist, students, and designers to be able to build their own oscilloscopes. At a very cheap rate and thus in order to create an efficient system, though with very limited specifications, the following research was undertaken. 2.1
Practical Arduino Approach
In this project, an Arduino to capture multiple input values and pass them via the USB connection to a host computer running a program that deciphers the values and displays them onscreen. They said because the Arduino itself is not providing any particular intelligence and simply passes on any values it reads, the project is very flexible and the behaviour of the system can be changed simply by altering the software that runs on your computer. This opens up a wide range of possibilities for using the same basic hardware to process and visualize analog data, parallel digital
data,
and
serial
digital
data.
In this project a visualisation program was used. This visualisation program was written Processing. They defined Processing as a sister project to Arduino that is designed to allow rapid development of visual programs in the same way that Arduino allows rapid development of physical programs. Processing runs on Windows, Linux, and Mac OS X. However, this simple approach has some major limitations in terms of both sample rate and resolution, because of this stipulated that the Arduinobased system cannot rival a professionalgrade oscilloscope or logic analyzer. They said that the analog inputs on an Arduino operate by default at 10bit resolution, which provides a scale of 0 to 1023. More advanced ADCs 8
provide 12bit resolution or higher. The Arduino analog inputs also take around 100 microseconds to take a reading in their default configuration, limiting the number of samples it can take per second and restricting it to much lower frequencies than a more advanced ADC. The result is a system that will operate quite well at 10bit resolution at up to around 5 KHz, depending on how many channels you are monitoring. It was also stated that though the Arduino based oscilloscope may not be a good specification, it is certainly better than nothing if you cannot afford a professional oscilloscope or logic analyser [4]. 2.2
GRIET Approach
A set of people also worked on building an Arduinobased oscilloscope here they were able to come up a software known as MegunoLink. This particular software has the ability to display this output values in realtime. In their work they were able to make the Arduinobased oscilloscope have 6 inputs. The issue remains unsolved is how this Arduinobased oscilloscope can be used in the measurement of analog signals. In their work they produced a sensing voltage card that can be able to reduce the input signal to be measured into a form that the input pins in the Arduino can utilise. They were also able to give a detailed explanation on the theory and analysis of the system created [5]. 2.3
MATLAB Approach
Also, a set of people also did a similar work on this but they used MATLAB to plot the graphs that the waveforms created with respect to time. The limitations to this particular work was that MATLAB could not provide information on a real time 9
basis. The advantage of using MATLAB can be derived from the fact since MATLAB is gradually becoming popular, so the codes utilised are relatively easy to understand when compared to Processing. Also the report given on this project was not well detailed [6]. 2.4
GIRINO Approach
In 2007 another research was carried out on how to make an Arduino based oscilloscope that would provide a faster sampling rate. In doing this the prescaler of the Arduino needed to be changed and thus resulting to lower accuracy. Though it did fit the specifications of the designer [7]. 2.5
Other Microcontrollers Approach
In this approach engineers have designed systems that can be able to build systems similar to the Arduino based oscilloscope with other micro controllers such as PIC (Programmable interrupt Controller) and the Python microcontroller. [8] 2.6
LCD Approach
In this project the Arduino will be interfaced with the PC however, there are those who used the LCD to plot the data received from the Arduino. The setback here is that the data plotted cannot be saved. And for more complex systems the data cannot be separated into different waveforms due to the monochrome nature of the LCD [9]. It can be seen that from the previous works on this project that a usual problem was the lack of detail that was presented in their report. Therefore, this report is going to curb that anomaly by providing a well detailed report of how the Arduinobased 10
oscilloscope is being developed. Secondly, this project is going to use the latest version of MegunoLink to obtain the maximum data needed for the plotting of the signals in realtime. Finally, this project will ensure that it can be able to measure analog signals that are within its range of measurement, and also the digital signals. The system thus developed will be able to measure analog and digital signals of high values by first reducing their amplitude and then sending it to the Arduino before it is fed to the PC for the plotting. With the above stated contributions that this report will give to this field of research it is necessary to state this report can serve as facilitator to further research on this subject as more possibilities can be achieved.
11
CHAPTER THREE METHODOLOGY, SYSTEM DESIGN AND ANALYSIS 3.1 Methodology Methodology refers to the system of methods used in particular area of study or project work developed. The methodology employed in this project was the Universal Design Methodology (UDM). In this section, a detailed description on how the employed methodology helped me in achieving the aim and objectives of this project will be treated. The Universal Design Methodology (UDM) This is an approach to hardware design with its foundations in the fundamental hardware designs. This methodology lays out the entire process, guaranteeing that the user will be able to accurately schedule the design and correctly allocate resources and prevent one from overlooking any step. The UDM specified steps provided by this methodology enabled the accomplishment of UDM design goals shown in Figure 3.1. The UDM approach is consequently iterative. This implies that during the design there was a need to fix errors and backtrack the process [10].
12
Concept
Specifications
Choose technology and tools
Schematic Design
Simulation
Design Review
Implementation
Testing
Final Product
Figure 3.1: Flow Chart of the UDM process
3.1.1 Concept The idea of a how a vital measuring instrument such as the oscilloscope would be made readily available, convenient and easy to use for those who are interested in
13
the field of electronics was first conceived, thus the need to embark on this project arose. 3.1.2 Specifications This is the second stage in the UDM where the detailed description needed to build the product is provided. This is vital because it serves as a guide for choosing the right tools and technology for the product design. These design specifications were chosen so that it would be able to achieve the aims and objectives of the project. The factors that were considered when choosing the specifications were; The price target, The range of values that the oscilloscope could measure, The minimum working conditions of the device which includes power consumption and operating voltages, The degree of information the oscilloscope can provide, The convenience and availability, and The troubleshooting procedures in case of any failure. 3.1.3 Choosing Technology and Tools Once the specifications were determined, I had to look out for different technologies could fit the specifications of the device. After some study on the technologies that could meet the specifications the Arduino came to be the most suitable technology for this design. Though it would need an additional circuit 14
(voltage sensing card) so that it could measure higher values of voltage i.e. higher than 5 V, it was still found to be the most suitable. Also the most suitable software in regards to the extent of my knowledge the MegunoLink was the most convenient and could give much details about the waveforms that would be generated from the Arduino as the software would serve as the interface between the Arduino and, also the PC and the user. Equipped with the above stated information the schematic design could be done. 3.1.4 Schematic Design The schematic design for the voltage sensing card, power supply circuit and the circuit needed to test the functionality of the oscilloscope were procured. The designs were done in the light of the objectives of the project. These circuits were simulated to test their functionality. 3.1.5 Simulation This step is vital and is also an ongoing process throughout the design. All sections of the system that could undergo a functional simulation were carried out in order to test the functionality of the schematically designed circuit. 3.1.6 Design Review After the simulation some changes were made in the schematic design in order to increase the efficiency of the system. Also with the help of the functional simulation errors were corrected and at this point the circuit was ready to be built. 15
3.1.7 Implementation After the design review was accomplished with the functional simulation software, the correct components were purchased, with confidence and a degree of accuracy as it was within the range of the value of the components involved.
3.1.8 Testing After the system had been fully constructed the system was tested and compared with a simulated oscilloscope. The discrepancy in measurements were acknowledged in order to make the system designed close to the ideal oscilloscope. 3.1.9 Final Product After the functionality of the system had been tested and found to be operational, the system was ready for packaging and for its use in its specified purpose. 3.2 System Design and Analysis The system was designed in individual sections with each recommending its distinctions. In this section the analysis of the system will be provided which will show the various schematics, skills and integration implemented in the course of constructing the project work. The emphasis were laid mostly on the objectives and specification and also more like a presentation of the work to fulfill the aim of the topic which is the design and construction of an Arduino based oscilloscope.
16
Systems design is the process or act of defining the architecture, component, modules, interfaces, and data for a system to satisfy specified requirements. One could see it as the application of systems theory to product development. There are some overlap and synergy with the disciplines of systems analysis, system architecture, and systems engineering [11]. System Analysis is defined as the procedural study of the operation of a system with an attempt to discover its problem areas i.e. to know why the system is not functioning properly and what can be done to restructure the system. This section is concerned with investigation and analysis of the existing system and a detailed explanation of the system design, with a view to understanding how it works including the problems and limitations. This section is important because in the rise of any complexities which may result to any uncertainty, with the aid of the detailed explanation in this section, anyone may be able to solve such issues and even make modifications where necessary [12]. System design and analysis in most cases are based on modularization be it software or hardware systems. The design and analysis of this project is similarly based on a method of modularization known as divide and conquer method. It allows for easy and effective design and analysis as the whole system and it is broken down into smaller units or modules and the design and analysis for each module is carried out independently. Modularization facilitates easy troubleshooting and correction or easy debugging (in case of software development). In the light of this project, the 17
design of an Arduino based oscilloscope/Logic analyser, its system design and analysis is divided into two subsystems, namely Hardware subsystem and Software subsystem 3.2.1 Hardware Subsystem The hardware subsystem comprises of every part of the system that can be seen and touched. In this report the hardware subsystem will be explained with aid of the block diagram below. Voltage Divider
ARDUINO HARDWARE
VOLTAGE SENSING CARD
OUTPUT
Figure 32: Block diagram of the hardware subsystem
First the value to be measured is fed into a voltage divider circuit and then fed into the voltage sensing card; in order to protect the Arduino from over voltages and put the voltage to be measured into a permissible level, the output from the voltage sensing card is then fed into the Arduino board, the analog to digital converter of the Arduino then sends the data to the PC which reads the data and the plots the values sent from the Arduino and shows it on the PC screen. The following part of this section will therefore analyse each module for a better understanding of the system.
18
3.2.1.1 Voltage Divider section This is the first circuit that the voltage to be measured enters. This circuit is used for stepping down the applied voltage to the permissible level accepted by the voltage sensing card and consequently the Arduino. This circuit is similar to the volt/div switch used in conventional oscilloscopes. The output of this voltage divider circuit is given to the voltage sensing card which gives protection to the Arduino from over voltages. The voltage divider circuit, consist of four 470 kΩ resistors and a 1 kΩ potentiometer in series. The voltage across the 1 kΩ potentiometer setting gets applied between the input terminals of the HCPL7800A. Since the output voltage should lie in the range 05V, the potentiometer setting is set to 0.9KΩ which is connected to pins 2 and 4 of HCPL7800A.
19
Figure 3.3: Diagram of the voltage divider circuit
3.2.1.2 Voltage sensing card section This is one of the most vital parts of the system because it is responsible for making sure the Arduino board is protected from over voltages. This card is used to sense the input voltage whether AC or DC and hence protect system equipment and circuitry from voltage that is hazardous or unsuitable for operation. It consists of 20
potentiometer circuit, an isolation amplifier HCPL 7800A and differential amplifiers TLE2082CP. HCPL 7800A works as an Isolator .The output of voltage sensing card will be of maximum 5V.This is given as input to the Arduino. The block diagram of the voltage sensing card is shown in Figure 3.3 below. The voltage sensing card can be divided into two subsections namely; Voltage sensing section Amplification section
Input voltage to be measured
Voltage sensing section
Amplificati on section
Output
: Figure 3.4: Block diagram of the voltage sensing card.
Input Voltage to be measured The range of value for this project will be 0240V (RMS). This will restrict our application to the selected range. Though the maximum value may be more than the root mean square (RMS) value. The circuit is designed in such a way that it responds to the RMS of the input so the range applies for RMS values and not for peak values of the input voltage. The voltage sensing card is designed to accept AC or DC. It is important to add that it can take 0340V peak values, though the range can be modified.
21
Voltage Sensing Section The isolation amplifier (isoamp) HCPL7800A [13] works as a precision voltage sensor together with a resistive divider consists of R1, R2, R3 and R4, and R5 sensing the input voltage to be measured. The HCPL7800A [14] can also work in conjunction with a shunt resistor to provide accurate current measurement. The isolated voltage sensor HCPL7800A can also be used in isolated temperature sensing designs. In this application, the voltage sensor must linearly and accurately measure temperature and send it across the isolation barrier thus providing safety insulation. The voltage sensing output are collected by the difference amplifier for amplification purposes. This is made possible when the output voltage of the isolation amplifier will be multiplied by the gain of the difference amplifier as it would be seen later in this section. Analysis of the isolation amplifier in the voltage sensing section As an example, functional blocks of the HCPL7800A are shown in Figure 3.4. First the isolation amplifier senses the input voltage (single ended analog signal) and converts it to a digital bit stream. The bit stream is then transmitted across the optical coupling pair consisting of an LED and a photodetector. This optical signal path provides the electrical insulation barrier. Because the transmitted signal is optical rather than electrical, it is immune to magnetic fields and electrical noise. The photodetector recovers the optical signal and converts it back to an electrical signal, 22
which is decoded and filtered to reproduce an analog output signal. The output voltage, provided in differential mode for better common mode noise rejection, is proportional to input voltage with unity gain. [15]
Figure 3.5: Block diagram of HCPL-7800A
The voltage sensor HCPL7800A provides ±1% measurement accuracy. The HCPL7800X family features a stretched SO8 package that is 30% smaller than a DIP8 package. These isoamps have a double protection rating of 3570 V rms/1 min per the UL 1577 safety standard. The 1414 Voltage peak maximum working voltage specification per IEC/EN/DIN EN 6074755 ensures circuits on the low voltage side are not damaged by hazardous high voltages. Using the HCPL7800A as an isolated voltage sensor is straight forward. Select resistors to form a voltage divider to scale down the voltage signal to be measured to a level within the sensor input range. With an integrated isolation and sensing
23
circuit, the application circuit is significantly simplified compared to alternative solutions that employ separate devices to perform sensing and isolation functions. A detailed voltage sensing circuit with the HCPL7800A is shown in Figure 3... Given that the HCPL7800A's nominal input voltage for VIN is 200 mV, a user needs to choose resistor R where R = R1+ R2+ R3 + R4 according to Equation 2 below =
× 5
(2)
For example if VL1 is 240 V and VIN is 0.2 V R2 is 1 kΩ then the value of R1 should be 999 kΩ.
24
Figure 3.6: High voltage measurement with conversion to an isolated ground reference input (Voltage sensing card schematics).
Choosing resistors is flexible. One method is to combine several resistors to match the target value; For example, in the project four 470Ω resistors in series make 1880 kΩ. The extra resistance is for precautionary measures. A VIN of 0.2V corresponds
25
to a VL1 of 240 V. However, in the cases that VL1 is not 240 V, specific resistance values might be difficult to find. Another method is to round up the target value to a convenient value, for example 3 MΩ, to make resistor selection easier. In such cases, the scaling relationship may need fine tuning. In the same example with a VL1 of 300 V, R1 of 3 MΩ, and R2 of 10 kΩ, VIN is solved to be 1.993 V. The downscaled input voltage is filtered by the antialiasing filter formed by R5 and C1, with corner frequency of 159 kHz (the value of R is usually much larger than R5, therefore neglected in calculation), and then sensed by the HCPL7800A. The galvanically isolated differential output voltage (VOUT+ VOUT) is proportional to the input voltage. Amplification Section The TLE2082CP, configured as a difference amplifier, converts the differential signal to a single ended output. This stage can also be made to amplify the signal, and, if required, low pass filter the signal to limit bandwidth. In this circuit, the difference amplifier is designed for a gain of one with a low pass filter corner frequency of 15.9 kHz. Resistors R9 and R11 can be changed for a different gain. The bandwidth can be reduced by increasing the capacitance of C3 and C4. The isolated output voltage VOUT, which is linearly proportional to the line voltage on the high voltage side, can be safely connected to the system microcontroller. With the TLE2082CP gain of A, and the overall transfer function of the voltage sensing card is simply: 26
= ×
(3)
=
(4)
Or
The recommended voltage operating range for the input voltage applied to the HCPL7800A lies in the range of +200 mV to −200 mV. The mean gain value of the HCPL7800A is 8. Therefore the output of the HCPL7800A lies between + 1.6V to −1.6V. However, for the sensor under consideration, the maximum output of the HCPL7800A is 1.2992 V which corresponds to the maximum value of the input voltage to the TLE2082CP. The gain of the TLE2082CP is set to 3.9 by using the 1 kΩ resistor at its inverting input and 3.9 kΩ as the feedback resistor. Hence, the maximum value of the output of the TLE2082CP which is to correspond to the output of the voltage sensing card is 1.2992 × 3.9 = 5.06 This corresponds to the value that will be sent to the Arduino’s analog input. The Power Supply Circuit The voltage sensing card utilized in this system had three different power supply circuits. Two were 5V single rail power supply circuit that was used to power the HCPL 7800A while the third one was a 15V dual rail power supply circuit. 27
5 V Power Supply Circuit The 5V regulated power supply circuit of fig 7 consists of a step down transformer. 230V AC is applied to the primary side of the transformer and the voltage obtained on the secondary side is 6V AC. The 6V AC is converted to DC using a bridge rectifier comprising of four 1N4007 diodes. The capacitors are used for the removal of ripples in the circuit. The voltage regulator used is LM7805 which produces a steady 5V regulated DC. This 5V DC is given to the isolation amplifier HCPL7800A. Since the input and output side of HCPL7800A are isolated, two such 5V power supplies are required.
Figure 3.7: 5V power supply circuit
28
+15V and -15V Power Supply Circuit The +15V and 15Vpower supply circuit of fig 5.2 consists of a centre tapped step down transformer. 230V AC is applied to the primary side of the transformer and the voltage obtained on the secondary side is 15015V AC. The 15015V AC is converted to DC using a bridge rectifier comprising of four 1N4007 diodes. The capacitors are used for the removal of ripples in the circuit. The voltage regulators used are LM7815 and LM7915. LM7815 produces a steady 15V regulated DC and LM7915 produces a steady 15V regulated DC with respect to the centre tap of the transformer. 15V and 15V DC is given to TLE2082CP.
Figure 3.8: Dual rail 15V power supply circuit.
3.2.1.3 Arduino Uno Section Arduino is an opensource platform used for building electronics projects. Arduino consists of both a physical programmable circuit board (often referred to as a microcontroller) and a piece of software, or IDE (Integrated Development 29
Environment) that runs on the user’s computer, used to write and upload computer code to the physical board. The Arduino platform has become quite popular with people just starting out with electronics, and for good reason. Unlike most previous programmable circuit boards, the Arduino does not need a separate piece of hardware (called a programmer) in order to load new code onto the board – the user can simply use a USB cable. Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn to program. Finally, Arduino provides a standard form factor that breaks out the functions of the microcontroller into a more accessible package. Arduino manufactures many different boards, each with different potentials. In addition, Arduino is “open source” hardware. This implies that others can modify and produce derivatives of Arduino boards that provide even more functionality. Such boards are: Arduino Uno LilyPad Arduino RedBoard Arduino Mega Arduino Leonardo This section will discuss the Arduino Uno. Reason being that the analysis of this device will be able to give the reader enough reasons as to why this device was chosen as a suitable microcontroller for the system design. 30
Arduino Uno The Arduino Uno is a microcontroller board based on the ATmega328 datasheet. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with an ACtoDC adapter or battery to get started. The Uno differs from all preceding boards in that it does not use the FTDI USBtoserial driver chip. Instead, it features the Atmega8U2 programmed as a USBtoserial converter. "Uno" means one in Italian and is named to mark the upcoming release of Arduino 1.0. The Uno and version 1.0 will be the reference versions of Arduino, moving forward. The Uno is the latest in a series of USB Arduino boards, and the reference model for the Arduino platform [16]. Table 3.1: The Arduino Uno specifications
Microcontroller
ATmega328
Operating Voltage
5V
Input Voltage (recommended)
712V
Input Voltage (limits)
620V
Digital I/O Pins
14 (of which 6 provide PWM output)
Analog Input Pins
6
31
DC Current per I/O Pin
40 mA
DC Current for 3.3V Pin
50 mA
SRAM
2 KB
EEPROM
1 KB
Clock Speed
Hz
Figure 3.9: Diagram of the Arduino Board
Power Specification The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically. External (nonUSB) power can
32
come either from an ACtoDC adapter (wallwart) or battery. The adapter can be connected by plugging a 2.1mm centerpositive plug into the board's power jack. Leads from a battery can be inserted in the GND and VIN pin headers of the POWER connector. The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts. The power pins are as follows: A) VIN The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). The user can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.
B) 5 V The regulated power supply used to power the microcontroller and other components on the board. This can come either from VIN via an onboard regulator, or be supplied by USB or another regulated 5V supply.
33
C) 3.3V A 3.3 volt supply generated by the onboard regulator. Maximum current draw is 50 mA. D) GND. Ground pins. E) IOREF: This pin on the Arduino board provides the voltage reference with which the microcontroller operates. A properly configured shield can read the IOREF pin voltage and select the appropriate power source or enable voltage translators on the outputs for working with the 5V or 3.3V. Memory Specification The ATmega328 has 32 KB (with 0.5 KB used for the boot loader). It also has 2 KB of SRAM and 1 KB of EEPROM. Input and Output Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode (), digitalWrite (), and digitalRead () functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pullup resistor (disconnected by default) of 2050 kΩ. In addition, some pins have specialized functions: Serial: 0 Receive (RX) and 1 Transfer (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USBtoTTL Serial chip.
34
External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt () function for details. Pulse Width Modulation (PWM): 3, 5, 6, 9, 10, and 11. Provide 8bit PWM output with the analogWrite() function. Serial Peripheral Interface (SPI): 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library. Light Emitting Diode 13: There is a builtin LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off. The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function. Additionally, some pins have specialized functionality: Two Wire Interface: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library. There are a couple of other pins on the board: AREF: Reference voltage for the analog inputs. Used with analogReference(). Reset. Bring this line LOW to reset the microcontroller. Typically, this is used to add a reset button to shields which block the one on the board. Communication
35
The Arduino Uno has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers. The ATmega328 provides UARTTTL (5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX). An ATmega8U2 on the board channels this serial communication over USB and appears as a virtual com port to software on the computer. The '8U2 firmware uses the standard USB COM drivers, and no external driver is needed. However, on Windows, an *.inf file is required. The Arduino software includes a serial monitor which allows simple textual data to be sent to and from the Arduino board. The RX and TX LEDs on the board will flash when data is being transmitted via the USBto serial chip and USB connection to the computer (but not for serial communication on pins 0 and 1). A SoftwareSerial library allows for serial communication on any of the Uno's digital pins. The ATmega328 also support I2C (TWI) and SPI communication. The Arduino software includes a Wire library to simplify use of the I2C bus. Programming the Arduino The Arduino Uno can be programmed with the Arduino software .Select “Arduino Uno” from the Tools > Board menu (according to the microcontroller on the board). The ATmega328 on the Arduino Uno comes preburned with a boot loader that allows the user to upload new code to it without the use of an external hardware programmer. It communicates using the original STK500 protocol (reference, C header files). The user can also bypass the boot loader and program the 36
microcontroller through the ICSP (InCircuit Serial Programming) header. The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source code is available. The ATmega16U2/8U2 is loaded with a DFU boot loader, which can be activated by: On Rev1 boards: connecting the solder jumper on the back of the board (near the map of Italy) and then resetting the 8U2. On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to ground, making it easier to put into DFU mode. The user can then use Atmel's FLIP software (Windows) or the DFU programmer (Mac OS X and Linux) to load a new firmware. Or the user can use the ISP header with an external programmer (overwriting the DFU boot loader).
37
Figure 3.10: An illustration of the Arduino IDE
Automatic (Software) Reset: Rather than requiring a physical press of the reset button before an upload, the Arduino Uno is designed in a way that allows it to be reset by software running on a connected computer. One of the hardware flow control lines (DTR) of theATmega8U2/16U2 is connected to the reset line of the ATmega328 via a 100 38
nanofarad capacitor. When this line is asserted (taken low), the reset line drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload code by simply pressing the upload button in the Arduino environment. This means that the boot loader can have a shorter timeout, as the lowering of DTR can be well coordinated with the start of the upload. This setup has other implications. When the Uno is connected to either a computer running Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the following halfsecond or so, the boot loader is running on the Uno. While it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the board after a connection is opened. If a sketch running on the board receives onetime configuration or other data when it first starts, make sure that the software with which it communicates waits a second after opening the connection and before sending this data. The Uno contains a trace that can be cut to disable the autoreset. The pads on either side of the trace can be soldered together to reenable it. It's labeled "RESETEN". You may also be able to disable the autoreset by connecting a 110 ohm resistor from 5V to the reset line.
39
USB Over-current Protection The Arduino Uno has a resettable polyfuse that protects your computer's USB ports from shorts and overcurrent. Although most computers provide their own internal protection, the fuse provides an extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically break the connection until the short or overload is removed. Physical Characteristics The maximum length and width of the Uno PCB are 2.7 and 2.1 inches respectively, with the USB connector and power jack extending beyond the former dimension. Three screw holes allow the board to be attached to a surface or case. Note that the distance between digital pins 7 and 8 is 160 mil (0.16"), not an even multiple of the 100 mil spacing of the other pins [17]. Analysis of the function of Arduino in the system When the output from the voltage sensing card and other voltages are fed into the Arduino Uno through any of it analog input pins from A0 –A5. The program uploaded into the ATMega328P instructs the board to send these signals to its Analog to digital converter (ADC). After a process known as successive approximation the digital signals (data) is sent from the serial port to the PC for plotting.
40
Analysis of the Analog-to-Digital Converter (ADC) of the Arduino Uno Most microcontroller cores have an 8 channel 10 bit analog to digital converter (ADC). In the Arduino the analogRead () function is used to interact with the ADC. In this subsection a detailed explanation will be given on the underlying process of the Arduino’s ADC. A focus will be given on the Atmel ATmega328P. The datasheet of this microcontroller is available in [17] in the reference section An ADC is used to convert an analog voltage that is continuously varying within a known range into a digital value. The analog value often represents some real world measurement. Most values in the real world, say air pressure or temperature or speed are inherently analog in nature. This continuous stream of analog information is normally referred to as a signal. Unlike the analog signal, the digital values that are converted from them will not be continuous. They will be read or sampled a certain number of times per second, which is referred to as the sampling frequency.
Figure 3.11: An illustration on how sampling frequency works.
The continuous slope of the graph in Figure 3.8 above represents an analog signal rising and falling between 5 volts and 5 volts. Most of the examples that were encountered in the project were fluctuating between 0 volts and 5 volts .The dots are 41
points in time when the ADC is used to convert the current point of the analog signal into a digital value. For instance, the first dot might convert to 3.25 volts and the second might convert to 5 volts. The number of times that we take a reading (create blue dots) per second is the frequency of the sampling. There are two conventional types of ADC which are the ramp ADC and the successive approximation ADC. The ADC utilised by the ATMega328P in this project is the successive approximation ADC. [18] Successive Approximation (SAR) ADC Converting an analog voltage level into its equivalent digital value (ADC) can be difficult to deal with, particularly if it needs to be done both quickly and accurately. As earlier stated, the analog inputs on an ATMega CPU use a technique called "successive approximation ADC," which provides a decent tradeoff between speed, accuracy, resolution, and complexity. Successive approximation ADC uses a network of capacitors with exponentially scaled values that are first completely discharged to an offset voltage provided by a comparator, then charged to the voltage of the signal being sampled. The capacitors are then switched to the comparator input so that it is exposed to the same voltage as the original signal but with that voltage provided by the capacitors rather than by the circuit under test, which is completely isolated at that point. Each capacitor is then progressively switched to the reference voltage and the comparator compares the resulting voltage to the reference voltage to decide if it is higher or lower, and 42
emit a 1 if it's higher or a 0 if it's lower. As each capacitor is switched, a new bit is emitted from the comparator.
Figure 3.12: Five-bit SAR-ADC based on charge redistribution
The simplest way to conceptualize this is to imagine that the ADC starts with a very rough idea of the level of the input and progressively narrows it down to a more accurate value. The first reading, or bit, simply checks whether it's in the top or bottom half of the voltage range. If it's in the top half, it is a HIGH; the lower half, it is a LOW. Then the second reading, or second bit, checks whether it's in the top or bottom half of that range. Every bit that is read doubles the resolution of the result by narrowing it down to a smaller part of the range. This means that the number of capacitors in the array determines the number of successive readings and, therefore, the bits of resolution that the ADC can generate. In an ATMega each analog input uses a 10capacitor array, so the highest resolution it can provide is a 10bit value.
43
This corresponds to a decimal number between 0 for a voltage at 0V, and 1023 for a voltage at the supply voltage of the system. As you can imagine, it takes a little while for this process of discharging, switching, charging, switching, and then stepping through each capacitor. Adding more bits increases the resolution, but it also means more steps for the ADC circuit to perform while doing the conversion. Conversely, decreasing the number of bits also decreases the conversion time. A 10bit sample on an ATMega used in an Arduino takes approximately 111 microseconds. When this is compared to the reading a digital input, which is essentially just feeding the input signal straight to the comparator and returning a single bit immediately without going through all the steps with the capacitor array. That is the reason why a digital read can take place in under one microsecond but an analog read takes more than one hundred times as long. It should be noted that the terms “accuracy” and “resolution” do not mean the same thing, even though many seem to use them interchangeably. Resolution tells us the number of intervals on a scale being used to measure something, while accuracy tells us how consistently the scale is applied. The resolution on an ATMega analog input is 10 bits, but it's not actually quite that accurate. By the time the ATMega gets to sampling the last two bits, there is a little bit of jitter in the voltage being tested and so they might fluctuate slightly even when reading a very consistent and accurately
44
generated reference voltage. The resolution on the analog inputs may be 10 bits, but they don't actually provide quite that much accuracy. If there is a need for the analog reads to be at the highest possible speed it is at the expense of a little accuracy because it is possible to force the ATMega CPU to apply a custom prescaler value to the ADC clock. Because the ADC needs to perform a sequence of comparisons, the time it takes to complete an entire analog read is dependent on how quickly it can perform each individual step. The ATMega is rated to supply a clock rate of between 50 kHz and 200 kHz to its ADC depending on a combination of the overall CPU clock speed (16MHz on a typical Arduino) and the ADC prescaler factor. The Arduino environment sets the prescaler factor to a value of 128 in the file hardware/cores/Arduino/wiring.c around line 231. This results in an ADC clock rate of 16 MHz / 128 = 125 kHz, which is well within the 50 kHz to 200 kHz range recommended by Atmel. 125 kHz is a fairly conservative ADC clock rate, though, and you can get massive ADC speed gains by pushing it closer to its operational limit. The ATMega datasheet notes that ADC clock speeds up to 1 MHz "do not reduce the ADC resolution significantly," which means that on a 16 MHz Arduino you can push the prescaler value as low as 16 to increase the ADC clock speed right up to 1 MHz (i.e., 16MHz / 16) and still get reasonably good accuracy. The result is analog reads that complete in around 16 microseconds which far faster than the 111 microseconds of a stock Arduino [19]. This state is not a good condition.
45
After this particular consideration I did not change the prescaler value because the present condition met the needs of the design specifications. To illustrate further, the ten steps to converting an analog input to 10 bit digital, using successive approximation, is shown here, for all voltages from 5V to 0V in 0.1V iterations. Since the reference voltage is 5V, when the input voltage is also 5V all bits are set. As the voltage is decreased to 4.9V, only some of the least significant bits are cleared. The MSB will remain set until the input is one half the reference voltage, 2.5V. The binary weights assigned to each bit, starting with the MSB, are 2.5, 1.25, 0.625, 0.3125,
0.15625,
0.078125,
0.0390625,
0.01953125,
0.009765625,
and
0.0048828125. All of these add up to 4.9951171875, meaning binary 1111111111, and is one LSB less than 5. When the analog input is being compared to the internal DAC output, it effectively is being compared to each of these binary weights, starting with the 2.5V and either keeping it or clearing it as a result. Then by adding the next weight to the previous result, comparing again, and repeating until all the bits and their weights have been compared to the input, the end result, a binary number, representing the analog input, is found. [20]. after the conversion process occurs these1 digital signals are then sent to the PC for plotting through the serial port of the Arduino by the process of serial communication.
46
Analysis of the serial communication between the PC and the Arduino The serial port of the Arduino sends the data to the PC through the PC’s Universal Serial Bus (USB). This type of communication is commonly referred to as serial communication between two devices. The particular mode of serial communication responsible for this is the Universal Synchronous Serial Receiver and transmitter (USART). This protocol will be discussed briefly. The ATmega328 which is the main component of the Arduino is equipped with a host of different serial communication subsystems including the Universal Synchronous Serial Receiver and transmitter (USART), the serial peripheral interface (SPI) and the twowire serial interface (TWI). What all of these systems have in common is the serial transmission of data. In a serial communication transmission, scheme data is sent a single bit at a time from transmitter to receiver. Serial USART is the form of serial communication that is of major interest in this project, the serial UART may be used for full duplex (two way) communication between a receiver and transmitter. This is accomplished by equipping the ATmega328 with independent hardware for the transmitter and receiver. The USART is typically used for asynchronous communication. That is there is not a common clock between the transmitter and receiver to keep them synchronised with one another. To maintain synchronisation between the transmitter and receiver 47
framing start and stop bits are used at the beginning and end of each data byte in a transmission sequence. The ATmega328 is quite flexible. It has the capability to be set to a variety of data transmission rates known as the Baud (bits per second) rate. The USART may also be set for data bit widths of 5 to 9 bits with one or two stop bits. Furthermore, the ATmega328 is equipped with a hardware generated parity bit (even or odd) and parity check hardware at the receiver. A single parity bit allows for detection of a single bit error within a byte of data. The USART may also be configured to operate in a synchronous mode, but the mode of connection used in this project is that of the asynchronous [21]. 3.2.2 The Software Subsystem The software subsystem in this project is referred to as the part of the project that involves the use of codes and software to achieve overall aim of the project. Therefore, the software subsystem of this project has two main parts namely; Programming the Arduino and Utilisation of the MegunoLink Software.
Digital Input signals from Arduino
MegunoLi nk plot
Figure 3.13: Block Diagram of Software Subsystem
48
Output on PC screen
3.2.2.1
Programming the Arduino
The Arduino was programmed with a code that enabled it first covert the analog signals into digital signals and then send these digital signals to the MegunoLink software for plotting [22]. The codes that were used to accomplish this task were explicitly stated in Appendix A. However, the algorithm and the main idea of the codes are described in the flowchart in Figure 3.10 and in Pseudocode 1 respectively. Define the time at which the data was last sent // = LastSent Define the interval between which the analog data will be sent// = SendInterval Name the plot where the data will be sent to Define baud rate of the serial port Equate the time variable to the required function // = TimeFunction Define the Title, Xaxis, and Yaxis and properties of the plot. IF (TimeFunction –LastSent) > SendInterval o THEN LastSent = TimeFunction END Define the analog pins that data will be obtained from. o Assign names to the analog pins to plot data read from those pins END Pseudocode 1: Pseudocode for reading analog input values and plotting them on graph.
49
Start
Connect
A = Time data was last sent
Define analog pins that will perform
B = Interval for data capture
Read analog pins
False
Name the plots
Name the graph
Is C > B?
Define serial port parameters
True Send Analog pins to PC
Define graph parameters
End
Call time function
Time Function − A=C
Conne ct
Figure 3.14: Flowchart of the algorithm of the code used in plotting
50
In addition, this system also has the capacity to read different analog input perform an operation on the data received and give a final output on a separate waveform. The Pseudocode 2 below will explain such concept Define the time at which the data was last sent // = LastSent Define the interval between which the analog data will be sent// = SendInterval Name the plot where the data will be sent to Define baud rate of the serial port Equate the time variable to the required function // = TimeFunction Define the Title, Xaxis, and Yaxis and properties of the plot. IF (TimeFunction –LastSent) > SendInterval o THEN LastSent = TimeFunction END Define the analog pins that data will be obtained from. o Perform the operation required on the data read from the analog pins o Assign names to the analog pins and output of the operation to plot data read from those pins and output of the operation. END Pseudocode 2: Program that performs an operation on two outputs and plots the data.
51
3.2.2.2
Utilisation of the MegunoLink Pro Software.
MegunoLink Pro is a tool designed to aid embedded electronics designers. MegunoLink provides a set of tools to help visualize serial data, it is made up of a set of visualizers that each have a unique function and any number of them can be utilized at once. With these visualizers and our functional tabbed and docked interface you can create a full control center for your embedded project. Plot, log and monitor serial streams from both hardwired, Bluetooth, and network based (UDP) devices. The software can be downloaded from their website. The user interface allows for a completely customized layout with many different visualisers displaying information at once. Perfect for developing exciting new microcontroller based designs. Data streams go from hard to follow serial messages to easy to interpret tables and interactive plots. The interface panel allows you to set up custom GUI elements that let you take control of your device from the comfort of your PC screen [23].
52
Figure 3.15: MegunoLink Pro Software
MegunoLink has many features which includes:
Serial port monitoring
The ability to capture serial port data to a text file.
A tool to graph formatted data sent from the Arduino in real time.
Enable building Arduino projects using ATMEL AVRstudio
Upload compiled .HEX files to Arduino Serial Port Monitoring: As with the Serial Monitor in the Arduino IDE, a user can monitor the data from the Arduino, and also send it back through the serial line. Capturing Serial Data to a file:This feature makes MegunoLink a very useful software because with this MegunoLink is armed with the capacity to log 53
every interaction the Arduino makes with the PC. With this it is possible to debug errors if need be. A user can also append data to an existing text file. When creating the output format in an Arduino sketch, it is expedient that the user is mindful to have separators such as commas or colons – which make it much easier to delimit the data once imported into a spreadsheet or database application. Plotting and Graphing Serial Data: Plotting data with MegunoLink is convenient. This feature is vital in the design that was carried out in this project. This because the oscilloscope was all about plotting. Inclusively, MegunoLink also has the capacity to save what was plotted in a readable format for better analysis. This is an added advantage to the usefulness of the Arduino based oscilloscope. The data must be formatted as such: {a, T, b}
Where ‘a’ is the name of the series. ‘T’ tells MegunoLink to plot the actual real time, and ‘b’ is the data as a number in string form. Figure 2 below shows an instance of a plot performed by MegunoLink.
54
Figure 3.16: An example of a plot using MegunoLink
Enable building Arduino projects using ATMEL AVRstudio Using MegunoLink a user can develop Arduino projects with Atmel AVRStudio software. As some people find the Arduino IDE quite limiting, this option gives a user access to the more programmerfriendly Atmel IDE. Upload compiled .HEX files to Arduino
Any user using AVRdude to upload compiled .hex files to an Arduino, can also do this using the GUI MegunoLink interface. This is also used for uploading the compiled files generated in AVRStudio [17].
55
The function of the MegunoLink is very vital because the PC is used as the screen of the oscilloscope because of the interaction between the MegunoLink software and the Arduino. The Arduino sends data to the MegunoLink through a USB interface. The MegunoLink read these data and used the plotting and graphing capabilities to plot the required waveform and showed it on the PC screen sequentially. The MegunoLink was also used to save the waveforms derived from the test that was carried out. This helped the designer to be able to use the values obtained for the analysis of the circuit design as desired [24]. At this point it is needful to say that the above mentioned methodology, system analysis and design of this project will give the reader a good grasp of the underlying process involved with the system.
56
CHAPTER FOUR 4. SYSTEM IMPLEMENTATION, TESTS AND RESULTS 4.1 SYSTEM IMPLEMENTATION The implementation of the Arduino based oscilloscope is divided into two sections namely; Hardware Subsystem Implementation Software Subsystem Implementation 4.1.1 Hardware Subsystem Implementation In this subsection a detailed report on how the hardware of the system was constructed will be given. It is important to note that in realizing the hardware used in this system, the order of the system analysis had to be followed, therefore this section would be explained in that order, however in the naming of the divisions some modifications were made to suit this chapter. This subsection is therefore subdivided into 3 namely; Voltage Divider circuit design implementation, Voltage sensing card design implementation, Arduino hardware integration.
57
4.1.1.1
Voltage Divider Circuit Implementation
The voltage divider circuit was implemented using four 470 kΩ resistors connected in series, with a 1 kΩ potentiometer, this is similar to the voltage divider found in conventional oscilloscopes. Each value of the resistor corresponds to the amount of input voltage, therefore the voltage measurement at each point is determined by the position the voltage to be measured is placed. 4.1.1.2
Voltage sensing card design implementation
This design was implemented using the isolation amplifier HCPL7800A, an operational amplifier, TLE2082, some resistors, capacitors all soldered to a Printed Circuit Board (PCB). The Figure 4.1 shows the circuit schematics of the voltage sensing card. The final circuitry was realised in the computer using a computer aided design (CAD) software tool – Multisim 12.0. This enabled the joining of all separate parts of the system together and simulate the entire circuitry before carrying out the physical construction. IN order to facilitate and reduce construction errors, the final circuitry was exported to another CAD software tool known as Easily Applicable Graphical Layout Editor (EAGLE), which served as a guide in the production of the airwires (signal lines) linking one pin to another. This CAD tool makes it possible to easily layout various components on a board. Hence the component layout is shown in Figure 4.2 was properly planned defining the position of each component before they are linked to one another by the traces. 58
By selecting the various device pins on the board, the CAD tool helped me to link the devices together as defined in the circuit diagram. With few manual alterations, the circuit track layout and traces were developed. This track layout is known as the printed circuit board layout. Once the PCB layout was done, it was simulated in order to test for connectivity and broken lines. When certified ‘OK’ the PCB track layout and board layout were printed out with the aid of a laser jet printer on a film. The printed layout was then placed on the copper side of the plain PCB, with the aid of a very hot pressing iron the layout was “pressed” onto the copper side. The pressing iron was placed there for about 30 – 40 seconds. After lifting the iron, the PCB was placed into water for about 10 minutes. Afterwards, the paper on the PCB was carefully removed so that the layout does not go with it. The board was carefully dried with a napkin to ensure the lines and pads remain on the board. The board was etched using Ferric Chloride, the chemical was placed inside water in a bucket in such a way that the concentration of the acid would be high. After about 5 minutes the bucket was stirred every 5 minutes for about an hour. After which the insulating materials were scraped out, and finally the PCB layout was done. All the jumpers that needed connection were put in place, tests for connectivity were carried out and then the PCB was ready.
59
The input port of the oscilloscope that indicated the measurement of DC and AC voltages were connected to the voltage sensing card input pads. Thus enabling the system to measure voltages up to 0 – 340 RMS peak values.
Figure 4.1: Design of PCB with EAGLE
60
Figure 4.2: Implemented PCB
4.1.1.3
Arduino Implementation
The Arduino Uno was implemented by integrating the voltage sensing card to one of the analog pins tagged A0. The Arduino’s six analog pins were used. This is what gave the system the capacity to have six input forms for showing the six wave forms. The probes are connected to each of the input ports. These probes are connected to resistors, diode (for protection) and capacitors (to filter the signal) and the connected 61
to the Arduino Uno’s analog pins so that in situations where more than 5V is connected to the Arduino the Arduino Uno would be protected. 4.1.2 SOFTWRE SUBSYTEM IMPLEMENTATION In this subsection every software utilised in the implementation of the project will be discussed. This subsection will be divided into two sections namely; Arduino IDE implementation MegunoLink Pro implementation. 4.1.2.1 Arduino IDE implementation The programming of the Arduino was done with the inbuilt programmer that comes with the Arduino Board. The program was written in C programming language. The program was compiled with Arduino IDE which was downloaded from the Arduino website [16]. The following steps shown below were used to program the Arduino. Download the IDE that matches with the operating system of the computer Install the Arduino IDE Type the required program If the program is contained in the library of the Arduino do the following Go to examples Click on folder name of the file that was used to save the program Click on the file name and then the program will automatically appear on the screen. 62
Click on compile to verify the program, if there is any error debug the program Click on build to burn the program into the microcontroller.
Figure 4.3: Arduino IDE programming
4.1.2.2
MegunoLink Pro Implementation
The MegunoLink pro software was implemented using the PC. The implementation of this software of this software helped to ensure that the digital signals sent from the Arduino to the PC was plotted against time. This software plotted these signals
63
in real time. It also has the capacity to log every recorded data to a text file chosen by the user. The particular feature that enabled the plotting of the signals in known as the time plot. Time plot visualizer contained in this software allows the user to send data over the serial port of the Arduino, and display it on a plot with time on the xaxis and the signal being measured on the yaxis. The time stamp for the xaxis can be provided by the MegunoLink as the data is being received or by the Microcontroller if it’s a clock.
Figure 4.4: Time plot example
64
The steps that were taken to implement the time plot feature of the software are given below Download the software from the MegunoLink website Install the software Click on the visualizer icon on the main toolbar to show the visualizer panel Select ‘Time Plot’. Go to the connection manger panel and click connect (This connects the Arduino Board with the software.) Click on the channel selector Select the channel that is to be monitored. In addition, you can view the summary table of any channel being monitored. Zoom in and out for a better view, perform auto scrolling where necessary and so on.
65
Figure 4.5: Time plot features
4.2 SYSTEM TEST AND RESULTS 4.2.1 Hardware subsystem test 4.2.1.1
Voltage divider section Test
The voltage divider was tested in order to make sure the required voltage is being fed into the voltage sensing card.
66
These tests were compared with a simulated version of the circuit shown in Figure 4.6 below
Figure 4.5: The voltage divider schematics
4.2.1.2
Voltage Sensing Card section test.
The major hardware subsystem test includes the voltage sensing card. This test was carried out in order to make sure that any voltage input at 0 – 340 V will give an output at or below 5V that can be used by the Arduino. The table 4.1 below shows the calculated values of the section involved in the voltage sensing card, the values below are to be expected from the built voltage sensing card. These values were calculated with the equations given in chapter three of this report.
67
Table 4.1: Results gotten from the calculations
Input voltage to be
Output of potential
measured ( V)
divider circuit (mV)
Output of
Output
of
sensor
HCPL 7800A (V)
(V) RMS
Peak
RMS
Peak
RMS
Peak
RMS
Peak
240
339.411
114.834
162.406
0.918
1.299
3.582
5.066
230
325.269
110.053
155.639
0.880
1.245
3.433
4.855
220
311.126
105.268
148.872
0.842
1.190
3.283
4.644
200
282.842
95.698
135.338
0.765
1.082
2.985
4.222
150
212.132
71.773
101.503
0.574
0.812
2.238
3.166
100
141.421
47.849
67.669
0.382
0.541
1.491
2.109
50
70.710
23.924
33.834
0.199
0.277
0.744
1.053
25
35.355
11.962
16.917
0.095
0.135
0.371
0.526
0
0
0
0
0
0
0
0
The voltage sensing card was simulated using a CAD tool – National Instruments Circuit design tool, Multisim 12.0, the simulation was carried out so that the data obtained would be compared to the calculated data so that in the case of any discrepancy the circuit would be debugged, as necessary adjustments will be made
68
to give a value close to the calculated value. Figure 4.7 below shows the simulation circuit of the voltage sensing card with a DC input from the HCPL7800A.
Figure 4.6: Voltage sensing card simulation circuit (DC)
Figure 4.8 shows the resulting waveform and signal details of the simulated circuit shown in Figure 4.7. 69
Figure 4.7: Simulation results of the voltage sensing card (DC) shown with an oscilloscope.
Similarly, the simulation of the voltage sensing card with an AC input was carried out, in order to ensure that the circuit worked as expected.
70
Figure 4.8: The simulation circuit for an AC input.
The resulting waveform stipulated from the circuit shown above is given in Figure 4.10 below 71
Figure 4.9: Simulated Voltage sensing card output AC
The results of the simulated version of the voltage sensing card were tabulated as shown in Table 4.2 below. The values recorded here were for the AC input because the AC was more difficult to deal with.
72
Table 4.2: The results obtained from the simulations.
Input voltage to be Input to TLE2082CP measured ( V)
Output of sensor
( V)
( V)
RMS
Peak
RMS
Peak
RMS
Peak
240
339.411
0.918
1.299
3.582
5.063
230
325.269
0.880
1.245
3.430
4.851
220
311.126
0.842
1.190
3.281
4.641
200
282.842
0.765
1.082
2.981
4.217
150
212.132
0.574
0.812
2.237
3.164
100
141.421
0.382
0.541
1.488
2.105
50
70.710
0.199
0.277
0.740
1.047
25
35.355
0.095
0.135
0.369
0.523
0
0
0
0
0
0
After the construction of the voltage sensing card, tests were carried out on the board and the resulting values are shown in Table 4.3 below
73
Table 4.3: Possible results to be obtained from the board
Input voltage that is to be measured
Output of the sensor
(V)
(V)
RMS
Peak
RMS
Peak
230
325.269
3.6
5.09
220
311.126
3.4
4.80
200
282.842
3.06
4.32
150
101.503
2.35
3.32
100
67.669
1.5
2.12
50
33.834
0.77
1.08
25
16.917
0.37
0.52
0
0
0.01
0.014
4.2.2 Test for the Arduino base oscilloscope system In testing the overall performance of the Arduino based oscilloscope some tests had to be carried out. A detailed explanation of the tests are given below.
74
4.2.2.1
Test for displaying waveforms
In carrying out this test a potentiometer was connected in such a way that its middle pin is given to an analog input port of the Arduino and the two other terminals are given to ground and 5V power supply of the Arduino respectively. By varying the potentiometer the value of the input voltage is varied and output is changed. Maximum output of the output voltage obtained is dependent on the maximum output voltage obtained from the potentiometer which signifies its accuracy. The wave form is shown in Figure 4.10 below
Figure 4.10: Arduino oscilloscope potentiometer test.
4.2.2.2
Test for displaying pulses
The circuit for displaying pulses using the Arduino is another Arduino that generates pulse width modulation. This because the use of analog other analog circuits do not
75
appear as square wave due to their inconsistences in giving a HIGH and LOW. Therefore, the resulting waveform is shown in Figure 4.11 below
Figure 4.11: Squarewave test on the Arduino Oscilloscope
However, in ideal situations as shown in the simulation of a 555 timer producing pulses and captured from the oscilloscope in the software, the square wave appears to be alright, and it is shown here for comparison purposes.
Figure 4.12: Squarewave test on the simulation software
76
4.2.2.3 Tests for displaying saw-tooth pulses The circuit used for displaying saw tooth is the same as that of the pulse generator circuit using 555 timer but this time the output is taken from terminal 2. The simulated circuit is shown in the Figure 4.13 below and the Arduino based oscilloscope result is shown in Figure 4.14
Figure 4.13: Sawtooth pulse test on the simulation software
Figure 4.14: Sawtooth pulse test on the Arduino oscilloscope
77
4.2.2.3
Test for multiple inputs
Test for the monitoring of two input channels were carried out. These channels can be monitored together or separately depending on the plans of the user.
Figure 4.15: Test for the plot of two input waveforms.
Also a test for six input waveforms were carried out. This is the maximum amount of waveform that the Arduino based oscilloscope was designed to plot. The program for the six input display is shown in appendix C.
78
Figure 4.16: Test for plotting six waveforms
4.2.2.4
Test for the operation of waveforms
Using the Arduino programming two or more waveforms can perform operations and still be displayed on the screen. In Figure 4.17 below A1 is a Squarewave, while A2 is a sawtooth waveform. Adding both these resulted in another waveform V3 which is shown in Figure 4.17 below. The program for this operation is written in Appendix B.
79
Figure 4.17: Plotting waveforms and their operations
4.3 System Integration System integration is the combination of the different parts (modules) of a system in order to form a complex system [24]. Therefore the system integration of this system followed the same analogy given in chapter three particularly the block diagram of the whole system. In other words the voltage selector circuit was connected to the input voltage sensing card and the output of the voltage sensing card was connected
80
to one of the analog pins of the Arduino Uno and finally the values obtained from the ADC of the Arduino is sent to the PC for plotting. 4.4
Performance Evaluation
This system has a performance evaluation of 90% when compared to an ideal system. The system is relatively accurate, but the inherent limitations such as the bit resolution and the amount of sample rate is not very high when compared to most conventional oscilloscopes. 4.5
Packaging the system
In the field of electronics, the working system is commonly referred to as the skeleton of the project, and any system that possess a skeleton should have a shield that protects its skeleton. This shield is known as a package. Packaging is the process of hiding and protecting the circuit from external or environmental harm. The packaging should suit to its application, usage and any other necessary factors that will any affect the system were considered. The Arduino based oscilloscope has components that are fragile so the PCB was screwed to the plastic box, the Arduino board was equally screwed, the space for the input ports were drilled and a space for the USB port was equally made available. The spacing of these openings were well measured in order to have a neat design.
81
4.6
Bill of Engineering Measurement and Evaluation (BEME).
The cost of building the work was effective, because the aim of this project is to make sure that the oscilloscope was made affordable for the target group to design and use at their own convenience. Table 4.4: BEME
S/N
Material
Quantity Price per unit (₦)
Total cost (₦)
Capacitors all values in Farad 1.
470p
5
30
150
2.
100p
5
30
150
3.
560p
5
30
150
4.
220μ
6
30
180
5.
100n
4
30
120
6.
0.1μ
15
30
450
7.
100μ
10
30
300
Diodes 8.
1N704A (zener)
2
10
20
9.
1N4004A
12
10
120
6
5
30
Resistors (All values in Ohms) 10. 470k
82
11. 1k
8
5
40
12. 6.8k
2
5
40
13. 3.9k
2
5
40
14. 200
2
5
10
15. 1k variable
2
20
40
16. 5k variable
2
20
40
17. HCPL 7800A
2
700
1400
18. TLE2082CP
2
700
1400
19. LM7805
2
50
100
20. LM7815
1
50
50
21. LM7915
1
50
50
22. Arduino Uno board
1
5000
5000
23. Two terminal Connector
1
200
200
24. Three terminal connector
1
300
300
down 1
500
500
Integrated Circuits
Others
25. Centertapped
step
transformer (220V→15V015V)
83
26. 2x2
step
down
transformer 1
300
300
1
750
750
28. Banana Male and female
8
100
800
29. PCB production
1
1000
1000
30. 1mm flex wire
1 yard
60
60
31. Probes
2
150
300
220V→6V 27.
Plastic box for packaging
Total
14 090
84
CHAPTER FIVE CONCLUSION AND RECOMMENDATION 5.1 Conclusion In summary the Arduino based oscilloscope project was borne out of the need for engineers, hobbyists and students to have access to the fundamental functionalities of an oscilloscope. At the end of the project, a 10bit resolution oscilloscope with a 5 kHz bandwidth capacity and with 6 input ports for displaying different waveforms was precipitated. This accomplishment would not only create a formal document for this design but would also equip the target group with a device that would help them to produce more efficient systems. In the process of accomplishing this project, some challenges were of course encountered which included the components used for especially for the AC measurement was farfetched, purchase of extra components in order to make sure the system was functional. Lack of technical knowhow at some point in the design, putting the project report in a way that would be conventionally good, and so on. Nevertheless, with the help of God, my supervisor, some system engineers, friends and thorough research and hard work, some of the challenges were overcame. Challenges that occurred in the project and the possible solutions are given below; 85
Challenge: Getting the correct driver for the Arduino Uno USB 2.0Serial, this is the driver that enables the COM port of the PC to communicate to the Arduino. Solution: Download the driver from driver scape website, make sure you pick the driver that matches the Operating System of the user. Challenge: The frequency at which the analog inputs read the incoming signals affected the wave form, it made a square waveform look like a sawtooth wave form. Solution: Make sure you match the frequency at which the circuit that is to be measured oscillates with the frequency at which the oscilloscope reads the value in order to get a good shape. This project has more room for improvements and these improvements are written below; Firstly, through the use of a better PCB technology the size of the circuit can be made more compact, thus reducing the cost for the production and the packaging of the system. Secondly, a communication interface can be connected to the PC in such a way that it can send graphical data to a handheld device, through a network protocol in order to overcome distance barrier where necessary. Thirdly, the measurement bandwidth and the amount of input ports and the resolution of the oscilloscope can be increased when an Arduino board that has higher specifications is utilised for the logic analyser/oscilloscope.
86
This written document has added a tangible addition to the body of knowledge in the world of Arduino’s utilities and also to the creation of equipment commonly used by engineers in the design of circuits. Armed with the information provided here the target group can build similar designs and make some modifications where necessary. When such designs are made this system can be made readily available in educational and research institutions for its intended purposes. 5.2 Recommendations From the experience gained from this project so far, the following recommendations would facilitate quicker and better results in building the system. Ensure that a proper test of the circuit is achieved before the circuit is being produced on a PCB design. This will enable the producer to make minimal mistakes and design errors. The use of proper and more durable materials should be used for packaging the system, so that external factors would not affect the connections of the internal circuitry even in extreme cases. Ensure that extreme care is taken when measuring AC voltage signals. Plug the AC voltage directly to the input of the voltage sensing card and make sure it is grounded before you measure it. Failure to do this can cause damage to the Arduino board and in extreme cases damage the PC. Extreme care should be observed when dealing with AC voltages.
87
I also recommend that the product precipitated from this project should be used in the electronics lab of Nnamdi Azikiwe University, Awka so that students can have more insight of what is being taught in lectures. Ensure that the components used in developing the circuits of the system stay within the specified range in comparison in order to avoid inconsistencies. I also recommend that the electronics lab under the supervision of the Department of Electronic and Computer Engineering of Nnamdi Azikiwe University, Awka should be provided with a PCB printing machine. This would facilitate construction of circuits by the students especially during projects and some assignments, as this would encourage students’ initiative, and improve indigenous technology in the nation to a great extent.
88
REFERENCES
[1] “Wikipedia,” [Online]. Available: www.wikiquotes.com/Measurements. [2] ebay, “Ebay oscilloscpes,” [Online]. Available: http://www.ebay.com/bhp/tektronixdigitaloscilloscope. [Accessed 2 September 2015].
[3] Tektronix, “Tektronix: The World's Standard in Digital Oscilloscopes,” Tektronix, [Online]. Available: http://www.tek.com/digitaloscilloscope. [Accessed 12 September 2015]. [4]
H. B. Jonathan Oxer, Practical Arduino, Technology in Action, 2009.
[5] K.Prashanthi, N.Swetha Reddy, N.Kavya, G.Alekhya, “GRIET,” 20 November 2013 . [Online]. Available: www.grietinfo.com/projects. [Accessed 20 June 2015]. [6]
Ritika, Preeti Kumari, Prem Ranjan Dubey , “open electronics,” 22 May
2013. [Online]. Available: http://www.openelectronics.org/wp content/uploads/2013/09/DESIGNINGAPCOSCILLOSCOPEUSING FREEDUINO.pdf. [Accessed 20 July 2015]. [7]
“instructables.com,” instructable DIY, 21 October 2012. [Online].
Available: www.instrucatbles.com/Girinio. [Accessed 08 July 2015]. 89
[8]PIC dual channel scope, 1st ed. 2008. [9]
“Electronics Lab,” [Online]. Available: http://www.electronics
lab.com/arduinolcdoscilloscope/. [Accessed 12 September 2015]. [10]Universial design Methodology, 1st ed. 2015. [11] Freetutes.com, 'Systems Analysis and Design Software Engineering Tutorial', 2015. [Online]. Available: http://www.freetutes.com/systemanalysis/. [Accessed: 13 Sep 2015]. [12] Wikipedia, 'Systems analysis', 2015. [Online]. Available: https://en.wikipedia.org/wiki/Systems_analysis. [Accessed: 14 Sep 2015]. [13]HCPL-7800 - Avago Technologies, 1st ed. 2015. [14] CH.S.A.L.PAVANI, SRUTHI MATHEW, SAMA SWETHA, “Voltage Sensing Card,” 2011. [Online]. Available: www.grietinfo.com/projects. [Accessed 20 August 2015].
[15] Powerguru.org, 'Using Optical Isolation Amplifiers In Power Inverters For Voltage, Current And Temperature Sensing | Powerguru Power Electronics Information Portal'. N.p., 2015. Web. 30 Aug. 2015. [16] Arduino, “Arduino.cc,” 1 September 2015. [Online]. Available: www.arduino.cc/ArduinoUno. [Accessed 4 September 2015].
90
[17] “ATmega48PA/88PA/168PA/328P,” Atmel, October 2009. [Online]. Available: http://www.atmel.com/Images/doc8161.pdf. [Accessed 28 August 2015]. [18] Allaboutcircuits.com, 'Successive Approximation ADC: DigitalAnalog Conversion Electronics Textbook'. N.p., 2015. Web. 30 Aug. 2015. [19]J. Oxer and H. Blemings, Practical Arduino. [Berkeley, CA]: Apress, 2009. [20]Yates, Darren. 'Arduino's AnalogToDigital Converter: How It Works APC'. APC. N.p., 2014. Web. 30 Aug. 2015. [21] Sozański, Krzysztof. Digital Signal Processing In Power Electronics Control Circuits. London: Springer, 2013. Print. [22] MegunoLink, 'Time Plot', 2014. [Online]. Available: http://www.megunolink.com/documentation/plotting/timeplot/. [Accessed: 30 Aug 2015]. [23] Hey it's my blog..., 'Improving Arduino to PC Interactions with MegunoLink', 2012. [Online]. Available: https://johnboxall.wordpress.com/2012/06/27/improvingarduinotopc interactionswithmegunolink/. [Accessed: 13 Sep 2015]. [24] Wikipedia, 'System integration', 2015. [Online]. Available: https://en.wikipedia.org/wiki/System_integration. [Accessed: 14 Sep 2015].
91
APPENDIX A Arduino program for single input display: #include GraphSeries g_aGraphs[] = {"A1”} void setup() { Serial.begin(9600);
// The data is sent via the serial port
pinMode(A1,INPUT); } void loop() { g_aGraphs[0].SendData(analogRead(A1)); // Read values from the ADC converter and send them out the serial port. delay(5); }
92
APPENDIX B Arduino program for performing operations #include
GraphSeries g_aGraphs[] = {"A1","A2","v3"}; void setup() { // The data is sent via the serial port. Initialize it. Serial.begin(9600); pinMode(A1,INPUT); pinMode(A2,INPUT); } void loop() { // Read values from the ADC converter and send them out the serial port. float v1=analogRead((A1)); float v2=analogRead((A2)); float v3=v1+v2; g_aGraphs[0].SendData(analogRead(A1)); 93
g_aGraphs[1].SendData(analogRead(A2));
94
APPENDIX C /* ****************************************************************** **************************** * Example program to plot data from the analoge to digital converter on a chart. * By Osisiogu Ukachi for the Arduino based Oscilloscope/Logic analyser project * * ****************************************************************** **************************** */ #include "MegunoLink.h" // Helpful functions for communicating with MegunoLink Pro. // Millis value when the data was last sent. long LastSent; // Interval (milliseconds) between sending analog data const unsigned SendInterval = 200; // [ms] // The plot we are sending data to. A TimePlot is used here TimePlot MyPlot1("Voltage 1"); TimePlot MyPlot2("Voltage 2"); TimePlot MyPlot3("Voltage 3"); TimePlot MyPlot4("Voltage 4"); TimePlot MyPlot5("Voltage 5"); TimePlot MyPlot6("Voltage 6"); void setup() { Serial.begin(9600); LastSent = millis(); MyPlot1.SetTitle("My Analog 1 Measurement"); MyPlot1.SetXlabel("Time"); MyPlot1.SetYlabel("Value"); MyPlot1.SetSeriesProperties("ADCValue1", Plot::Magenta, Plot::Solid, 2, Plot::Square); 95
MyPlot2.SetTitle("My Analog 2 Measurement"); MyPlot2.SetXlabel("Time"); MyPlot2.SetYlabel("Value"); MyPlot2.SetSeriesProperties("ADCValue2", Plot::Blue, Plot::Solid, 2, Plot::Square); MyPlot3.SetTitle("My Analog 3 Measurement"); MyPlot3.SetXlabel("Time"); MyPlot3.SetYlabel("Value"); MyPlot3.SetSeriesProperties("ADCValue3", Plot::Red, Plot::Solid, 2, Plot::Square); MyPlot4.SetTitle("My Analog 4 Measurement"); MyPlot4.SetXlabel("Time"); MyPlot4.SetYlabel("Value"); MyPlot4.SetSeriesProperties("ADCValue4", Plot::Black, Plot::Solid, 2, Plot::Square); MyPlot5.SetTitle("My Analog 5 Measurement"); MyPlot5.SetXlabel("Time"); MyPlot5.SetYlabel("Value"); MyPlot5.SetSeriesProperties("ADCValue5", Plot::Green, Plot::Solid, 2, Plot::Square); MyPlot6.SetTitle("My Analog 6 Measurement"); MyPlot6.SetXlabel("Time"); MyPlot6.SetYlabel("Value"); MyPlot6.SetSeriesProperties("ADCValue6", Plot::Purple, Plot::Solid, 2, Plot::Square);
} void loop() { if ((millis() LastSent) > SendInterval) { LastSent = millis(); float DataValue1 = analogRead(0); float DataValue2 = analogRead(1); 96
float DataValue3 = analogRead(2); float DataValue4 = analogRead(3); float DataValue5 = analogRead(4); float DataValue6 = analogRead(5); DataValue1 = analogRead(0)*(float)100/(float)1023; //reads 01023V > 0 100% DataValue2 = analogRead(1)*(float)100/(float)1023; //reads 01023V > 0 100% DataValue3 = analogRead(2)*(float)100/(float)1023; //reads 01023V > 0 100% DataValue4 = analogRead(3)*(float)100/(float)1023; //reads 01023V > 0 100% DataValue5 = analogRead(4)*(float)100/(float)1023; //reads 01023V > 0 100% DataValue6 = analogRead(5)*(float)100/(float)1023; //reads 01023V > 0 100% MyPlot1.SendData("ADCValue1", DataValue1); MyPlot2.SendData("ADCValue2", DataValue2); MyPlot3.SendData("ADCValue3", DataValue3); MyPlot4.SendData("ADCValue4", DataValue4); MyPlot5.SendData("ADCValue5", DataValue5); MyPlot6.SendData("ADCValue6", DataValue6); delay (10) } }
97