Digital Oscilloscope
Home
PIC Projects
The triggering event can be selected as any of the
channels passing any threshold voltage either rising or
falling.  Alternately, it can be manual - the user pressing a
button to start the sampling.  Whichever chip is designated
as the trigger starts sampling as soon as it is configured.  If
the precondition to the trigger event is true (e.g. The
trigger is the voltage falling through 3V and we're above 3V
now), the trigger chip lights the "Cocked" LED indicating the
trigger can happen at any time.  Once the trigger event has
happened, the trigger chip pulls the Trigger line low.  

The Trigger line going low is the indication to the master
chip to start the Clock line.  The master bringing this line
high and low keeps the time for all of the chips to take
readings.

The chips can each listen to a different channel at the
same time, or they can take turns listening to the same
channel.  To get the full speed, I found the only option was
to store the values in active memory - saving them took too
much time.  So the limit is 80 data points for 3 or 4
channels, 160 data points for 2 channels, or 240 data
points for 1 channel.  This suffices for me right now.
Far and away my most ambitious project to date, this
digital oscilloscope can sample up to four channels
at a rate up to 100kHz.  And the best part? It only
cost me about $40 in components.

The user interface is an application running on a
PC.  The user selects the configuration settings
here.  When the data has been acquired, it is
displayed as a graph on this screen.

The board uses five PIC 16F688 microcontrollers,
four to sample the different channels on regular
analog-to-digital pins and communicate as slaves to
the master microcontroller.  The master
communicates with the PC hosting the user interface
and configures the slaves.  When the measuring is
done, the master coordinates the reporting of the
measured values to the PC.
I started the first work on this project about
a year ago.  Surprisingly the biggest
challenge was a platform on the PC that
would let me open the serial port!  The
board actually uses a chip to replicate a
serial port over USB (UM232R from FTDI)
but it's a serial port as far as the PC is
concerned.  I found that Java didn't
support this anymore, though I could find
files online, I couldn't get it to work and
from the posts I read, this was a common
problem.  I found several options for
buying serial port drivers for MS Excel, but
I objected to paying.  I finally found my
solution in Processing, a tool out of MIT
and based on Java (http://processing.org/)
 It's a little flaky so there are some
work-arounds in my code, but it does the
job and it was free.
My favorite part about this project is that it's
actually useful.  I can use it for debugging
other projects.  

It's still a bare board, I've got the parts to
finish it on order and they'll actually cost
more than the active components.
What 9600 Baud UART Serial Messages Look Like
The communication within this project is a mixed bag.
 The messages between the PC and the master chip
are ASCII, readable to a person and they print out at
the bottom of the Processing screen.  The messages
between master and slave are binary.  I considered
using a hardware communications protocol like SPI,
but I wanted the same code on all the slaves so I
couldn't assign different addresses in the code.  
Instead it uses regular serial communication.  Each
slave learns what address number it is by the inputs
on its two address pins.

The communication line from master to slaves is no
problem, all slaves listen to what the master sends
out.  Going the other way was a problem, though.  
For a slave to communicate to the master, it has to
pull that line low.  If there are other slaves asserting
the same line high, it doesn't work.  I did find it OK
for two slaves, but not for four.  The solution was to
have that line pulled high by a resistor to +5V and
connected to the slave pins via diodes.  This lets any
slave pull it low, but none can assert it high.  
Messages from any slave get through.  Since slaves
only respond to queries from the master, there's no
chance of two trying to talk at the same time.
Output of Two Accelerometers
A Capacitor Discharging Thru a Series of Resistors
Code for PC App (used with Processing)
Code for Oscilloscope Master
Code for Oscilloscope Slave