数字示波器设计2
http://www.cip.physik.uni-muenchen.de/~wwieser/elec/analysis/
Electronics -- USB Live Oscilloscope
A little 10MS/s USB-2.0 ("high speed") oscilloscope with two 8bit sampling inputs. Each of these can be used either as analog input with an 8bit AD converter (oscilloscope mode) or as 8 distinct digital inputs (logic state analyzer).
Overview
The design goal was to build a fairly simple device which allows to digitize signals with frequencies ranging from DC to around 1MHz with very long sampling buffer (i.e. millions of points).
Since I had the USB-FX2 board laying around already, the design was straightforward: A little board glues together a sampling clock generator and 2 input boards (analog or digital), each with 8bit interface to the USB-FX2 - and the rest is about writing software.
[click to enlarge: 224kbJPEG] / Features:
· Very simple hardware design; most functionality provided by software.
· Two 8-bit channels, each configurable as 8bit analog input or 8 digital inputs.
· Sampling rate: Tunable in 8 steps from 50kS/s to 10MS/s.
· Live transmission of data stream allows storage of nearly unlimited number of samples.
· Analog input sensitivity: 1Vpp or 2Vpp, DC coupled with 2.5V common mode.
· Digital input: Schmitt trigger, 3.3V or 5V CMOS levels.
· USB-powered operation.
This image shows the USB Live Oscilloscope: The bottom-most layer is the USB-FX2 board, on top there are two 8bit input boards next to each other (left: digital, right: analog) and in between, there's the "glue board" which does little more than connecting the parts. The clock generator is sticked on the bottom to the glue board and cannot be seen on this image.
Hardware
The USB Live Oscilloscope consists of the following parts:
· USB-FX2 board for USB data transmission. The version here applies a Rev.1 board but a Rev.2 board will just work the same.
· Main board: This is the "glue" board in the middle where everything else gets plugged into.
· Clock generator to generate the sampling clock at varying frequencies.
· ADCV input board to digitize analog signals.
· Digital input board for 8 digital Schmitt-trigger inputs.
Software
Writing software which sends and receives data over the USB is not really hard these days but writing something which is capable of receiving data at a constant rate of 20MByte/s is not so easy since you have to use asynchronous IO and a dedicated data transfer thread.
The complete source code of my software including the firmware for the USB-FX2 board (and the clock generator) is available on the software page.
More Photos
[click to enlarge: 111kbJPEG] / This is the side view corresponding to the image on the top of this page.
Top layer: Input boards (ADCV input board in front and digital input board in the background).
Middle layer: Main board.
Bottom layer: USB-FX2 board on the left and the tiny clock generator on the right.
[click to enlarge: 141kbJPEG] / USB Live Oscilloscope without clock generator and USB-FX2 board.
Note that the analog input board on all these photos is the revision1 while the circuit schematic shows rev.1b with additional 1M biasing resistor (R3) and external common mode connector (CM_OUT).
Electronics -- USB Live Oscilloscope: Digital Input Board
Digital Input Board Circuit
Download USB-Live-Osci: Digital input board circuit schematic:
PNG image (704x504 as seen below): digiboard.png (15kb)
High-quality PDF: digiboard.pdf (148kb)
Permission to copy and use this schematic is hereby granted provided credit is given where it is due.
Description
The digital input board has 8 distinct digital inputs available on JP1. There are separate pull-down resistors (RN1, choose a value you like, e.g. 1MOhm) and then each input has a Schmitt-trigger. Since these may be destroyed by improper input voltages, I chose to use HC14 devices in DIL-14 packages and mount them on sockets to be easily replaceable. Furthermore, one can switch from CMOS to TTL levels by plugging in a HCT14 instead or even have mixed inputs since there are two Schmitt-trigger IC's, each one handling 4 inputs.
The inputs operate on 5V or 3.3V levels; for the latter, there is an on-board LDO (IC5) which generates the 3.3V from 5V. This is not strictly necessary since we already have 3.3V on the mainboard (available on the AD_DUMMY connector, actually...), so you may choose to go for a simpler design. Note that when configuring for 3.3V inputs, the digital bus voltage at pin1 on ADCV_DATA must be 3.3V, otherwise 5V are supported as well (although we exclusively use 3.3V for the USB Live Oscilloscope).
The buffering latch IC1 makes sure that we "sample-and-hold" the digital level exactly when the sampling clock arrives (rising edge).
Electronics -- USB Live Oscilloscope: Clock Generator
Clock Generator Circuit
Download USB-Live-Osci: Clock generator circuit schematic:
PNG image (704x504 as seen below): clockgen.png (11kb)
High-quality PDF: clockgen.pdf (73kb)
Permission to copy and use this schematic is hereby granted provided credit is given where it is due.
Description
I was in a hurry when doing the clock generator and was not able to quickly come up with a simple design which would produce the varying sampling clock write strobe pulses. So, I settled with this semi-optimal but working design applying an ATtiny2313 microcontroller from Atmel.
For a 10MHz sampling clock, I need a 20MHz clock for the ATtiny2313 and hence it needs to be powered at 5V instead of 3.3V like all the other logic around. So, I had to add these HCT04 inverters for logic level translation of input pins; output pins are no big deal since both the VHC00 on the main board and the CY7C68013A on the USB-FX2 board have 5V tolerant inputs.
The CKGEN_SPI 6-pin connector is the standard SPI in-system-programming connector so that the microcontroller can be programmed by my USB-AtmelPrg programmer.
JP1 is the connection to the mainboard. The 8051 controller on the USB-FX2 board can program the sampling clock by taking INT1 HIGH, then transferring a command via the serial lines SCK and RxD while reading back status via TxD (also synchronized by SCK) and then taking INT1 LOW again.
The clock generator outputs a constant 10MHz sampling clock on the clock0 output pin. This clock will drive the AD converter and latches at constant 10MHz at any time. Since this is also the interface clock for the USB-FX2 (USB_IFCLK), we may never change the frequency and even may never have any glitch or missing pulse. (Yes, I debugged the circuit for a whole day until discovering that a tiny glitch in the USB_IFCLK introduced by the ATtiny2313 firmware while synchronizing the interface clock with the write strobes, made the FX2 stop sending data over the USB link!)
Different sampling rates are accomplished by different write strobes on the clock1 pin (USB_RDY1 which is SLWR in slave fifo mode) thereby only committing certain samples to the FIFO and hence to the USB link. So, for full 10MS/s, clock1 is simply pulled LOW, committing all samples, for 5MS/s, it is LOW at every second low-to-high transition of the sampling clock, for 1MS/s it's the same for evey 10th low-to-high transition, etc.
Clock Generator Firmware
Since it applies a microcontroller, the clock generator needs some firmware wich has to be downloaded onto its flash storage before plugging it into the mainboard.
Writing this firmware was not as simple as it may seem since the timings have to be exactly right and the sampling clock (provided by an on-chip timer/counter) must be kept in sync with the write strobes.
Supported sampling rates: 10MS/s, 5MS/s, 2.5MS/s, 1MS/s, 500kS/s, 250kS/s, 100kS/s, 50kS/s, 0S/s
The firmware was verified to have correct synchronisation for all these sampling rates.
Download: The clock generator firmware (source code and binary) is bundeled with the USB-Live-Osci software.
Electronics -- USB Live Oscilloscope: Main Board
Mainboard Circuit
Download USB-Live-Osci: Mainboard circuit schematic:
PNG image (1042x712 as seen below): mainboard.png (31kb)
High-quality PDF: mainboard.pdf (217kb)
Permission to copy and use this schematic is hereby granted provided credit is given where it is due.
Connectors
The mainboard consists mainly of connectors:
· The USB-FX2 board gets plugged into: USB_CTL2, USB_RW, USB_CTL1, USB_PB, USB_PA, USB_PD as well as 3V3_5_SUP, 3V3_SUP, GND_SUP.
· The clock generator is connected at CLK_IO and CLK_SUP.
· The two input boards (ADCV or digital) get connected to AD_CTL1, AD_DATA1, AD_SUP5V_1, AD_SUP3V3_1 for the first board and the same names with suffix 2 for the second board.
· JP3 and JP5 can be used for external sampling clock when the clock generator is disabled.
Description
To transfer the sampling data, the 16 digital data lines from the two input boards are fed into the 16bit wide bus of the FX2-USB board (USB_PA,). Each input board can have up to 3 control lines (pins 1,2 and 4 of AD_CTL) which are set from the USB-FX2 board's 8051 controller via lines USB_PA1,3,7 and shift register IC2.
IC1A,B form together an RS-flip-flop which was meant to detect FIFO buffer overflows (i.e. when the USB-FX2 board is not able to transmit data over the USB fast enough). It is connected to the clock generator so that it can take action. However, this feature currently is not used at all and the FIFO stall can probably also be detected by a software interrupt in the FX2.
IC1C,D to the necessary clock inversion because ADCV clock and interface clock need to be inverted compared to the latch clock. (See also the waveform diagrams on the schematic.)
Electronics -- USB-FX2 Interface Board (USB-2.0)
A small microcontroller-steered 16bit parallel IO interface board connecting external devices to a computer applying USB-2.0 (high-speed).
Overview
[click to enlarge: 233kbJPEG] / This is a USB (universal serial bus) interface board supporting USB-2.0 high speed mode (480Mbit/s).
Features:
· Throughput: Actual continuous transfer rates of 35Mb/s (mega bytes not bits).
· Flexibility: On-board 8051 microcontroller with 16kb RAM.
· FIFO IO: 8 or 16 bit wide, additional handshake lines, 3.3V logic.
· Several USB endpoints and buffering configurations (up to 512 bytes, quad-buffered); bulk, isochronous and interrupt transfer.
· Several additional free digital IO lines.
· Firmware download via USB; optional non-volatile 64kb EEPROM.
· USB-powered and externally powered operation.
· Very few discrete components.
If you would simply like to connect a microcontroller board to a computer using USB but don't need massive bandwidth (less than 800kb/s), then you may want to have a look at the smaller and cheaper USB8Bit board.
Schematic
[click to enlarge: 153kbPDF] / The main component is the CY7C68013A USB-2.0 interface IC ("FX2", actually it's "FX2LP" but don't mind) from Cypress Semiconductor with integrated 8051 microcontroller. Beyond that, really few external components are required.
It includes a 5V-to-3.3V low-drop regulator to provide the 3.3V logic level. Access to all data, control, handshake and clock pins is granted via dedicated connectors and allows direct interfacing to a variety of high-speed devices (like AD/DA converters, hard drives, FIFOs, etc.).
For more information, have a look at the detailed circuit description.
Host Software and Firmware
First of all, the software part is not as easy as with the USB8Bit board, especially if you're after high transfer rates. In order to write your own software, you need:
· The CY7C8601xA Data Sheet and, even more important, the EZ-USB Technical Reference Manual, both available from Cypress.
· An '8051 compiler like SDCC for the firmware.
· libusb, including headers, GCC, and of course all the usual development tools assumed to be on the hard drives of anybody who is surfing these pages...
Here is a list of local and external resources around the FX2:
· My software collection: Local tools and examples verified to work with my FX2 board, including high-speed IO transfer program FX2Pipe.
· USB Live Osci, my a little dual 8bit 10MS/s sampling USB oscilloscope.
· SSRP: Simple Software Radio Peripheral; basically an AD converter connected to the FX2. Fast IO source code.
· FX2 programmer, another programmer similar to my one, and also check out the software radio link on that page
Electronics -- USB Live Oscilloscope: ADCV Board
ADCV Board Circuit
Download USB-Live-Osci: Analog-to-digital converter board circuit schematic:
PNG image (843x604 as seen below): adcvboard.png (22kb)
High-quality PDF: adcvboard.pdf (95kb)
Permission to copy and use this schematic is hereby granted provided credit is given where it is due.
Description
The analog input is first fed into a fast non-inverting buffer amplifier (OPA353) set up for unity gain which protects the analog-to-digital converter from out-of-range voltages.
The ADS830 is a fairly cheap 8-bit analog-to-digital converter which supports sampling clocks from 10kS/s to 60MS/s. It has sort of a 3-stage pipeline meaning that the conversion result available on the digital outputs corresponds to the analog voltage 3 clocks earlier. Since we're sampling on a constant 10MS/s rate (remember: for lower "sampling rates", the sampling clock is still 10MHz but we select only certain samples before committing them to the USB-FX2 FIFO) this introduces a constant delay of 300ns. This is nothing to worry about most of the time but when comparing the time from digital and analog inputs, it must be remembered that the analog signal lags somewhat behind.
The digital outputs from the AD converter are fed into a latch (IC2) for 3.3V level conversion and then leave the board on the ADCV_DATA connector.
The AD_CTL plug not only provides the sampling and latch clocks (they have the same frequency but opposite phase) but also the config for the AD converter allowing to set the sensitivity to 1Vpp or 2Vpp or choosing between internal and external reference. (There is currently no extra plug for an external reference.)
Analog Input
The analog has to be attached to the CON-BNC connector. It must be understood that the input is DC coupled and demands a common mode offset voltage of 2.5V. This is ideal for 5V single-supply amplifier circuits which operator symmetrically around 2.5V. However, this is not what one expects when connecting to a "real" oscilloscope. If different signal levels are required, an extra input amplifier and level shifter has to be built (which will probably require an external power supply!).