Logic Analyzer Ver. 1.0 (a.k.a. "logan")
Back
What is it?
- Logan is a very low cost, PC controlled logic analyzer. Total cost in parts is around $40CND,
much less if you've got certain things on hand (project box, cables, DB9 connector, etc.).
In it's most basic form it is simply a glorified RAM buffer, samples are stored in a large RAM. A PIC Microcontroller acts as the
"controller", controlling the CPLD, RAM and input buffer.
Max sample rate is in the 4MHz to a theoretical ~40MHz range.
What does it consist of?
- Logan consists of 4 major components:
- Microchip PIC16F877 4MHz Microcontroller
- Xilinx XC9536 CPLD
- Dallas DS1258Y NV 256KB RAM chip
- 74LS245 Octal Buffer Chips x2
Obviously other support components are required, including a variety of capactors, a 4MHz crystal, and a MAXIM rs232
level convertor chip. Please see schematic for components required.
A way to get a programmed PIC is also required. If you have or have access to a programmer a HEX file can be found below.
If on the other hand you have no access to a programmer a preprogrammed PIC can be purchased from me. Please
click here for further details.
The CPLD must also be programmed. A bit file is available below.
Unfortunately I do not have the facilities to
program the CPLD, however simple programmers you can build are available on the net.
The code for the CPLD was compiled using the free CPLD environment available from
Xilinx.
And finally, the Logic Analyzer Client must also be compiled.
The client was written using Borland C Builder Ver. 3.0.
A compiled version that should work on most windows system is available below.
For other systems the project can't be directly compiled, I've included my source code below and it should give
good pointers on porting it to other OSs.
What does it do?
- On powerup, Logan makes a few self checks, and then sits waiting to receive a character from the serial port.
On receipt of a command from the client software over the serial port it performs the requested action.
For example, if an "s" command is received it sets bits on the size bus to correspond to what is requested;
the CPLD uses these lines to determine what sample depth is required.
The commands the PIC recognizes are:
-
d - dump_mem - prints out the contents of the memory until done is received, terminal friendly, used for testing
-
w - write_mem - writes to the memory a pseudo random number, used for testing
-
s - set_size - prompts for number between 0-7 and sets the size bits accordingly
-
c - set_clock - prompts for number between 0-7 and sets the clock bits accordingly
-
r - read_mem - reads the memory, sending it as full binary
-
t - store - sets clk_sel, rd_strb and finally RST to start a data capture, waits for done from CPLD
-
l - load_trigger - loads trigger supplied by serial port into global variables
Triggering is completely optional.
If triggering is disabled, then on receipt of a "store" command the PIC tells the CPLD to start
capturing and waits for the CPLD to signal that capturing has been completed.
If a trigger has been loaded things proceed a little differently.
- The PIC sets everything up to start a "store", however it
holds the CPLD in reset.
- The PIC then starts monitoring the data bus for the trigger condition
- The following section of code is a 2 state, state machine. So if a trigger
on a level is wanted both states look for the same logic value.
If an edge is wanted instead the first state looks for a "0" and the second state
looks for a "one"
- Once the state machine has passed through the second state capturing of the waveform begins, and the PIC waits for the CPLD to signal
completion of capture.
Limitations?
- There are some limiations due to the approach taken:
- All triggered waveforms have the trigger point at the BEGINNING of the waveform
- At very high sample rates there is a latency between the trigger condition being true and the start of capture. This will sometimes
result in the trigger point not being on the waveform
- Since data is returned over the serial port at 19200bps large waveforms take time to download. A 128KB download requires slightly more
then a minute to download
- Maximum sample rate is determined by the bandwidth of your construction, the access speed of the RAM and the critical path in the CPLD.
The max speed I've tested is 4MHz, I'm certain it could go alot faster, preliminary indicators suggested 30-40MHz was the upper limit
Enough already! Show me the files...
- Links to the files are as follows:
And now, some pretty pictures
- Image of the project in-circuit
(it's actually connected to the I2C bus on my other project carmon)

- What's in the box? (Bonus points if you can tell me what movie I remember that line from...)

- Closeup shot of main board containing PIC and RAM chip

- Closeup shot of CPLD board

- Closeup shot of the underside of the CPLD board
Like the rats nest? :)

- Closeup shot of input side of box, serial port is to the top left,
power regulator on the bottom, power switch to the right

- Screen capture of the client program in action, this is a capture of an I2C transaction in progress

- And finally, the schematic

Miscellanous/Loose Ends
- Currently I only have 8 channels enabled in the firmware. Adding the further 8 channels isn't much of a challenge.
Hardware for the full 16 channels is already there.
- I would like to eventually get around the "trigger at the start of the capture" limitation.
Doing so would require a complete rework
of the code in the CPLD (to create a circular buffer and enable constant capturing).
I'm not sure if the current CPLD would be big enough. If not the Xilinx XC9572 is pin compatible with twice the
capacity.
- I've never actually tested to see how fast it can still work, that would be neat to explore if I ever found the time.
- Oh, you might be wondering WHY I use non-volatile RAM? Well, because Maxim/Dallas has an amazing free sample program!
- There is a minor bug in the CPLD: depending on how quickly the CPLD is brought out of reset the first sample may not be
recorded/returned.
This isn't much of a bug because usually this first sample isn't that important.
The problem appears in simluation, I haven't
searched for it in the real hardware.
Resources
- Obviously, to do a project like this requires quite a few resources, below are a few I used:
- PICLIST - The PICLIST is a email based mailing list consisting of nearly 2000 people. Think of it as
a PIC centered think-tank: a group of individuals that have probably seen most of the problems encountered while working with
PICs and are eager to help others in solving those problems. I'm a co-admin of the list.
- Microchip.com - The manufacturer of the PIC Microcontroller line. A great product, a great company.
Can't really do anything with a PIC without referencing one of their datasheets or app notes.
- Xilinx - Manufacturer of the amazing 9536 series of CPLDs, very cheap, very quick, very hobbiest
friendly!
A direct link to the software I used to compile the verilog into something the CPLD could understand:
Xilinx WebPack Software
- Maxim Semiconductor - Makers of the RAM chip I used, along with the RS232 receiver.
GREAT sample program!
Question? Comments?
Please note:
All contents on this site remain the property of myself.
Please feel
free to use the information found here in "one off", personal, hobbiest type projects.
No permission is granted for using the information on this site in commercial type projects.
Please contact me at webmaster@farcite.net about using any
of the contents on this site in a commercial application.
Copyright 2003, 2004, Herbert Graf. All rights reserved.
Back
Last update:
Thursday, September 2, 2004