Vous êtes sur la page 1sur 84

2-Channel-PC-Based Oscilloscope 2011

Table of Content List of Figures ........................................................................................................ 5 List of Tables ......................................................................................................... 7 CHAPTER-1 .......................................................................................................... 8 INTRODUCTION ................................................................................................. 8 1.1 Background of the problem .......................................................................... 9 1.2 Statement of the problem ............................................................................10 CHAPTER-2 .........................................................................................................11 PROJECT OVERVIEW .......................................................................................11 2.1 VIEW OF PROJECT ..................................................................................12 2.2 Advantages of the PC-Based Oscilloscope ..................................................12 2.3 Circuit Diagram of Project ..........................................................................13 2.3.1 CIRCUIT DESCRIPTION ...................................................................14 2.3.2 OPERATION .......................................................................................15 CHAPTER-3 .........................................................................................................17 PIC18F2550 Microcontroller ................................................................................17 3.1 Description ..................................................................................................18 3.2 New Core Features ......................................................................................18 3.2.2 UNIVERSAL SERIAL BUS (USB) .....................................................18 3.2.3 MULTIPLE OSCILLATOR OPTIONS AND FEATURES .................19 3.3 Other Special Features ................................................................................20 3.4 Internal Block Diagram of PIC18F2550 (28-Pin) ........................................22 3.5 Pin out Diagram of PIC18F2550 Microcontroller .......................................23 3.6 PIC18F2550 Pin out I/O Description ...........................................................23 3.7 Oscillator Configuration ..............................................................................27 3.7.1 Overview ..............................................................................................27 3.7.2 Oscillator Control .................................................................................27
Inderprastha Engineering College, Ghaziabad Page 1

2-Channel-PC-Based Oscilloscope 2011 3.7.3 Oscillator Types ...................................................................................27 3.7.4 Oscillator Modules and USB Operations ..............................................29 3.7.5 Crystal Oscillator/ Ceramic Oscillator ..................................................30 3.8 RESET ........................................................................................................32 3.8.1 RCON Register ....................................................................................32 3.8.2 Master Clear Reset (MCLR) .................................................................33 3.8.3 POWER-ON RESET (POR) ................................................................35 3.8.4 BROWN OUT RESET (BOR) .............................................................36 3.9 FLASH PROGRAM MEMORY .................................................................37 3.10 USB Overview ..........................................................................................37 3.10.1 Layered Framework ...........................................................................37 3.10.2 FRAMES ...........................................................................................38 3.10.3 USB Transfers ....................................................................................38 3.10.4 POWER .............................................................................................39 3.10.5 ENUMERATION...............................................................................40 3.10.6 DESCRIPTORS .................................................................................40 3.10.7 BUS SPEED .......................................................................................41 3.10.8 CLASS SPECIFICATIONS AND DRIVERS ....................................41 3.10.9 USB Hardware ...................................................................................42 3.11 10 Bit Analog-to-Digital (A/D) Converter Module ....................................43 3.12 A/D Acquisition Requirement ...................................................................50 3.13 Selecting and Configuring Acquisition Time.............................................51 3.13.1 Selecting the Analog-to-Digital Conversion Clock .............................52 CHAPTER-4 .........................................................................................................53 COMPONENTS USED ........................................................................................53 4.1 LF353 DUAL OPERATIONAL AMPLIFIER ............................................54 4.1.1 General Description ..............................................................................54
Inderprastha Engineering College, Ghaziabad Page 2

2-Channel-PC-Based Oscilloscope 2011 4.1.2 Typical Connection ..............................................................................55 4.1.3 Connection Diagram ............................................................................55 4.1.4 Application of LF353 in our Project .....................................................55 4.2 MCP6S91 Low gain PGA ...........................................................................56 4.2.1Description ............................................................................................56 4.2.2 Block Diagram .....................................................................................56 4.2.3 Package Types......................................................................................56 4.2.4 Pin Functional Table ............................................................................56 4.2.5 Pin Description .....................................................................................57 4.2.6 Typical Applications ............................................................................58 4.3 ICL7660 - SWITCHED CAPACITOR VOLTAGE CONVERTERS ..........59 4.3.1 General Description ..............................................................................59 4.3.2 Features ................................................................................................59 4.3.3 Typical Operating Circuit .....................................................................59 4.3.4 Pin Configurations ...............................................................................60 4.3.5 Application of ICL7660 in our Project .................................................60 CHAPTER-5 .........................................................................................................61 PCB Designing Process ........................................................................................61 5.1 Introduction.................................................................................................62 5.2 Material required .........................................................................................62 5.3 Procedure ....................................................................................................62 5.4 Precautions While Designing PCB .............................................................63 CHAPTER 6 .........................................................................................................64 SOFTWARES .....................................................................................................64 6.1 Microcontrollers Programming ..................................................................65 6.1.1 Microcontroller Programming and Code ..............................................66 6.2 Graphical User Interface Development using Visual Basic 6.0....................70
Inderprastha Engineering College, Ghaziabad Page 3

2-Channel-PC-Based Oscilloscope 2011 6.2.1 Communication with PIC Microcontroller and Visual Basic 6 .............70 CHAPTER 7 .........................................................................................................73 INSTALLATION AND WORKING ....................................................................73 OF THE PROJECT ...............................................................................................73 7.1 Installation Steps .........................................................................................74 7.2 Project Working ..........................................................................................79 CHAPTER-8 .........................................................................................................81 CONCLUSION ....................................................................................................81 8.1Applications .................................................................................................82 8.2 Future aspects .............................................................................................83 REFERENCE .......................................................................................................84

Inderprastha Engineering College, Ghaziabad

Page 4

2-Channel-PC-Based Oscilloscope 2011

List of Figures
Figure 2- 1 2-Channel-PC Based Oscilloscope ..................................................13 Figure 3 - 1 Internal Block Diagram of PIC18F2550 ............................................22 Figure 3 - 2 PINOUT DIAGRAM OF PIC18F2550 ..............................................23 Figure 3 - 3 PIC18F2550 CLOCK DIAGRAM .....................................................29 Figure 3 - 4 CRYSTAL/CERAMIC RESONATOR OPERATION ......................30 Figure 3 - 5 Simplified Block Diagram of ON-CHIP RESET Circuit...................33 Figure 3 - 6 RCON: RESET Control Register ......................................................34 Figure 3 - 7 External POWER-ON Reset Circuit ..................................................35 Figure 3 - 8 USB Layers ......................................................................................38 Figure 3 - 9 Example of a USB Transaction and Interrupt Events .........................39 Figure 3 - 10 USB Connectors .............................................................................42 Figure 3 - 11 Pin-Out of USB Connectors' ............................................................42 Figure 3 - 12 USB Connector PIN Assignment .....................................................43 Figure 3 - 13 A/D Converter Block Diagram ........................................................47 Figure 3 - 14 A/D Transfer Function .....................................................................49 Figure 3 - 15 Analog Input Models .......................................................................49 Figure 3 - 16 Acquisition Time .............................................................................50 Figure 3 - 17 A/D Minimum Charging Time.........................................................50 Figure 3 - 18 Calculating the Minimum Acquisition Time Required .....................51 Figure 4 - 1 Typical Connection Diagram .............................................................55 Figure 4 - 2 Pin Out Diagram ................................................................................55 Figure 4 - 4 Pin Out Diagram of MCP6S91 ..........................................................56 Figure 4 - 3 Block Diagram of MCP6S91 .............................................................56 Figure 4 - 5 Gain Ranging Circuit .........................................................................58
Inderprastha Engineering College, Ghaziabad Page 5

2-Channel-PC-Based Oscilloscope 2011 Figure 4 - 6 Negative Voltage Converter ..............................................................59 Figure 4 - 8 Circuit for Generating Negative Power Supply ..................................60 Figure 4 - 7 Pin Diagram of ICL7660 ...................................................................60 Figure 5- 1 Printout Taken by Express PCB Software ...........................................63 Figure 6- 1 MikroC Interface ................................................................................65 Figure 6- 2 MPLAB IDE Interface ........................................................................66 Figure 6- 3 WinPic Programmer Interface ............................................................69 Figure 6- 4 Visual Basic 6.0 Interface ...................................................................70 Figure 6- 5 EasyHID Interface ..............................................................................71 Figure 6- 6 Visual Basic Code Generated by EasyHID .........................................71 Figure 6- 7 Final GUI in Visual Basic 6.0 .............................................................71 Figure 6- 8 Final GUI ...........................................................................................72 Figure 7 - 2 USB2-Mini Oscilloscope Detected on Host Computer ......................75 Figure 7 - 3 Hardware Installation Wizard. ...........................................................75 Figure 7 - 4 Choose Advanced Option Radio Button for installing the Drivers Manually. ..............................................................................................................76 Figure 7 - 5 Choose the Drivers from Specified Location .....................................76 Figure 7 - 6 Driver Installation Continued.............................................................77 Figure 7 - 7 Driver Installation Continued .........................................................77 Figure 7 - 8 Driver Installation Completed ............................................................78 Figure 7 - 9 New Hardware is ready to use. ..........................................................78 Figure 7 - 10 USB2-Mini Oscilloscope gets successfully connected to host ..........79 Figure 7 - 11 Sine Wave Comparison ...................................................................79 Figure 7 - 12 Square Wave Comparision ..............................................................80 Figure 7 - 13 Ramp Wave Comparison .................................................................80

Inderprastha Engineering College, Ghaziabad

Page 6

2-Channel-PC-Based Oscilloscope 2011

List of Tables
TABLE 3 - 1 DEVICE FEATURES .....................................................................21 TABLE 3 - 2 PIC18F2550 PINOUT I/O DESCRIPTION ....................................23 TABLE 3 - 3 PIC18F2550 PINOUT I/O DESCRIPTION CONTINUED... ..........24 TABLE 3 - 4 PIC18F2550 PINOUT I/O DESCRIPTION CONTINUED... ..........25 TABLE 3 - 5 PIC18F2550 PINOUT I/O DESCRIPTION CONTINUED... ..........26 TABLE 3 - 6 CAPACITOR SELECTION FOR CERAMIC RESONATORS ......31 TABLE 3 - 7 CAPACITOR SELECTION FOR CRYSTAL OSCILLATOR .......31 TABLE 3 - 8 BOR Configurations .......................................................................36 TABLE 3 - 9 ADCON0: A/D Control Register 0 ..................................................44 TABLE 3 - 10 ADCON1: A/D Control Register 1 ................................................45 TABLE 3 - 11 ADCON2: A/D Control Register 2 ................................................46 TABLE 3 - 12 TAD Vs Device Operating Frequency ...........................................52 Table 4- 1Pin Functional Table .............................................................................57

Inderprastha Engineering College, Ghaziabad

Page 7

2-Channel-PC-Based Oscilloscope 2011

CHAPTER-1 INTRODUCTION

Inderprastha Engineering College, Ghaziabad

Page 8

2-Channel-PC-Based Oscilloscope 2011 1.1 Background of the problem Oscilloscopes traditionally are hardware based using a CRT (Cathode Ray Tube) designed to display voltage variations (periodic or otherwise); they are bulky, expensive and have difficultly displaying low frequency waveform.

Figure 1 - 1 Conventional Digital CRO

Figure 1 - 2 Conventional Analog CRO

The heart of the traditionally CRT oscilloscope is the display screen itself, the CRT. The CRT is a glass bulb which has had the air removed and then been sealed with a vacuum inside. At the front is a flat glass screen, which is coated inside with a phosphor material. This phosphor will glow when struck by the fast moving electrons and produce light, emitted from the front and forming the spot and hence the trace. The rear of the CRT contains the electron gun assembly. A small heater element is contained within a cylinder of metal called the cathode. When the heater is activated by applying a voltage across it, the cathode temperature rises and it then emits a stream of electrons.

Inderprastha Engineering College, Ghaziabad

Page 9

2-Channel-PC-Based Oscilloscope 2011 1.2 Statement of the problem More and more experiments are now PC-assisted. In addition, conventional acquisition systems are very expensive. Since portable PCs are today common and a USB link is a better solution than an old ISA bus, here we present an oscilloscope using USB port of the PC that operates at up to 10 kHz with 16V input voltage. . The oscilloscope uses IC PIC18F2550 from Microchip as the main controller, which makes the oscilloscope compact, as there is no need of additional power supply for the entire circuit board.

Inderprastha Engineering College, Ghaziabad

Page 10

2-Channel-PC-Based Oscilloscope 2011

CHAPTER-2 PROJECT OVERVIEW

Inderprastha Engineering College, Ghaziabad

Page 11

2-Channel-PC-Based Oscilloscope 2011 2.1 VIEW OF PROJECT This project attempts to achieve the same functionality as a traditional oscilloscope, using a PIC microcontroller for data acquisition (including appropriate analogue circuitry) which transfers the data to the PC through USB. A Microsoft Windows based software application will then display the waveform, as it would appear on a traditional CRT oscilloscope. This software application will have additional features not present on a traditional oscilloscope with greater flexibly as additional features can be added as they can be developed without the need for new hardware. 2.2 Advantages of the PC-Based Oscilloscope: Large screen using data projector for demonstration purposes. Remote monitoring (e.g. via the internet remotely control / view the oscilloscope from anywhere in the world). Low cost. Software Upgradeable.

Inderprastha Engineering College, Ghaziabad

Page 12

2-Channel-PC-Based Oscilloscope 2011 2.3 Circuit Diagram of Project

Figure 2- 1 2-Channel-PC Based Oscilloscope

Inderprastha Engineering College, Ghaziabad

Page 13

2-Channel-PC-Based Oscilloscope 2011 2.3.1 CIRCUIT DESCRIPTION At the heart of this oscilloscope is USB2.0-compliant microcontroller PIC18F2550 from Microchip. We can also use PIC18F2445 in place of PIC18F2550. Specifications these microcontrollers are as follows:

Programming 1. Up to 32 kB of flash memory, 2kB RAM and 256-byte EEPROM 2. Extended instruction set (optimized for C compiler) 3. 8x8 single-cycle multiplier 4. Single-supply serial programming and easy debugging USB transceiver 1. USB1.1 and 2.0 from 1.5 MB/s to 12 MB/s 2. Isochronous, bulk and interrupt transfer modes 3. 1 kB of access RAM usable with 32 endpoints (64 bytes each) Multiple oscillator and power modes 1. From internal 31 kHz to external 48 MHz with PLL 2. Possible software switching between run, idle and sleep modes. In sleep mode, current is down to 0.1 A. 3. Wide operating voltage range (2.0V to 5.5V). Useful for battery operations. Complete set of classical peripherals 1. Several input/output (I/O) ports, four timers with capture/compares 2. Synchronous and asynchronous enhanced modules 3. Streaming parallel port 4. 10-bit ADC module with up to 13-channel multiplexer.

Inderprastha Engineering College, Ghaziabad

Page 14

2-Channel-PC-Based Oscilloscope 2011 2.3.2 OPERATION Figure 2- 1shows the circuit of the 2-Channel-PC Based Oscilloscope. MCP6S91 from Microchip Technology is an analogue programmable gain amplifier that is well suited for driving analogue-to digital converters (ADCs) and an analogue input to a PIC microcontroller. Two MCP6S91 programmable gain amplifiers (IC2 and IC3) make it possible to choose the input ranges for each of the two channels, by selecting a gain from 1:1 to32:1. The amplifiers are small, cheap and easy to use. A simple three-wire serial peripheral interface (SPI) allows the PIC to control them through its pins 5, 6 and 7. The MCP6S91 amplifier is designed with CMOS input devices. It is designed to not exhibit phase inversion when the input pins exceed the supply voltages. The maximum voltage that can be applied to the input pin is 0.3V (VSS) to +0.3V (VDD). Input voltages that exceed this absolute maximum rating can cause excessive current into or out of the input pins. Current beyond 2mA can cause reliability problems. Applications that exceed this rating must be externally limited with a resistor to the input pin. Vref (pin 3), which is an analogue input, should be at a voltage between V SS and VDD. The voltage at this pin shifts the output voltage. The SP Interface inputs are chip-select (CS), serial input (SI) and serial clock (SCK). These are Schmitttriggered, CMOS logic inputs. The only disadvantage is that these amplifiers accept only positive signals .Thats why voltage-shifting amplifiers LF353 (IC4A and IC5A) are used, one each for each channel input (see Figure 2- 1). The LF353 is a JFET input operational amplifier with an internally compensated input offset voltage. The JFET input device provides wide bandwidth, low input bias currents and offset currents. This voltage-shifting amplifier results in high input impedance and an attenuation factor of 1:4.5.A 16V input signal is then shifted to the 0-5V range when the programmed gain is 1:1. Two halves of the LF353 (IC4B and IC5B) are used as voltage followers to provide a low-impedance shifting voltage (Vref) to the programmable amplifiers. This voltage must be precisely adjusted with two 4.7-kiloohm presets to measure precisely 2.5V level on the inputs of IC2 and IC3 when the input signals are grounded. Because LF353 Op-Amps need a symmetrical supply voltage, a small DC-DC voltage converter ICL7660 (IC6) is used to feed 5V to LF353. With its small 8pin DIP package, it needs only two polarized capacitors. ICL7660 can be replaced
Inderprastha Engineering College, Ghaziabad Page 15

2-Channel-PC-Based Oscilloscope 2011 with a MAX1044. TheMAX1044 and ICL7660 is monolithic, CMOSs witchedcapacitor voltage converters that invert, double, divide or multiply a positive input voltage.

Inderprastha Engineering College, Ghaziabad

Page 16

2-Channel-PC-Based Oscilloscope 2011

CHAPTER-3 PIC18F2550 Microcontroller

Inderprastha Engineering College, Ghaziabad

Page 17

2-Channel-PC-Based Oscilloscope 2011 3.1 Description The PIC18F2550 is 28-Pin High Performance, Enhanced Flash, USB Microcontroller with nano-watt technology. This family of devices offers the advantages of all PIC18 microcontrollers namely, high computational performance at an economical price with the addition of high endurance, Enhanced Flash program memory. In addition to these features, the PIC18F2455/2550/4455/4550 family introduces design enhancements that make these microcontrollers a logical choice for many high-performances, power sensitive applications. 3.2 New Core Features 3.2.1 NanoWatt Technology All of the devices in the PIC18F2455/2550/4455/4550 family incorporate a range of features that can significantly reduce power consumption during operation. Key items include: Alternate Run Modes: By clocking the controller from the Timer1 source or the internal oscillator block, power consumption during code execution can be reduced by as much as 90%. Multiple Idle Modes: The controller can also run with its CPU core disabled but the peripherals still active. In these states, power consumption can be reduced even further, to as little as 4% of normal operation requirements. On-the-Fly Mode Switching: The power-managed modes are invoked by user code during operation, allowing the user to incorporate power-saving ideas into their applications software design. Low Consumption in Key Modules: The power requirements for both Timer1 and the Watchdog Timer are minimized. See Section Electrical Characteristics for values. 3.2.2 UNIVERSAL SERIAL BUS (USB) Devices in the PIC18F2455/2550/4455/4550 family incorporate a fully featured Universal Serial Bus communications module that is compliant with the USB Specification Revision 2.0. The module supports both low-speed and full-speed communication for all supported data transfer types. It also incorporates its own
Inderprastha Engineering College, Ghaziabad Page 18

2-Channel-PC-Based Oscilloscope 2011 on-chip transceiver and 3.3V regulator and supports the use of external transceivers and voltage regulators. 3.2.3 MULTIPLE OSCILLATOR OPTIONS AND FEATURES All of the devices in the PIC18F2455/2550/4455/4550 family offer twelve different oscillator options, allowing users a wide range of choices in developing application hardware. These include: Four Crystal modes using crystals or ceramic resonators. Four External Clock modes, offering the option of using two pins (oscillator input and a divide-by-4 clock output) or one pin (oscillator input, with the second pin reassigned as general I/O). An internal oscillator block which provides an 8 MHz clock (2% accuracy) and an INTRC source (approximately 31 kHz, stable over temperature and VDD), as well as a range of 6 user-selectable clock frequencies, between 125 kHz to 4 MHz, for a total of 8 clock frequencies. This option frees an oscillator pin for use as an additional general purpose I/O. A Phase Lock Loop (PLL) frequency multiplier, available to both the High-Speed Crystal and External Oscillator modes, which allows a wide range of clock speeds from 4 MHz to 48 MHzs Asynchronous dual clock operation, allowing the USB module to run from a high-frequency oscillator while the rest of the microcontroller is clocked from an internal low-power oscillator. Besides its availability as a clock source, the internal oscillator block provides a stable reference source that gives the family additional features for robust operation: Fail-Safe Clock Monitor: This option constantly monitors the main clock source against a reference signal provided by the internal oscillator. If a clock failure occurs, the controller is switched to the internal oscillator block, allowing for continued low-speed operation or a safe application shutdown. Two-Speed Start-up: This option allows the internal oscillator to serve as the clock source from Power-on Reset, or wake-up from Sleep mode, until the primary clock source is available.
Inderprastha Engineering College, Ghaziabad Page 19

2-Channel-PC-Based Oscilloscope 2011 3.3 Other Special Features Memory Endurance: The Enhanced Flash cells for both program memory and data EEPROM are rated to last for many thousands of erase/write cycles up to 100,000 for program memory and 1,000,000 for EEPROM. Data retention without refresh is conservatively estimated to be greater than 40 years. Self-Programmability: These devices can write to their own program memory spaces under internal software control. By using a boot-loader routine, located in the protected Boot Block at the top of program memory, it becomes possible to create an application that can update itself in the field. Extended Instruction Set: The PIC18F2455/2550/4455/4550 family introduces an optional extension to the PIC18 instruction set, which adds 8 new instructions and an Indexed Literal Offset Addressing mode. This extension, enabled as a device configuration option, has been specifically designed to optimize re-entrant application code originally developed in high-level languages such as C. Enhanced CCP Module: In PWM mode, this module provides 1, 2 or 4 modulated outputs for controlling half-bridge and full-bridge drivers. Other features include auto-shutdown for disabling PWM outputs on interrupt or other select conditions and auto-restart to reactivate outputs once the condition has cleared. Enhanced Addressable USART: This serial communication module is capable of standard RS-232 operation and provides support for the LIN bus protocol. Other enhancements include Automatic Baud Rate Detection and a 16-bit Baud Rate Generator for improved resolution. When the microcontroller is using the internal oscillator block, the EUSART provides stable operation for applications that talk to the outside world without using an external crystal (or its accompanying power requirement). 10-Bit A/D Converter: This module incorporates programmable acquisition time, allowing for a channel to be selected and a conversion to be initiated, without waiting for a sampling period and thus, reducing code overhead. Dedicated ICD/ICSP Port: These devices introduce the use of debugger and programming pins that are not multiplexed with other microcontroller features.
Inderprastha Engineering College, Ghaziabad Page 20

2-Channel-PC-Based Oscilloscope 2011 Offered as an option in select packages, this feature allows users to develop I/O intensive applications while retaining the ability to program and debug in the circuit.
TABLE 3 - 1 DEVICE FEATURES

Inderprastha Engineering College, Ghaziabad

Page 21

2-Channel-PC-Based Oscilloscope 2011 3.4 Internal Block Diagram of PIC18F2550 (28-Pin)

Figure 3 - 1 Internal Block Diagram of PIC18F2550

Inderprastha Engineering College, Ghaziabad

Page 22

2-Channel-PC-Based Oscilloscope 2011 3.5 Pin out Diagram of PIC18F2550 Microcontroller The Pin out diagram of PIC18F2550 is shown in Figure 3 - 2.

Figure 3 - 2 PINOUT DIAGRAM OF PIC18F2550

3.6 PIC18F2550 Pin out I/O Description


TABLE 3 - 2 PIC18F2550 PINOUT I/O DESCRIPTION

Inderprastha Engineering College, Ghaziabad

Page 23

2-Channel-PC-Based Oscilloscope 2011


TABLE 3 - 3 PIC18F2550 PINOUT I/O DESCRIPTION CONTINUED...

Inderprastha Engineering College, Ghaziabad

Page 24

2-Channel-PC-Based Oscilloscope 2011


TABLE 3 - 4 PIC18F2550 PINOUT I/O DESCRIPTION CONTINUED...

Inderprastha Engineering College, Ghaziabad

Page 25

2-Channel-PC-Based Oscilloscope 2011

TABLE 3 - 5 PIC18F2550 PINOUT I/O DESCRIPTION CONTINUED...

Inderprastha Engineering College, Ghaziabad

Page 26

2-Channel-PC-Based Oscilloscope 2011 3.7 Oscillator Configuration 3.7.1 Overview Devices in the PIC18F2455/2550/4455/4550 family incorporate a different oscillator and microcontroller clock system than previous PIC18F devices. The addition of the USB module, with its unique requirements for a stable clock source, makes it necessary to provide a separate clock source that is compliant with both USB low-speed and full-speed specifications. To accommodate these requirements, PIC18F2455/2550/4455/4550 devices include a new clock branch to provide a 48 MHz clock for full-speed USB operation. Since it is driven from the primary clock source, an additional system of prescalers and postscalers has been added to accommodate a wide range of oscillator frequencies. An overview of the oscillator structure is shown in Figure 3 - 3. Other oscillator features used in PIC18 enhanced microcontrollers, such as the internal oscillator block and clock switching, remain the same. They are discussed later in this chapter. 3.7.2 Oscillator Control The operation of the oscillator in PIC18F2455/2550/4455/4550 devices is controlled through two Configuration registers and two control registers. Configuration registers, CONFIG1L and CONFIG1H, select the oscillator mode and USB prescalers/postscalers options. As Configuration bits, these are set when the device is programmed and left in that configuration until the device is reprogrammed. The OSCCON register (Register 2-2) selects the Active Clock mode; it is primarily used in controlling clock switching in power-managed modes. Its use is discussed in Section Oscillator Control Register. The OSCTUNE register (Register 2-1) is used to trim the INTRC frequency source, as well as select the low-frequency clock source that drives several special features. Its use is described in OSCTUNE Register. 3.7.3 Oscillator Types PIC18F2455/2550/4455/4550 devices can be operated in twelve distinct oscillator modes. In contrast with previous PIC18 enhanced microcontrollers, four of these modes involve the use of two oscillator types at once. Users can program the FOSC3:FOSC0 Configuration bits to select one of these modes:

Inderprastha Engineering College, Ghaziabad

Page 27

2-Channel-PC-Based Oscilloscope 2011 1. XT Crystal/Resonator. 2. XTPLL Crystal/Resonator with PLL enabled. 3. HS High-Speed Crystal/Resonator. 4. HSPLL High-Speed Crystal/Resonator with PLL enabled. 5. EC External Clock with FOSC/4 output. 6. ECIO External Clock with I/O on RA6. 7. ECPLL External Clock with PLL enabled and FOSC/4 output on RA6. 8. ECPIO External Clock with PLL enabled, I/O on RA6. 9. INTHS Internal Oscillator used as microcontroller clock source, HS Oscillator used as USB clock source. 10. INTXT Internal Oscillator used as microcontroller clock source, XT Oscillator used as USB clock source. 11. INTIO Internal Oscillator used as microcontroller clock source, EC Oscillator used as USB clock source, digital I/O on RA6. 12. INTCKO Internal Oscillator used as microcontroller clock source, EC Oscillator used as USB clock source, FOSC/4 output on RA6.

Inderprastha Engineering College, Ghaziabad

Page 28

2-Channel-PC-Based Oscilloscope 2011

Figure 3 - 3 PIC18F2550 CLOCK DIAGRAM

3.7.4 Oscillator Modules and USB Operations Because of the unique requirements of the USB module, a different approach to clock operation is necessary. In previous PICmicro devices, all core and peripheral clocks were driven by a single oscillator source; the usual sources were primary, secondary or the internal oscillator. With PIC18F2455/2550/4455/4550 devices,
Inderprastha Engineering College, Ghaziabad Page 29

2-Channel-PC-Based Oscilloscope 2011 the primary oscillator becomes part of the USB module and cannot be associated to any other clock source. Thus, the USB module must be clocked from the primary clock source; however, the microcontroller core and other peripherals can be separately clocked from the secondary or internal oscillators as before. Because of the timing requirements imposed by USB, an internal clock of either 6 MHz or 48 MHz is required while the USB module is enabled. Fortunately, the microcontroller and other peripherals are not required to run at this clock speed when using the primary oscillator. There are numerous options to achieve the USB module clock requirement and still provide flexibility for clocking the rest of the device from the primary oscillator source. These are detailed in Section Oscillator Settings for USB. 3.7.5 Crystal Oscillator/ Ceramic Oscillator In HS, HSPLL, XT and XTPLL Oscillator modes, a crystal or ceramic resonator is connected to the OSC1and OSC2 pins to establish oscillation. Figure 3 - 4 shows the pin connections. The oscillator design requires the use of a parallel cut crystal.

Figure 3 - 4 CRYSTAL/CERAMIC RESONATOR OPERATION

Note: a. Use of a series cut crystal may give a frequency out of the crystal manufactures specification. b. See TABLE 3 - 6 and TABLE 3 - 7 initial values of C1 and C2. c. RF varies with Oscillator mode chosen. d. A Series Resonator Rs may be required for AT Strip cut-crystal.

Inderprastha Engineering College, Ghaziabad

Page 30

2-Channel-PC-Based Oscilloscope 2011


TABLE 3 - 6 CAPACITOR SELECTION FOR CERAMIC RESONATORS

TABLE 3 - 7 CAPACITOR SELECTION FOR CRYSTAL OSCILLATOR

Inderprastha Engineering College, Ghaziabad

Page 31

2-Channel-PC-Based Oscilloscope 2011

3.8 RESET The PIC18F2455/2550/4455/4550 devices differentiate between various kinds of Reset: a) Power-on Reset (POR) b) MCLR Reset during normal operation c) MCLR Reset during power-managed modes d) Watchdog Timer (WDT) Reset (during execution) e) Programmable Brown-out Reset (BOR) f) RESET Instruction g) Stack Full Reset h) Stack Underflow Reset This section discusses the Resets generated by MCLR, POR and BOR and covers the operation of various start-up timers. The simplified block diagram of On-Chip Reset Circuit is shown in Figure 3 - 5. 3.8.1 RCON Register Device Reset events are tracked through the RCON: RESET Control Register. The lower five bits of the register indicate that a specific Reset event has occurred. In most cases, these bits can only be cleared by the event and must be set by the application after the event. The state of these flag bits, taken together, can be read to indicate the type of Reset that just occurred. This is described in more detail in Section Reset State of Registers. The RCON register also has control bits for setting interrupt priority (IPEN) and software control of the BOR (SBOREN). Interrupt priority is discussed in Section Interrupts. BOR is covered in Section Brown-out Reset (BOR).

Inderprastha Engineering College, Ghaziabad

Page 32

2-Channel-PC-Based Oscilloscope 2011

Figure 3 - 5 Simplified Block Diagram of ON-CHIP RESET Circuit

3.8.2 Master Clear Reset (MCLR) The MCLR pin provides a method for triggering an external Reset of the device. A Reset is generated by holding the pin low. These devices have a noise filter in the MCLR Reset path which detects and ignores small pulses. The MCLR pin is not driven low by any internal Resets, including the WDT. In PIC18F2455/2550/4455/4550 devices, the MCLR input can be disabled with the MCLRE Configuration bit. When MCLR is disabled, the pin becomes a digital input. It is shown in Figure 3 - 7.

Inderprastha Engineering College, Ghaziabad

Page 33

2-Channel-PC-Based Oscilloscope 2011

Figure 3 - 6 RCON: RESET Control Register

Inderprastha Engineering College, Ghaziabad

Page 34

2-Channel-PC-Based Oscilloscope 2011

Figure 3 - 7 External POWER-ON Reset Circuit

3.8.3 POWER-ON RESET (POR) A Power-on Reset pulse is generated on-chip whenever VDD rises above a certain threshold. This allows the device to start in the initialized state when V DD is adequate for operation. To take advantage of the POR circuitry, tie the MCLR pin through a resistor (1 kOhm to 10 kOhm) to VDD. This will eliminate external RC components usually needed to create a Power-on Reset delay. A minimum rise rate for VDD is specified (parameter D004, Section DC Characteristics). For a slow rise time, see Figure 3 - 7. When the device starts normal operation (i.e., exits the Reset condition), device operating parameters (voltage, frequency, temperature, etc.) must be met to ensure operation. If these conditions are not met, the device must be held in Reset until the operating conditions are met. POR events are captured by the POR bit RCON<1>). The state of the bit is set to 0 whenever a POR occurs; it does not change for any other Reset event. POR is not reset to 1 by any hardware event. To capture
Inderprastha Engineering College, Ghaziabad Page 35

2-Channel-PC-Based Oscilloscope 2011 multiple events, the user manually resets the bit to 1 in software following any POR. 3.8.4 BROWN OUT RESET (BOR) PIC18F2455/2550/4455/4550 devices implement a BOR circuit that provides the user with a number of configuration and power-saving options. The BOR is controlled by the BORV1:BORV0 and BOREN1:BOREN0 Configuration bits. There are a total of four BOR configurations which are summarized in TABLE 3 8. The BOR threshold is set by the BORV1:BORV0 bits. If BOR is enabled (any values of BOREN1:BOREN0 except 00), any drop of VDD below VBOR (parameter D005, Section DC Characteristics) for greater than TBOR will reset the device. A Reset may or may not occur if VDD falls below VBOR for less than TBOR. The chip will remain in Brown-out Reset until VDD rises above VBOR. If the Power-up Timer is enabled, it will be invoked after VDD rises above VBOR; it then will keep the chip in Reset for an additional time delay, TPWRT. If VDD drops below VBOR while the Power-up Timer is running, the chip will go back into a Brown-out Reset and the Power-up Timer will be initialized. Once VDD rises above VBOR, the Power-up Timer will execute the additional time delay. BOR and the Power-on Timer (PWRT) are independently configured. Enabling BOR Reset does not automatically enable the PWRT.
TABLE 3 - 8 BOR Configurations

Inderprastha Engineering College, Ghaziabad

Page 36

2-Channel-PC-Based Oscilloscope 2011 3.9 FLASH PROGRAM MEMORY The Flash program memory is readable, writable and erasable, during normal operation over the entire VDD range. A read from program memory is executed on one byte at a time. A write to program memory is executed on blocks of 32 bytes at a time. Program memory is erased in blocks of 64 bytes at a time. A Bulk Erase operation may not be issued from user code. Writing or erasing program memory will cease instruction fetches until the operation is complete. The program memory cannot be accessed during the write or erase, therefore, code cannot execute. An internal programming timer terminates program memory writes and erases. A value written to program memory does not need to be a valid instruction. Executing a program memory location that forms an invalid instruction results in a NOP. Further information on Flash Memory of PIC18F2550 can be obtained from Datasheet.

3.10 USB Overview USB Specifications can be seen from the USB website www.usb.org and the basic details of the USB is also given in PIC18F2550 datasheet. Here we are going to present the brief overview on USB in PIC18F2550 microcontroller. This section presents some of the basic USB concepts and useful information necessary to design a USB device. Although much information is provided in this section, there is a plethora of information provided within the USB specifications and class specifications. Thus, the reader is encouraged to refer to the USB specifications for more information (www.usb.org). If you are very familiar with the details of USB, then this section serves as a basic, high-level refresher of USB. 3.10.1 Layered Framework USB device functionality is structured into a layered framework graphically shown in Figure 3 - 8. Each level is associated with a functional level within the device. The highest layer, other than the device, is the configuration. A device may have
Inderprastha Engineering College, Ghaziabad Page 37

2-Channel-PC-Based Oscilloscope 2011 multiple configurations. For example, a particular device may have multiple power requirements based on Self-Power Only or Bus Power Only modes. For each configuration, there may be multiple interfaces. Each interface could support a particular mode of that configuration. Below the interface is the endpoint(s). Data is directly moved at this level. There can be as many as 16 bidirectional endpoints. Endpoint 0 is always a control endpoint and by default, when the device is on the bus, Endpoint 0 must be available to configure the device.

Figure 3 - 8 USB Layers

3.10.2 FRAMES Information communicated on the bus is grouped into 1 ms time slots, referred to as frames. Each frame can contain many transactions to various devices and endpoints. Figure 3 - 9 shows an example of a transaction within a frame. 3.10.3 USB Transfers There are four transfer types defined in the USB specification. Isochronous: This type provides a transfer method for large amount of data (up to 1023 bytes) with timely delivery ensured, however data integrity is not ensured. This is good for streaming applications where small data loss in not critical such an audio.
Inderprastha Engineering College, Ghaziabad Page 38

2-Channel-PC-Based Oscilloscope 2011 Bulk: This type of transfer method allows for large amount of data to be transferred with ensured data integrity; however the delivery timeliness is not ensured. Interrupt: This type transfer provides for ensured timely delivery for smaller blocks of data plus data integrity is ensured. Control: This type provides for device setup control. While full speed device support all transfer types, while low speed devices are limited to interrupt and control transfer modes.

Figure 3 - 9 Example of a USB Transaction and Interrupt Events

3.10.4 POWER Power is available from the Universal Serial Bus. The USB specification defines the bus power requirements. Devices may either be self-powered or bus powered. Self-powered devices draw power from an external source, while bus powered devices use power supplied from the bus. The USB specification limits the power taken from the bus. Each device is ensured 100 mA at approximately 5V (one unit load). Additional power may be requested, up to a maximum of 500 mA. Note that power above one unit load is a request and the host or hub is not obligated to provide the extra current. Thus, a device capable of consuming more than one unit load must be able to maintain a low-power configuration of a one unit load or less, if necessary.

Inderprastha Engineering College, Ghaziabad

Page 39

2-Channel-PC-Based Oscilloscope 2011 The USB specification also defines a Suspend mode. In this situation, current must be limited to 500 A, averaged over 1 second. A device must enter a Suspend state after 3 ms of inactivity (i.e., no SOF tokens for 3 ms). A device entering Suspend mode must drop current consumption within 10 ms after Suspend. Likewise, when signaling a wake-up, the device must signal a wake-up within 10 ms of drawing current above the Suspend limit. 3.10.5 ENUMERATION When the device is initially attached to the bus, the host enters an enumeration process in an attempt to identify the device. Essentially, the host interrogates the device, gathering information such as power consumption, data rates and sizes, protocol and other descriptive information; descriptors contain this information. A typical enumeration process would be as follows: USB Reset: Reset the devices. Thus, the device is not configured and doesnt have an address (address 0). Get Device Descriptor: The host requests a small portion of device descriptor. USB Reset: Reset the device again. Set Address: The host assigns an address to the device. Get Device Descriptor: The Host retrieves the device descriptor, gathering info such as manufacturer, type of device, maximum control packet size. Get Configuration Descriptors. Get any other descriptor. Set a configuration. The exact enumeration process depends on the host. 3.10.6 DESCRIPTORS There are eight different standard descriptor types of which five are most important for this device. Device Descriptor The device descriptor provides general information, such as manufacturer, product number, serial number, the class of the device and the number of configurations. There is only one device descriptor.
Inderprastha Engineering College, Ghaziabad Page 40

2-Channel-PC-Based Oscilloscope 2011 Configuration Descriptor The configuration descriptor provides information on the power requirements of the device and how many different interfaces are supported when in this configuration. There may be more than one configuration for a device (i.e., lowpower and high-power configurations). Interface Descriptor The interface descriptor details the number of endpoints used in this interface, as well as the class of the interface. There may be more than one interface for a configuration. Endpoint Descriptor The endpoint descriptor identifies the transfer type and direction, as well as some other specifics for the endpoint. There may be many endpoints in a device and endpoints may be shared in different configurations. String Descriptors Many of the previous descriptors reference one or more string descriptors. String descriptors provide human readable information about the layer (3.10.1 Layered Framework) they describe. Often these strings show up in the host to help the user identify the device. String descriptors are generally optional to save memory and are encoded in a Unicode format.

3.10.7 BUS SPEED Each USB device must indicate its bus presence and speed to the host. This is accomplished through a 1.5 k resistor which is connected to the bus at the time of the attachment event. Depending on the speed of the device, the resistor either pulls up the D+ or D- line to 3.3V. For a low-speed device, the pull-up resistor is connected to the D- line. For a full-speed device, the pull-up resistor is connected to the D+ line. 3.10.8 CLASS SPECIFICATIONS AND DRIVERS USB specifications include class specifications which operating system vendors optionally support. Examples of classes include Audio, Mass Storage,
Inderprastha Engineering College, Ghaziabad Page 41

2-Channel-PC-Based Oscilloscope 2011 Communications and Human Interface (HID). In most cases, a driver is required at the host side to talk to the USB device. In custom applications, a driver may need to be developed. Fortunately, drivers are available for most common host systems for the most common classes of devices. Thus, these drivers can be reused.

3.10.9 USB Hardware USB is a four wire interface implemented using a four-core shielded cable. Two types of connectors are specified and used: Type-A and Type-B. The image of Type-A and Type-B USB Connector is shown in Figure 3 - 10.

Figure 3 - 10 USB Connectors

The Pin-Out of USB Connectors is shown in Figure 3 - 11.

Figure 3 - 11 Pin-Out of USB Connectors'

Inderprastha Engineering College, Ghaziabad

Page 42

2-Channel-PC-Based Oscilloscope 2011 The USB Connector Pin assignment is shown in Figure 3 - 12.

Figure 3 - 12 USB Connector PIN Assignment

The specification also defines mini-B connector, mainly used in smaller portable electronic devices such as cameras and other hand-held devices. This connector has a fifth pin called ID, though this pin is not used.

3.11 10 Bit Analog-to-Digital (A/D) Converter Module The Analog-to-Digital (A/D) converter module has 10 inputs for the 28-pin devices. This module allows the conversion of an analog input signal to a corresponding 10-bit digital number. This module has five registers: A/D Result High Register (ADRESH) A/D Result Low Register (ADRESL) A/D Control Register 0 (ADCON0) A/D Control Register 1 (ADCON1) A/D Control Register 2 (ADCON2) All these registers are shown in successive pages. The ADCON0 Register is shown in TABLE 3 - 9, ADCON1 Register is shown in TABLE 3 - 10 and ADCON2 Register is shown in TABLE 3 - 11.

Inderprastha Engineering College, Ghaziabad

Page 43

2-Channel-PC-Based Oscilloscope 2011


TABLE 3 - 9 ADCON0: A/D Control Register 0

Inderprastha Engineering College, Ghaziabad

Page 44

2-Channel-PC-Based Oscilloscope 2011


TABLE 3 - 10 ADCON1: A/D Control Register 1

Inderprastha Engineering College, Ghaziabad

Page 45

2-Channel-PC-Based Oscilloscope 2011

TABLE 3 - 11 ADCON2: A/D Control Register 2

The analog reference voltage is software selectable to either the devices positive and negative supply voltage (VDD and VSS) or the voltage level on the RA3/AN3/VREF+ and RA2/AN2/VREF-/CVREF pins. The A/D converter has a unique feature of being able to operate while the device is in Sleep mode. To operate in Sleep, the A/D conversion clock must be derived from the A/Ds internal RC oscillator.

Inderprastha Engineering College, Ghaziabad

Page 46

2-Channel-PC-Based Oscilloscope 2011 The output of the sample and hold is the input into the converter, which generates the result via successive approximation.

Figure 3 - 13 A/D Converter Block Diagram

A device Reset forces all registers to their Reset state. This forces the A/D module to be turned off and any conversion in progress is aborted. Each port pin associated with the A/D converter can be configured as an analog input or as a digital I/O. The ADRESH and ADRESL registers contain the result of
Inderprastha Engineering College, Ghaziabad Page 47

2-Channel-PC-Based Oscilloscope 2011 the A/D conversion. When the A/D conversion is complete, the result is loaded into the ADRESH: ADRESL register pair, the GO/DONE bit (ADCON0 register) is cleared and A/D Interrupt Flag bit, ADIF, is set. The block diagram of the A/D module is shown in Figure 3 - 13. The value in the ADRESH: ADRESL registers is not modified for a Power-on Reset. The ADRESH: ADRESL registers will contain unknown data after a Poweron Reset. After the A/D module has been configured as desired, the selected channel must be acquired before the conversion is started. The analog input channels must have their corresponding TRIS bits selected as an input. To determine acquisition time, see 3.12 A/D Acquisition Requirement. After this acquisition time has elapsed, the A/D conversion can be started. An acquisition time can be programmed to occur between setting the GO/DONE bit and the actual start of the conversion. The following steps should be followed to perform an A/D Conversion. 1. Configure the A/D module: Configure analog pins, voltage reference and digital I/O (ADCON1) Select A/D input channel (ADCON0) Select A/D acquisition time (ADCON2) Select A/D conversion clock (ADCON2) Turn on A/D module (ADCON0) 2. Configure A/D interrupts (if desired): Clear ADIF bit Set ADIE bit Set GIE bit 3. Wait the required acquisition time (if required). 4. Start conversion: Set GO/DONE bit (ADCON0 register) 5. Wait for A/D conversion to complete, by either: Polling for the GO/DONE bit to be cleared OR Waiting for the A/D interrupt

Inderprastha Engineering College, Ghaziabad

Page 48

2-Channel-PC-Based Oscilloscope 2011 6. Read A/D Result registers (ADRESH: ADRESL); clear bit ADIF, if required. 7. For next conversion, go to step 1 or step 2, as required. The A/D conversion time per bit is defined as TAD. A minimum wait of 3 TAD is required before the next acquisition starts.

Figure 3 - 14 A/D Transfer Function

Figure 3 - 15 Analog Input Models

Inderprastha Engineering College, Ghaziabad

Page 49

2-Channel-PC-Based Oscilloscope 2011 3.12 A/D Acquisition Requirement For the A/D converter to meet its specified accuracy, the charge holding capacitor (CHOLD) must be allowed to fully charge to the input channel voltage level. The analog input model is shown in Figure 3 - 15. The source impedance (RS) and the internal sampling switch (RSS) impedance directly affect the time required to charge the capacitor CHOLD. The sampling switch (RSS) impedance varies over the device voltage (VDD). The source impedance affects the offset voltage at the analog input (due to pin leakage current). The maximum recommended impedance for analog sources is 2.5 k. After the analog input channel is selected (changed), the channel must be sampled for at least the minimum acquisition time before starting a conversion. To calculate the minimum acquisition time, Equation in Figure 3 - 16may be used. This equation assumes that 1/2 LSB error is used (1024 steps for the A/D). The 1/2 LSB error is the maximum error allowed for the A/D to meet its specified resolution. Example in Figure 3 - 18 shows the calculation of the minimum required acquisition time TACQ. This calculation is based on the following application system assumptions: CHOLD = 25 pF Rs = 2.5 k Conversion Error 1/2 LSB VDD = 5V RSS = 2 k Temperature = 85 C (system max.)

Figure 3 - 16 Acquisition Time

Figure 3 - 17 A/D Minimum Charging Time

Inderprastha Engineering College, Ghaziabad

Page 50

2-Channel-PC-Based Oscilloscope 2011

Figure 3 - 18 Calculating the Minimum Acquisition Time Required

3.13 Selecting and Configuring Acquisition Time The ADCON2 register allows the user to select an acquisition time that occurs each time the GO/DONE bit is set. It also gives users the option to use an automatically determined acquisition time. Acquisition time may be set with the ACQT2:ACQT0 bits (ADCON2<5:3>) which provide a range of 2 to 20TAD. When the GO/DONE bit is set, the A/D module continues to sample the input for the selected acquisition time, and then automatically begins a conversion. Since the acquisition time is programmed, there may be no need to wait for an acquisition time between selecting a channel and setting the GO/DONE bit. Manual acquisition is selected when ACQT2:ACQT0 = 000. When the GO/DONE bit is set, sampling is stopped and a conversion begins. The user is responsible for ensuring the required acquisition time has passed between selecting the desired input channel and setting the GO/DONE bit. This option is also the default Reset state of the ACQT2:ACQT0 bits and is compatible with devices that do not offer programmable acquisition times. In either case, when the conversion is completed, the GO/DONE bit is cleared, the ADIF flag is set and the A/D begins sampling the currently selected channel again. If an acquisition time is programmed, there is nothing to indicate if the acquisition time has ended or if the conversion has begun.

Inderprastha Engineering College, Ghaziabad

Page 51

2-Channel-PC-Based Oscilloscope 2011

3.13.1 Selecting the Analog-to-Digital Conversion Clock The A/D conversion time per bit is defined as TAD. The A/D conversion requires 11 TAD per 10-bit conversion. The source of the A/D conversion clock is software selectable. There are seven possible options for T AD: 2 TOSC 4 TOSC 8 TOSC 16 TOSC 32 TOSC 64 TOSC Internal RC Oscillator For correct A/D conversions, the A/D conversion clock (T AD) must be as short as possible but greater than the minimum T AD (see parameter 130 in Table 28-29 for more information). Table 21-1 shows the resultant TAD times derived from the device operating frequencies and the A/D clock source selected.
TABLE 3 - 12 TAD Vs Device Operating Frequency

This is all that is necessary from our project point of view; further information is available in datasheet of PIC18F2550.

Inderprastha Engineering College, Ghaziabad

Page 52

2-Channel-PC-Based Oscilloscope 2011

CHAPTER-4 COMPONENTS USED

Inderprastha Engineering College, Ghaziabad

Page 53

2-Channel-PC-Based Oscilloscope 2011 Some of the other important components used in our project are described in brief in the subsequent sections. They are as follow: LF353 Dual Operation Amplifier MSCP6S91 Gain Amplifier from Microchip Technology ICL7660 Switched Capacitor Voltage Converter 4.1 LF353 DUAL OPERATIONAL AMPLIFIER 4.1.1 General Description These devices are low cost, high speed, wide bandwidth dual JFET input operational amplifiers with an internally trimmed input offset voltage. They require low supply current yet maintain a large gain bandwidth product and fast slew rate. In addition, well matched high voltage JFET input devices provide very low input bias and offset currents. These amplifiers may be used in applications such as high speed integrators, fast D/A converters, sample and hold circuits and many other circuits requiring low input offset voltage, low input bias current, high input impedance, high slew rate and wide bandwidth. The devices also exhibit low noise and offset voltage drift. Features Internally trimmed offset voltage Low input bias current Low input noise voltage Low input noise current Wide gain bandwidth High slew rate Low supply current Low total harmonic distortion Low 1/f noise corner Fast settling time to 0.01% : : : : : : : : : : 10 mV 50pA 25 nV/Hz 0.01 pA/Hz 4 MHz 13 V/s 3.6 mA 0.02% 50 Hz 2 s

Inderprastha Engineering College, Ghaziabad

Page 54

2-Channel-PC-Based Oscilloscope 2011

4.1.2 Typical Connection

Figure 4 - 1 Typical Connection Diagram

4.1.3 Connection Diagram

Figure 4 - 2 Pin Out Diagram

4.1.4 Application of LF353 in our Project There are two applications of LF353 in our Project and they are as follow. It is used as Voltage Shifting Amplifier to shift the negative signal to the positive signal, as the Gain Amplifier IC i.e. MCP6S91 is not able to process the negative signal. Secondly it is used as voltage followers to provide low impedance shifting voltage to Vref pin of Gain Amplifier.

Inderprastha Engineering College, Ghaziabad

Page 55

2-Channel-PC-Based Oscilloscope 2011 4.2 MCP6S91 Low gain PGA 4.2.1Description The Microchip Technology Inc. MCP6S91is analog Programmable Gain Amplifiers (PGAs). They can be configured for gains from +1 V/V to+32 V/V and the input multiplexer can select one of up to two channels through a SPI port. The serial interface can also put the PGA into shutdown to conserve power. These PGAs are optimized for high-speed, low offset voltage and single-supply operation with rail-to-rail input and output capability. These specifications support single supply applications needing flexible performance or multiple inputs. The onechannel MCP6S91 is available in 8-pin PDIP, SOIC and MSOP. All parts are fully specified from -40C to +125C. 4.2.2 Block Diagram

Figure 4 - 3 Block Diagram of MCP6S91

4.2.3 Package Types

Figure 4 - 4 Pin Out Diagram of MCP6S91

4.2.4 Pin Functional Table


Inderprastha Engineering College, Ghaziabad Page 56

2-Channel-PC-Based Oscilloscope 2011


Table 4- 1Pin Functional Table

4.2.5 Pin Description Analog Output The output pin (VOUT) is a low-impedance voltage source. The selected gain (G), selected input (CH0, CH1) and voltage at VREF determine its value. Analog Inputs (CH0, CH1) The inputs CH0 and CH1 connect to the signal sources. They are highimpedance CMOS inputs with low bias currents. The internal MUX selects which one is amplified to the output. External Reference Voltage (VREF) The VREF pin, which is an analog input, should be at a voltage between VSS and VDD (the MCP6S92 has VREF tied internally to VSS). The voltage at this pin shifts the output voltage.

Power Supply (VSS and VDD) The Positive Power Supply Pin (VDD) is 2.5V to 5.5V higher than the Negative Power Supply Pin (VSS). For normal operation, the other pins are at voltages between VSS and VDD. Typically, these parts are used in a single (positive) supply configuration. In this case, VSS is connected to ground and VDD is connected to the supply. VDD will need a local bypass capacitor (typically 0.01 F to 0.1 F) within 2 mm of the VDD pin. These parts can share a bulk capacitor with analog parts (typically 2.2 F to 10 F) within 100 mm of the VDD pin.
Inderprastha Engineering College, Ghaziabad Page 57

2-Channel-PC-Based Oscilloscope 2011

Digital Inputs The SPI interface inputs are: Chip Select (CS), Serial Input (SI) and Serial Clock (SCK). These are Schmitt triggered, CMOS logic inputs. Digital Output The MCP6S93 device has a SPI interface Serial Output (SO) pin. This is a CMOS push-pull output and does not ever go High-Z. Once the device is deselected (CS goes high), SO is forced low.

4.2.6 Typical Applications Gain Ranging Figure 4 - 5 shows a circuit that measures the current IX. The circuits performance benefits from changing the gain on the PGA. Just as a handheld millimeter uses different measurement ranges to obtain the best results, this circuit makes it easy to set a high gain for small signal.

Figure 4 - 5 Gain Ranging Circuit

For further details on MCP6S91 IC from Microchip Technology, one can refer its datasheet, which can be downloaded free of cost from the www.microchip.com.

Inderprastha Engineering College, Ghaziabad

Page 58

2-Channel-PC-Based Oscilloscope 2011 4.3 ICL7660 - SWITCHED CAPACITOR VOLTAGE CONVERTERS 4.3.1 General Description The ICL7660 and MAX1044 is monolithic, CMOS switched-capacitor voltage converters that invert, double, divide, or multiply a positive input voltage. They are pin compatible with the industry-standard ICL7660. Operation is guaranteed from 1.5V to 10V with no external diode over the full temperature range. They deliver 10mA with a 0.5V output drop. The ICL7660 combine low quiescent current and high efficiency. Oscillator control circuitry and four power MOSFET switches are included on-chip. Applications include generating a -5V supply from a +5V logic supply to power analog circuitry. For applications requiring more power, the MAX660 delivers up to 100mA with a voltage drop of less than 0.65V.

4.3.2 Features Miniature MAX Package 1.5V to 10.0V Operating Supply Voltage Range 98% Typical Power-Conversion Efficiency Invert, Double, Divide, or Multiply Input Voltages No-Load Supply Current: 200A Max at 5V No External Diode Required for Higher-Voltage Operation

4.3.3 Typical Operating Circuit

Figure 4 - 6 Negative Voltage Converter

Inderprastha Engineering College, Ghaziabad

Page 59

2-Channel-PC-Based Oscilloscope 2011 4.3.4 Pin Configurations

Figure 4 - 7 Pin Diagram of ICL7660

4.3.5 Application of ICL7660 in our Project In our project this IC is used as Negative Voltage converter to provide symmetrical negative voltage supply to the dual-operational amplifier. The circuit for generating this is shown in Figure 4 - 8.

Figure 4 - 8 Circuit for Generating Negative Power Supply

Inderprastha Engineering College, Ghaziabad

Page 60

2-Channel-PC-Based Oscilloscope 2011

CHAPTER-5 PCB Designing Process

Inderprastha Engineering College, Ghaziabad

Page 61

2-Channel-PC-Based Oscilloscope 2011 5.1 Introduction Making a Printed Circuit Board is the first step towards building electronic equipment by any electronic industry. A number of methods are available for making PCB. The PCB in this project is made in lab with the proper procedure mentioned below. PCB is developed to obtain a conducting circuit diagram on the board. All the path which leads to current flow are developed on board and then desired components are soldered. 5.2 Material required Copper Board. Express PCB software Soldering gun Blue dye UV exposure machine Ferrite Etching solution Steel Wool Photo-Resist solution

5.3 Procedure Layout is developed in Express PCB software, and then its printout is taken as shown in Figure 5- 1. Negative is made with the help of Photo-Contact Machine. With the help of negative the positive is developed on the copper board, this process is given below. A Copper Board is cleaned with steel wool. Copper Board is dipped in photo resist solution and kept to dry. This is kept in UV exposure machine to obtain imprints of circuit on board. The board is dipped in developer and dye and then it is washed. After that it is kept for etching of undesired copper in etching machine. After etching PCB is ready and the holes are drilled and finally components are mounted on it.

Inderprastha Engineering College, Ghaziabad

Page 62

2-Channel-PC-Based Oscilloscope 2011 5.4 Precautions While Designing PCB Add Ferric Chloride (FeCl3) carefully, without any splashing. FeCl3 is irritating to the skin and will stain the clothes. Place the board in solution with copper side up. Try not to breathe in the vapors. Stir the solution by giving see-saw motion to the dish and solution in it. Occasionally the solution is heated to fasten the etching process. After some time the un-shaded parts change their color continue to etch. Gradually the base material will become visible. Etch for two minutes more to get a neat pattern. Don't throw away the remaining FeCl3 solution. It can be used again for next Printed Circuit Board (PCB).

Figure 5- 1 Printout Taken by Express PCB Software

Inderprastha Engineering College, Ghaziabad

Page 63

2-Channel-PC-Based Oscilloscope 2011

CHAPTER 6 SOFTWARES

Inderprastha Engineering College, Ghaziabad

Page 64

2-Channel-PC-Based Oscilloscope 2011 In order to complete 2-Channel-PC Based Oscilloscope Project we have used a number of softwares. They are classified on the basis on their application into two categories: Microcontrollers Programming Graphical User Interface 6.1 Microcontrollers Programming There are two well known and popular softwares available in market for programming PIC series microcontroller, and they are as follow: MPLAB IDE along with Hi-Tech C Compiler from Microchip Technology MikroC for PIC from MikroElektronika Both of these softwares are extremely good, we have used both softwares for our learning purpose but as MikroC doesnt permit to compile the code above 2 kilo bytes in its evaluation version, so we have to go for MPLAB IDE along with HiTech C Compilers. The snapshot of both these softwares are shown in Figure 6- 1and Figure 6- 2.

Figure 6- 1 MikroC Interface

Inderprastha Engineering College, Ghaziabad

Page 65

2-Channel-PC-Based Oscilloscope 2011

Figure 6- 2 MPLAB IDE Interface

6.1.1 Microcontroller Programming and Code The program for the microcontroller is written in C language. MPLAB 7.31 along with MPLAB_C18 is used as the software tool for development. The software tools can be downloaded for free from website www.microchip.com. Based on Microchips application notes, the program for the chip is centered on a main loop continually polling the USB transceiver state. The PIC software consists of eight C program source files, 14 header files and a linker file all under aquis.mcp project. The main C program source file (main.c) is given below.

Inderprastha Engineering College, Ghaziabad

Page 66

2-Channel-PC-Based Oscilloscope 2011 The main.c program is as follow:


/********************************************************************* * * Microchip USB C18 Firmware Version 1.0 * ********************************************************************* * FileName: main.c * Dependencies: See INCLUDES section below /** I N C L U D E S **********************************************************/ #include "p18f2550.h" #include "typedefs.h" // Required #include "usb.h" // Required #include "io_cfg.h" // Required #include "user.h" // Modifiable /** V A R I A B L E S ********************************************************/ #pragma udata extern unsigned char voie1[256]; extern unsigned char voie2[256]; extern unsigned char voiesH1[64],voiesH2[64]; extern char ordre, timeout; /** P R I V A T E P R O T O T Y P E S ***************************************/ static void InitializeSystem(void); void USBTasks(void); void timer_isr(void); /** V E C T O R M A P P I N G **************************************/

extern void _startup (void); // See c018i.c in your C18 compiler dir #pragma code _RESET_INTERRUPT_VECTOR = 0x000800 void _reset (void) { _asm goto _startup _endasm } #pragma code #pragma code low_vector = 0x18 void low_interrupt (void) { _asm goto timer_isr } #pragma code

_endasm

#pragma interruptlow timer_isr //Fixe une periode de 1 seconde pour le time-out aquisition void timer_isr(void) { //Reset l'it du timer 1 INTCONbits.TMR0IF=0; TMR0H= 256-183; TMR0L= 0; timeout++; } /*#pragma code _LOW_INTERRUPT_VECTOR = 0x000818 void low_ISR (void) { ; // incremente le compteur time-out !!

Inderprastha Engineering College, Ghaziabad

Page 67

2-Channel-PC-Based Oscilloscope 2011


}*/ /** D E C L A R A T I O N S **************************************************/ #pragma code /****************************************************************************** * Function: void main(void) * PreCondition: None * Input: None * Output: None * Side Effects: None * Overview: Main program entry point. * Note: None *****************************************************************************/ void main(void) { InitializeSystem(); ordre=0; while(1) { USBTasks(); // USB Tasks ProcessIO(); // See user\user.c & .h }//end while }//end main /****************************************************************************** * Function: static void InitializeSystem(void) * PreCondition: None * Input: None * Output: None * Side Effects: None * Overview: InitializeSystem is a centralize initialization routine. * All required USB initialization routines are called from * here. * User application initialization routine should also be * called from here. *****************************************************************************/ static void InitializeSystem(void) { ADCON1 |= 0x0F; // Default all pins to digital #if defined(USE_USB_BUS_SENSE_IO) tris_usb_bus_sense = INPUT_PIN; // See io_cfg.h #endif #if defined(USE_SELF_POWER_SENSE_IO) tris_self_power = INPUT_PIN; #endif UserInit(); // See user.c & .h // See usbdrv.h

mInitializeUSBDriver(); }//end InitializeSystem

/****************************************************************************** * Function: void USBTasks(void) * PreCondition: InitializeSystem has been called. * Input: None * Output: None * Side Effects: None * Overview: Service loop for USB tasks. *****************************************************************************/ void USBTasks(void) {

Inderprastha Engineering College, Ghaziabad

Page 68

2-Channel-PC-Based Oscilloscope 2011


/* Servicing Hardware */ USBCheckBusStatus(); if(UCFGbits.UTEYE!=1) USBDriverService(); }// end USBTasks /** EOF main.c ***************************************************************/ // Must use polling method // Interrupt or polling method

Rest of the programs are provided by Microchip and are available on the Microchip website ( www.microchip.com ), or one can see all the list of programs in the CD attached at the end of this report. After compiling this code the hex file gets generated, now we have to burn this hex file into the microcontroller. To do this we have used In-Circuit Serial Programmer (ICSP) for programming the microcontroller. The software used for programming is WinPic, its interface is shown in the

Figure 6- 3 WinPic Programmer Interface

Now Microcontrollers programming part is over, now come on to the Graphical User Interface Part.

Inderprastha Engineering College, Ghaziabad

Page 69

2-Channel-PC-Based Oscilloscope 2011 6.2 Graphical User Interface Development using Visual Basic 6.0 As we all are familiar with the fact that Visual Basic is one of the most popular languages for the development of Graphical User Interfaces. The Interface of Visual Basic 6.0 is shown Figure 6- 4.

Figure 6- 4 Visual Basic 6.0 Interface

6.2.1 Communication with PIC Microcontroller and Visual Basic 6 There are several tools available over the internet for initiating the communication with PIC Microcontrollers and Computers. One such software which we have used in our project is EasyHID from Mechanique Company; this tool helps in creating a visual basic code for communicating with PIC Microcontroller. The interface of this software is shown in Figure 6- 5 and the code generated by EasyHID for Visual Basic is shown in
Inderprastha Engineering College, Ghaziabad Page 70

2-Channel-PC-Based Oscilloscope 2011 Figure 6- 6. This greatly helps in communication between PIC and Computer, now our task gets restricted to placing tools on the Visual Basic form window, this is shown in Figure 6- 7.
Figure 6- 5 EasyHID Interface

Figure 6- 6 Visual Basic Code Generated by EasyHID

Figure 6- 7 Final GUI in Visual Basic 6.0

Inderprastha Engineering College, Ghaziabad

Page 71

2-Channel-PC-Based Oscilloscope 2011 These all softwares and project files are included in the CD attached at the last of the report. The compiled code is shown in Figure 6- 8.

Figure 6- 8 Final GUI

On this screen we will see our output, the outputs are shown in

Inderprastha Engineering College, Ghaziabad

Page 72

2-Channel-PC-Based Oscilloscope 2011

CHAPTER 7 INSTALLATION AND WORKING OF THE PROJECT

Inderprastha Engineering College, Ghaziabad

Page 73

2-Channel-PC-Based Oscilloscope 2011

This chapter describes how to connect the Oscilloscope Hardware with the host Computer and then how to view the output on the Visual Basic 6.0 as discussed in Section 6.2 Graphical User Interface Development using Visual Basic 6.0. The various steps are illustrated using the snapshots taken while installing the hardware. And these are as follow: 7.1 Installation Steps i. First of all the hardware is connected to the host computer with the help of a USB cable, when this device gets connected successfully, a dialogue box will appear displaying USB2-Mini Oscilloscope as shown in Figure 7 - 1. ii. Now a Pop-up window will appear, which is the hardware installation wizard as shown in Figure 7 - 2. iii. Select the advance radio button and click next as shown in Figure 7 - 3. iv. Then provide the path for the drivers and click on the next button as shown in Figure 7 - 4. v. During installation a hardware warning error comes just click on continue anyway button, as shown in Figure 7 - 5. vi. Then Figure 7 - 6 and Figure 7 - 7 shows the next installation snapshots and then click on finish button. vii. Then a pop-up dialogue box will appear at the right bottom of the screen, displaying your new hardware gets installed and ready to use, this is shown in Figure 7 - 8. viii. One can check the hardware in Device Manager by right-clicking on COMPUTER Manage Option, it display our hardware, as shown in Figure 7 - 9.

Inderprastha Engineering College, Ghaziabad

Page 74

2-Channel-PC-Based Oscilloscope 2011

Figure 7 - 1 USB2-Mini Oscilloscope Detected on Host Computer

Figure 7 - 2 Hardware Installation Wizard.

Inderprastha Engineering College, Ghaziabad

Page 75

2-Channel-PC-Based Oscilloscope 2011

Figure 7 - 3 Choose Advanced Option Radio Button for installing the Drivers Manually.

Figure 7 - 4 Choose the Drivers from Specified Location

Inderprastha Engineering College, Ghaziabad

Page 76

2-Channel-PC-Based Oscilloscope 2011

Figure 7 - 5 Driver Installation Continued...

Figure 7 - 6 Driver Installation Continued

Inderprastha Engineering College, Ghaziabad

Page 77

2-Channel-PC-Based Oscilloscope 2011

Figure 7 - 7 Driver Installation Completed

Figure 7 - 8 New Hardware is ready to use.

Inderprastha Engineering College, Ghaziabad

Page 78

2-Channel-PC-Based Oscilloscope 2011

Figure 7 - 9 USB2-Mini Oscilloscope gets successfully connected to host

7.2 Project Working Now, our 2-Channel PC Based Oscilloscope is ready, we have to just view the output, by connecting the signal (generated by a function generator or any other device, for verification purposes we are using function generator). Test 1: Using Function Generator we have generated a 5KHz Sinusoidal Wave

Figure 7 - 10 Sine Wave Comparison

Inderprastha Engineering College, Ghaziabad

Page 79

2-Channel-PC-Based Oscilloscope 2011 Test 2: Using Function Generator we have generated a 5KHz Square Wave

Figure 7 - 11 Square Wave Comparision

Test 3: Using Function Generator we have generated a 5KHz Ramp Signal

Figure 7 - 12 Ramp Wave Comparison

The above figures show the comparison between the output of our 2-Channel-PC Based oscilloscope and Conventional CRO present in our Project Lab.

Inderprastha Engineering College, Ghaziabad

Page 80

2-Channel-PC-Based Oscilloscope 2011

CHAPTER-8 CONCLUSION

Inderprastha Engineering College, Ghaziabad

Page 81

2-Channel-PC-Based Oscilloscope 2011 8.1Applications Monitoring of sound waves, which are difficult to monitor on a traditional oscilloscope due to the low frequencies involved. Monitoring of an ECG signal, again because this is such a low frequency traditional oscilloscopes would have difficultly monitoring such a signal. ECG data could be logged and emailed directly to the doctor for diagnosis, or perhaps real-time TCP/IP internet communication so that the doctor could remotely monitor the ECG signal in real-time. Monitoring of serial communications, for example RS485 works on the principal of differential voltages between two cables twisted together; hence the PC based oscilloscope could be used to view serial communications. Two oscilloscope channels would be used, and the PC software will automatically add the two channels together producing a virtual trace (A+B). The PC based oscilloscope is ideal for demonstration purposes, for example using data projector a class of student could be introduced to the oscilloscope, with real waveforms being monitored (signal generator, or even a microphone for sound waves) and displayed on a large projector display. Because of the low cost of the PC based oscilloscope, it is economical for a school / technical college to have large quantities available for students. Unlike traditional analogue scopes which are expensive and students are forced to share equipment, because it is not economical to purchase enough scopes for every student.

Inderprastha Engineering College, Ghaziabad

Page 82

2-Channel-PC-Based Oscilloscope 2011

8.2 Future aspects The future aspect of this Oscilloscope depends on the developer smartness, that how efficiently he/she will experiment with the acquired samples, based on our perception one can add various functionality such as follows: The Oscilloscope can be extended up to 10 channels as PIC18F2550 supports 10 Analog-to-Digital Converter. Features like Save, Import and Export of the plots can be added to the visual basic graphical user interface. Additional High-Level operations can also be inserted like logarithmic plot, Fourier Transform etc. Frequency Range can be increased, so that this oscilloscope can handle more types of signal.

Inderprastha Engineering College, Ghaziabad

Page 83

2-Channel-PC-Based Oscilloscope 2011

REFERENCE
Advanced PIC Microcontroller Projects in C - From USB to RTOS with the PIC18F Series_ Dogan Ibrahim (Newnes_ 2008) Advanced PIC Microcontroller Projects in C - from USB to ZIGBEE with the PIC18F Series_ 2008_ Dogan Ibrahim www.microchip.com for USB Based firmwares and datasheets. MikroElektronika Documentation. MPLAB IDE and Hi-Tech Documentation. www.edaboard.com 8051 C Mazidi www.usb.org for USB 2.0 Specifications www.google.com for searching all datasheets

Inderprastha Engineering College, Ghaziabad

Page 84

Vous aimerez peut-être aussi