DIY - USB OSCILLOSCOPE IN a MATCHBOX
by ajoyraman in Circuits > Electronics
312442 Views, 811 Favorites, 0 Comments
DIY - USB OSCILLOSCOPE IN a MATCHBOX
I present a "BEST OF CLASS", "Full-Featured" DIY-USB OSCILLOSCOPE which is "Truly DIY".
My aim is to provide a cheap Digital-Storage-Oscilloscope for Students, Budding Engineers and the Hobbyist.
This USB-Oscilloscope could be part of the laboratory equipment in educational establishments.
Build this DIY-Oscilloscope for just $15
----------------------------------------------------------------------------------------------------
Today 21 Nov 2014, my Instructable crossed 100000 Views!
At this Milestone I am happy to share all the source files (C, .Net & Python) at:
https://github.com/ajoyraman/USB_Matchbox_Scope
-----------------------------------------------------------------------------------------------------
I wish to acknowledge the inputs from the following designs which have led to this optimized solution:
DPScope SE - the simplest real oscilloscope/logic analyzer on the planet, by womai, https://www.instructables.com/id/DPScope-SE-the-si...
DPScope - Build Your Own USB/PC-Based Oscilloscope,by womai
https://www.instructables.com/id/DPScope-Build-You...
LCS-1M - A Full-Featured, Low-Cost Hobby Oscilloscope,by womai
https://www.instructables.com/id/LCS-1M-A-Full-Fea...
PC SOUND-CARD SCOPE INTERFACE FACILITATES DC RESTORATION, by me
https://www.instructables.com/id/PC-SOUND-CARD-SCO...
Universal Analog Hardware Testbench, by me
https://www.instructables.com/id/Universal-Analog-...
Analog Experiments Anywhere,by me
https://www.instructables.com/id/Analog-Experiment...
Two-Channel PC Based Oscilloscope USB, by Gaurav Chaudhary
http://www.circuitvalley.com/2011/07/two-channel-...
Responding to comments and suggestions from many members :
I am sharing the micro-controller fuse .Hex file for the dsPIC30F2020.
The Host PC software has been written in both 'Visual Basic.Net' and open source 'Python' providing a cross-platform GUI based solution for both Windows and Linux platforms.
Specifications
Analog bandwidth (Small Signal), 12/6/7 MHz ,For Gain 1/2/5
Input impedance 1 Meg Ohm
Input connection 3 mm Audio Jack
+6.25V to - 6.25V, Gain 2
+2.50V to -2.50V, Gain 5
-6.25V to +13.75V, Gain 2
-2.50V to +17.50V, Gain 5
10bps to 500 kbps, 100ms/sample to 2uses/sample , Normal Mode
Trigger Polarity
Trigger Range
+6.25V to - 6.25V, Gain 2
+2.50V to -2.50V, Gain 5
Ch1 vs. time 200 Samples
Ch2 vs. time 200 Samples
XY Ch1 + Ch2 vs. time 200 Samples each
DFT Ch1 400 Samples
DFT Ch2 400 Samples
Block Schematic and Function Description
For ease of portability the unit is powered and controlled from the USB port of a PC.
The configuration is optimized so that only five integrated circuits all operating on a single +5V supply are required to provide the full functionality of this Digital Storage Oscilloscope.
The FT232R from FDTI is a USB to serial UART interface with advanced features providing:
• With the entire USB protocol handled on the chip.
• A fully integrated 1024 bit EEPROM storing device descriptors and CBUS I/O configuration.
• With fully integrated USB termination resistors.
• A fully integrated clock generation with no external crystal required
• Output selection enabling glue-less interface to external MCU or FPGA.
• And data transfer rates from 300 baud to 3 Mega baud
This chip provides a minimum component count USB-Serial interface and is used to communicate with the host PC for enumeration as a USB to UART device setting up the Aj_Scope2 as a 200mA device and acts as the USB communication interface.
The MCP6S22 devices are digitally controlled Programmable Gain Amplifiers (PGA) with high bandwidth and high input impedance controlled through a Serial-Peripheral-Interface (SPI). These devices provide the input interface between the dsPIC18F14K50 and dsPIC30F2020 and the external analog signals being monitored.
The dsPIC30F2020 micro-controller implements the main Oscilloscope Functions.
• Trigger interrupt handling
• Responding to serial commands from PC and sending back the acquired data.
• A Busy signal is also generated
The dsPIC30F2020 micro-controller is ideally suited to this task as it permits simultaneous 2-channel A/D conversion at rates up to 1Msps, has internal comparators which can handle the trigger functionality, provide PWM outputs which are used to set the input offset voltages and a SPI interface for controlling the PGAs.
A LM1117 3.3V regulator provides a Voltage reference which is used to compensate for the gain changes with varying USB +5V.
Software on the PC Host
Visual Basic .Net Microsoft Windows Application Code
A Visual Basic .Net 2.0 based GUI program is used to control the functions of the Aj_Scope2.
The Aj_Scope.exe along with associated ZedGraph.dll and FTDI USB driver files have been tested for compatibility with Windows XP and Windows 7 with .Net 2.0.
* The FDTI VCP drivers can be downloaded from www.ftdichip.com/
Open Source Python Cross-Platform Application Code
Alternatively a Python based GUI program can be used to control the functions of the Aj_Scope2.
The Aj_Scope.pyc python executable bit code provides a cross-platform application which has been tested using Python 2.7 on Windows XP and Windows 7 and on Debian 6.0 (“squeeze”) and Debian 7.0 (“wheezy”) using Python 2.6 and Python 2.7 respectively.
The Python installation requires the following packages:
Tkinter, ttk, serial, glob, math, time, csv, numpy and matplotlib
*On Linux systems appropriate ‘chmod’ commands need to be executed as root for giving users permission to access the VCP port which is typically /dev/ttyUSB0
GUI VB.Net 2.0
Display and trigger modes, sampling rate, channel gains, channel offset trigger offset and number of samples can be set using the simple controls.
The RUN button initiates the signal capture single, repetitive or over-plotted.
Initially signals can be acquired in auto / single mode after with suitable changes can be made in the gain and offsets and a trigger level set. Repeat mode can now be used for continuous display of the signals. Display of Ch1/Ch2 is possible with trigger by either Ch1 or Ch2.
Finally an EXIT button is provided to close the program and exit.
Figure 4, Shows the Mouse cursor data display
Figure 5, Shows the Image zoom, copy, print and save modes
Figure 6, Shows the Plot in EXCEL based on saved data
Figure 7, Shows the Spectrum Display
GUI Software on Debian Linux "Lenny"
Figure 9, Cursor Display
Figure 10 Image zoom, pan and save modes provided by the Python Tkinter Toolbar.
Figure 11, Plot in Debian Gnumeric based on saved .csv data
Figure 12, XY Plot
Figure 13, DFT Spectrum Plot
The Aj_Scope2 Unit
The USB connection to the PC is on one end while the Audio-Jack for the signals to be monitored is on the other.
A ‘Busy’ LED is provided on one corner at the top and a ‘Reset’ switch is provided diagonally opposite.
The ‘Reset’ switch provides a restart of the micro-controller is the worst-case of hang-up. This typically occurs when the operator selects a trigger threshold which is out of limits with respect to the waveform being observed. If the Aj_Scope2 is operated correctly this switch is seldom used.
Circuit Diagrams 1: USB Interface
The FDTI FT232R forms a single chip minimum component count interface between the PC USB port and the micro-controller serial-link Rx-Data and Tx-Data pins. As all the circuitry in self contained only one capacitor C8 needs to be added for the 3.3V generation.
Power to the rest of the circuitry is fed from the USB connector.
On connection to the PC USB port , the device is enumerated as a Virtual Com Port (VCP) and the corresponding drivers are loaded by the OS. As the Aj_Scope2 draws approximately 150mA the device has been programmed to indicate a 200mA device.
Circuit Diagrams 2: Analog Interface
An input potential divider with a ratio 4:1 is formed by resistors R2: (R3+R7+R8+R9), 820k: 205k. The input impedance of this divider is therefore 1.025 Meg Ohm. Capacitors C9 and C10 are added so as to compensate for any input capacitance of the MCP6S22.
OC1 a PWM output of the micro-controller is filtered in two stages by R9/C15 and R8/C14 and produces a DC offset voltage at the junction of R7/R8 based on the duty cycle of the PWM. This offset voltage is initialized to produce a fixed VDD/2 voltage at the output of the MCP6S22 which is then changed by the Ch1 offset voltage slider around this value. The PWM voltage is suitably adjusted for different gain settings.
The MCP6S22 is connected to the micro-controller through an SPI interface in order to setup the gain values 1/2/5.
VOUT at Pin 1 of the MCP6S22 is fed as an analog input to the microcontroller within a working range 0-VDD. This output is potential divided by 2 using R1/R4 and fed as an input to the internal comparator CMP3 of the microcontroller. This voltage is used for the trigger function.
Circuit Diagrams 3: Processor Circuit
The dsPic30F2020 is powered from the USB bus.
A reset switch is provided at the MCLR pin.
A 16MHz crystal is connected across OSC1/OSC2 and sets up the processor clock.
RE0 to RE3 form the SPI interface to the two PGAs.
OC1 and OC2 for the PWM signals setting the offset voltages for Ch1 and Ch2. U1ARX and U1ATX are connected to the USB to Serial converter FT232R.
A Vref of 3.3V is connected to the analog inputs AN2/AN3 and is used to compensate for ADC scale-factor change with variation in VDD.
Finally the PGA outputs are connected to AN0/AN1 and CMP3A/CMP3B.
Under software control the microcontroller A/D converts the Ch1/Ch2 inputs at fixed intervals and stores them in internal memory before transferring them to the host PC.
When not in auto mode the start of the conversion sequence is determined by comparing an internally generated trigger reference voltage with the voltages at CMP3A/CMP3B.
LED D1 flashes during the initialization and acquisition process indicating that the processor is busy. No commands are initiated during this phase.
Figure 17 shows the overall circuit.
Bill of Materials
U4 the dsPic30F2020 is the micro-controller
U3 & U5 are the Programmable gain amplifiers MCP6S22
U2 is the USB to serial converter FT232R
and U1 is a 3.3 V , LM1117 regulator used as a voltage reference
42 other components make up the connectors , switch and passive components.
The overall cost of the BOM is 940 Indian Rupees or an equivalent of $ 15.
Double Sided PCB "HOW-TO"
1. In fabricating the double sided PCB by the toner transfer method the top of the CAD layout needs to be mirrored. Print the files on A4 size on Photo-paper and use it to iron on the toner to the copper clad sheet.
2. The trick in alignment is take a print of top or bottom on normal paper, cut the paper to the approximate size of the PCB and use this as a template to drill the four (paper pin diameter) locating holes at the center of mounting holes in the copper clad sheet.
3. Use the TOP+BOT file to check your placement
4. Now pierce 4 paper-pins through the TOP print and pass through the 4 holes in the copper clad sheet, this aligns the Top.
5 .Pierce the BOT 4 mounting holes and then exactly place them on the 4 pins which are jutting out of the bottom side of the copper clad sheet.
6. Now flatten everything and then stick the paper edges with 3M tape.
7. Remove the pins and proceed with the toner transfer ironing.
8. Two tricks
b) To save on photo-paper first print on normal paper, stick slightly larger than PCB size piece of photo paper over the area where the PCB was printed and feed the same paper back into the laser printer.
10. Gently rub off any paper sticking on the copper sheet.
11. Etch with a Ferric-Chloride solution.
12. Drill the component holes and then clean out the toner from the card.
The Hole registration was good.
Figure 18, shows the component layout and Fig 19, the wired PCB.
Construction
Step 1 & Step 2 show that the double sided PCB track widths are suited for the 'Toner-Transfer' method of PCB fabrication.
It is necessary to check that pads on the top layer are soldered on top and if necessary at the bottom also in order to handle the non availability of plated through holes for component pins.
Additionally some pads for the connectors on the top layer are inaccessible because they are covered by the connector body. In this case small holes need to be drilled near these pins and the pad connection extended to the bottom by soldering a thin copper wire through the board. This needs to be done carefully so as not to create any accidental connection to neighboring tracks.
A thin piece of paper or any insulating material needs to be placed under the USB connector so that the body does not short with tracks on the top of the board.
Note how the MCP6S22 which comes in a Small 8-pin MSOP Package is handled.
In this case cut pieces from the other component leads are inserted into the base and soldered carefully to the MCP6S22 pins. This helps in taking care of these devices which come both in the Small 8-pin MSOP Package or the 8-pin DIP package.
Conformal Coating
Once the basic operation is checked along with the Host PC loaded with appropriate Windows/Linux software the board needs to be cleaned of excess solder flux using ISO-Propyl Alcohol or Spirit and dried.
After covering the IC base locations with insulating tape the board is sprayed on both sides with a conformal coating for protection.
Holes need to be cut for the connectors and reset switch using a sharp knife and the board carefully fitted into the inner cardboard container of the matchbox.
Next, this can be slid into the outer cover with a hole for the LED and legs stuck onto the bottom
While practically operating the system it was noticed that the dsPIC30F2020 runs hot to the touch. This is particularly so because of operating at a clock frequency just outside specifications, the enclosure and when the USB 5V is slightly on the 5+ side.
This could lead to intermittent communication between the PIC and Host PC.
A heat-sink is added to eliminate this problem.
The reset switch is turned to the vertical position.
Heat sink compound is added over the processor IC.
And the heat sink plate fixed using the screws through the mounting holes.
This compound unit is now fitted back into the inner cardboard and slid into the top cover.
We are done and the DIY-USB-Oscilloscope is ready to use.
Software and Documentation
Folder dsPIC30F2020 contains the fuse .Hex file
Scope2.hex
Aj_Scope2_V2.7.pyc
Aj_Scope.xml
Aj_Scope2.exe
ZedGraph.dll
email any feedback to ajoyraman@gmail.com
visit my website www.ajoyraman.in for other projects
Downloads
Important
The Integrated Circuits were sourced from element14 as per the following details
Manufacturer: FTDI
Order Code: 1146032
Manufacturer Part No: FT232RL
FTDI - FT232RL - IC, USB TO UART, SMD, 28SSOP
Manufacturer: MICROCHIP
Order Code: 1439475
Manufacturer Part No: MCP6S22-I/SN
MICROCHIP - MCP6S22-I/SN - PGA, 2CH, 12MHZ, SPI, SMD, SOIC8
Manufacturer: MICROCHIP
Order Code: 1297281
Manufacturer Part No: DSPIC30F2020-30I/SP
MICROCHIP- 16BIT DSP12K FLASH, 512B RAM, DIP28
Manufacturer: TEXAS INSTRUMENTS
Order Code: 2148396
Manufacturer Part No: LM1117MPX-3.3/NOPB.
TEXAS INSTRUMENTS - LM1117MPX-3.3/NOPB. - VOLTAGE REGULATOR IC
------------------------------------------------------------------------------------------------------------------------------------------
Warning & Disclaimer:
All content provided here is for informational purposes only. I make no representations as to the accuracy or completeness of any information. I will not be liable for any errors or omissions in this information. I will not be liable for any losses, injuries, or damages from the display or use of this information including software.