If There’s Something Strange in Your Project, and if it’s Something Weird and it Doesn’t Look Good…

…Who are you going to call?

For a lot of people, Ghostbusters may seem like the only option they have available to them. In fact, that is very much the way that I felt when I was working a new Pmod library and things just didn’t seem to be working out the way I expected them to. But then, I glanced to my left and saw…

A shining diamond in the rough.
A shining diamond in the rough.

The Analog Discovery 2! But alas, what can it do to help me solve my problem? Especially when I’m not even sure what my problem is to begin with.

The biggest thing is that the Analog Discovery 2 (or AD2 for short) is an oscilloscope — a device that can measure and display the electrical behavior of a device. This means that with the appropriate knowledge of what sort of places we need to probe on the device, we can get a good picture of how it is operating electrically; this is something we can’t normally do by looking at it with the naked eye.

For my project, I was working on creating a library for the new PmodJSTK2, but was getting some inconsistent results when I sent a command to the joystick or read some data from the joystick. Sometimes everything would work exactly as I expected, and other times I seemed to be getting a bunch of nonsense. Because I was using SPI to communicate back and forth between the WF32 and the PmodJSTK2, I figured that would be a good place to observe all of the electrical signals to see if I could spot anything suspicious.

After following Kaitlyn’s guide for installing Waveforms 2015, I clicked on the “Scope” button (since that made the most sense for using an oscilloscope). Then I connected scope channels 1 and 2 to the data following to the PmodJSTK2 and to the clock that dictates how fast the two devices communicate, adjusted the time scale so I could reasonably see what was happening (since they communicate very fast with each other), and hit “Run” to start the oscilloscope.

Selecting the scope in WaveForms 2015
Selecting the scope in WaveForms 2015.
Connecting Oscilloscope channels 1+ and 2+ on the AD2
Connecting Oscilloscope channels 1+ and 2+ on the AD2.
Adjusting the time base for the oscilloscope in WaveForms 2015
Adjusting the time base for the oscilloscope in WaveForms 2015.

And soon it was running! However, I quickly found that while I could stop the oscilloscope and look at the information on the screen, it was rather tedious to manually calculate any time or data differences that were present. Plus, I also wanted to be able to view both data lines, the clock, and the enable line simultaneously, rather than being forced to pick just two of them.

What I was attempting to decipher from the oscilloscope
What I was attempting to decipher from the oscilloscope.

As I was verbally lamenting about my problems, a co-worker of mine decided to take pity on me and suggested that I use the Logic Analyzer tool inside of WaveForms 2015. Sure enough, along the left-hand side of the main window, there was a button labeled “Logic”. After clicking on that, I was brought to the Logic Analyzer page where I could add a new channel, choose SPI, and set which of the numbered AD2 pins are measuring which SPI communication line. I added a second SPI channel so that I could measure the data lines going both to and from the PmodJSTK2 simultaneously, set my time base, and clicked run.

The Logic Analyzer feature in WaveForms 2015
The Logic Analyzer feature in WaveForms 2015.
Choosing to analyze an SPI bus in the Logic Analyzer.
Choosing to analyze an SPI bus in the Logic Analyzer.
Setting up the Logic Analyzer for two SPI bus lines
Setting up the Logic Analyzer for two SPI bus lines.
Connecting the Logic Analyzer for the Analog Discovery 2
Connecting the Logic Analyzer for the Analog Discovery 2.
Choosing the time base on the Logic Analyzer.
Choosing the time base on the Logic Analyzer.

I could immediately tell that the Logic Analyzer was definitely the tool I was needing to use, instead of the oscilloscope. All of the transitions were crisp and clear, which makes sense considering that the oscilloscope focuses on measuring an accurate voltage and captures all of the transitions as well as any oscillations between transitions. In contrast, the Logic Analyzer instead looks to see if the measured voltage has crossed a high or low threshold, since it is a digital logic analyzer.

The Logic Analyzer in action.
The Logic Analyzer in action.

It was only because of this Logic Analyzer that I was able to notice a strange timing error where the SPI communication would suddenly be cut off part way through a message. Digging into the problem a little bit further revealed that an additional delay was needed between the final byte of data being transferred and the signal to stop communicating over SPI. This was then incorporated into the embedded firmware so other users would not have to worry about it.

So, as tempting as it might be to look up Bill Murray’s number to give him a call, there may be something close by that can help you figure out the solution to your problem. For me, that something was the Analog Discovery 2. What do you use to help solve your problems?

Author

  • James Colvin

    A local Digilent employee who is sometimes tricked into making other content besides documentation and supporting customers on the Digilent Forum, but then I get to write a little more informally so that's a plus. A sassy engineer, lover of puns and dad jokes, father and husband. I know both way too much and simultaneously almost nothing about a number of nerdy topics. If you want to hear me rant, ask me what data rate USB C operates at.

Be the 1st to vote.

About James Colvin

A local Digilent employee who is sometimes tricked into making other content besides documentation and supporting customers on the Digilent Forum, but then I get to write a little more informally so that's a plus. A sassy engineer, lover of puns and dad jokes, father and husband. I know both way too much and simultaneously almost nothing about a number of nerdy topics. If you want to hear me rant, ask me what data rate USB C operates at.

View all posts by James Colvin →

Leave a Reply

Your email address will not be published. Required fields are marked *