3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

DPScope - Build Your Own USB/PC-Based Oscilloscope

Step 8Microcontroller

Microcontroller
The Microcontroller is the heart of the DPScope. It is a 16-bit Microchip dsPIC30F2020 which has a lot of desirable features: Not only is it blazingly fast (it runs 32 MIPS on a 128 MHz clock - this is very slightly outside spec - max. 120 MHz - but works perfectly fine) and comes in a hobbyist-friendly DIP package; since it is geared towards digital signal processing or DSP (that's where the "ds" in the name comes from) it also has a bunch of useful mixed-signal periphery already built in:

First and most important, it has an analog-to-digital converter that can acquire samples at 2 MSamples/sec. At least that's what the spec seems to say at first glance. The reality is - it can acquire two channels simultaneously
at 1 MSample/sec each, and the Microchip marketing guys simply added those two numbers... anyway, that's perfectly fine for us because we need two channels anyway. The ADC has a resolution of 10 bits, but in order to maximize acquisition speed and reduce memory requirements only the upper 8 bits get used (i.e. one byte per sample). The reason for using a 128 MHz clock is the same - at that speed the dsPIC is just barely fast enough to repeatedly sample two channels and store the data into internal memory at 1 MHz sample rate.

The analog bandwidth of the ADC is well above 1 MHz, so it's not a limiting factor in the signal chain. For sample rates faster than 1 MSample/sec
- up to 20 MSamples/sec - the DPScope employs a technique called "equivalent time sampling" - basically it runs at 1 MSample/sec real sample rate and acquires only a subset of the data points at each sweep, and then overlays two or more subsequent sweeps (each with slightly increased start delay after the trigger) for a composite picture with higher effective timing resolution. You can read more details about this technique in the Tektronix application note "The XYZ of oscillscopes".

The second great feature
of this microcontroller is a set of comparators with finely controllable threshold (10 bit resolution); most other Microchip devices have only very coarse compare threshold steps. These comparators are all we need to implement a full-blown scope trigger with adjustable threshold and selectable edge polarity (rising or falling edge, respectively), which cuts down on overall component count and thus cost and complexity.

The only sore point with this dsPIC is its small RAM size - just 512 bytes. Some of that is taken up by program overhead (e.g. global variables, parameter stack and so on), and it was a challenge to get at least 200 bytes per channel
(actually 205, since this works out to 410 points for FFT - where only one channel as acquired at a time - and 410 is 4/5 of the 512 points needed for the FFT, which makes interpolating it to 512 points fairly straightforward); a future version of the scope may use a different dsPIC device (but right now there isn't any that has all the other features, runs at 5V, and is available in DIP package). Adding external RAM is not an option either - first, it would add cost and complexity, second, the dpPIC does not have enough output pins to control it, and third, at maximum sample rate there is no time for additional control tasks anyway. But 200 points is good enough for a full display, and in most applications the DPScope's delayed trigger capability provides exactly the same functionality that a longer capture memory would.

Finally, the dsPIC supports SPI and USART communication, which it uses to control the other devices in the DPScope (adjustable gain amplifiers, offset DAC) and communicate with the PC, respectively.

« Previous StepDownload PDFView All StepsNext Step »
3 comments
Mar 1, 2010. 9:25 AMsaLZBURG says:
I am interrested in building this scope but microchip doesn't have
a 24 F 2020. What other chip could be used instead.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
59
Followers
3
Author:womai