Intermission: Electrical Debugging Tips

Before I post about USB UART, I feel the need to cover electrical debugging on the PSOC. Since the PSOC is a mixed signal device, handling both analog and digital signals internally, you have challenges when debugging your project. In order to trouble-shoot your project, you must be able to 1) See analog waveforms, 2) See Digital signals, 3) Read DC Voltage levels, 4) Occasionally inject Analog Signals, and 5) Occasionally inject Digital Signals.

Oscilloscopes

You can accomplish numbers 1 through 3 a variety of ways. The first most useful tool in your toolbox will be an oscilloscope. For number 2, a logic analyzer is best, but an oscilloscope can be used in a pinch. For number 4, an arbitrary waveform generator can be used, although it can be painful (but pain is part of the process!). You can also use another PSOC to inject digital signals into your project, but that can be complicated.

In years past, the oscilloscopes generally considered suitable for lab use in the U.S.A. were from Tektronix and H.P. (now Agilent). These scopes were top of the line and carried new car price tags. There were some exceptions to this rule.

Today, your choices are much broader. I still have an older 4 channel scope from Tektronix, a TDS-2014 that I purchased from Fry’s back when they were a rising star in the electronics retail world. It was purchased to do a paying side project. The project paid for the very expensive scope. You can still purchase Tektronix (now on Amazon!) and Agilent equipment, and their prices have come down, but there are many much cheaper options.

First, a recommendation: If you do consulting work on the side, use one of your consulting jobs to fund the best scope you want from the best manufacturer, which I personally believe is Tektronix. Tek scopes last a long time.

If you have to purchase a scope from your pocket, I recommend looking for Hantek or Siglent. You can purchase a scope from Amazon. Search for “oscilloscope.” These scopes will last 3 to 5 years without problems, typically.

To properly debug PSOC waveforms, you need at least a 50mhz oscilloscope. For around $250 USD you can purchase a 100 MHZ dual channel oscilloscope. I have purchased several Siglent and Hantek ‘scopes and have found them very usable, and very accurate.

The problem with purchasing cheap ‘scopes is durability. Once the inexpensive ‘scopes are over 5 years old, their most used knobs start becoming intermittent. For a patient man on a budget, this is workable. On the other hand, my 10 year old+ Tek scope is still working perfectly. However, I can still purchase around 10 of the cheaper scopes for what the single Tek scope cost me.

Multimeters

A good multimeter is a must. However, you don’t have to spend a lot of money to acquire one. Believe it or not, a decent multimeter can be acquired for less than $10 USD. Search for Meter on Amazon, or go to this link: https://smile.amazon.com/gp/product/B06XPDQ6P2/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1

Cheap, cheap, multimeter, from Amazon

If you purchase this meter, be aware the leads are extremely flimsy. I was able to purchase some MEK (mainly used to create plastic glue for ABS and PLA) from my hardware store. It melts pretty much everything, and needs to be used outdoors if at all possible. Use a glove (not plastic!) when handling the fluid. I poured a small amount of fluid down the probe stem where the plastic coated wire entered. This provided a strain relief for the probe. Otherwise you will use the probe one or two times and it will come apart and stop functioning. However, for the current price of $3.40 USD, a little gluing is worth it.

I have found this inexpensive device to be more that adequate for my needs during my projects. I have also used it at work. I really don’t worry about destroying a $4 device. I do worry about destroying a $300 device. I have thrown away more than one of the $4 multimeters after accomplishing an “OOPS!”

The best meter out there, based on personal experience, is a Fluke. The Fluke 87 multimeter provides a lot of functionality, and it holds up to abuse. It’s price tag is well over $300 USD. I believe you should purchase it only when you have the need and the funds. It should last a lifetime, however.

Waveform Generators

For Items 4 and 5, if you search for “waveform generator” at Amazon, you get a lot of choices. I don’t have any firm recommendations for these. Every waveform generator I have used has had many problems. You generally work around the problems and keep going. However, I do have a suggestion that has worked well for me so far….

MultiFunction Device

I have been wanting a combination multimeter, oscilloscope, and arbitrary waveform generator. There are quite a few out there, the prices are all over the map. I purchased one that I have grown to like a lot, the Hantek 2D72 3 in 1. I paid over $200 USD for it last year. It is now available for as little as $178 at this link: https://smile.amazon.com/Hantek-Oscilloscope-Generator-Multimeter-Multifunction/dp/B07MQJR6W9/ref=psdc_393269011_t3_B07RLDPNKQ

Hantek 2D72

Don’t misunderstand. This multi-function device is flawed. You may not like it. It has many drawbacks. For me, the pluses outweigh the minuses.

The things I like about it are 1) It is quiet (no fan), 2) it is almost instant on, 3) dual channel, 4) 70 mhz bandwidth is sufficient for debugging PSOC, 5) it is battery powered, 6) DC Multimeter is very pleasant to use and works well, 7) Arbitrary Wave Generator is good enough, especially if you download the Windows software for it, and 8) it includes everything in a good carrying case pouch.

The drawbacks for this device are as follows: 1) the button usage is not very intuitive, it will take time to learn, 2) The second ‘scope channel on the display is hard to see due to colors chosen by Hantek for it, 3) the cursors for timing are hard to see, 4) the display is much smaller than a dedicated ‘scope, 5) the Windows software is usable, but buggy, 6) the AWG takes some practice to be able to use properly, 7) the beeper on the multimeter in the ohms continuity tester is very, very, very quiet (you can hear it, but barely), and 8) switching between modes (Scope to DMM) can be slow.

However, when I am debugging my projects during development, the 2D72 is now my goto unit of choice. I only have one unit sitting next to my breadboard, not three. This one unit lets me know if I am doing what I think I am doing. If I want extremely critical measurements, or I want to do screen captures, I use my (noisy fan) Hantek 100 mhz oscilloscope. I can use the downloadable Windows software for the Multifunction 2D72 to do screen shots, but it is clumsy.

I don’t consider the 2D72 to be a laboratory piece of equipment, but it is more than accurate enough for testing my intermediate work. I do consider it to be indispensable when I am working on and testing my analog / digital / and firmware project. It greatly reduces bench top clutter.

There is a difference between project development and final project certification. The first usually requires much less precision than the other, and speed of development is of utmost importance. You can replace everything except your personal time. That resource is extremely limited, even if you don’t understand it yet. You will understand this concept one day.

Digital Analysis: Logic Analyzers

The last item I will discuss is a digital analyzer, usually called a Logic Analyzer. When debugging digital output, you generally need to see the digital patterns in the time domain. You rarely need to see the actual waveforms on an oscilloscope; instead you need to see the digital 1’s and 0’s in relation to other digital signals, such as a ‘clock.’

Several years ago, Saleae (at https://www.saleae.com/ ) realized that a Cypress FX2 USB device could capture digital signals at a maximum rate of 24 MHZ. This was fast enough using Full Speed USB when testing for up to 10 MHZ signals, and more than fast enough for most UART, SPI, CAN Bus, and general control signal testing.

Their original product included software that runs on Windows, Macintosh, and Linux. It was written using the Qt framework, and was intuitive and generally bug free. The cloners have stepped in and now produce a product with an FX2 chip for a cheap price. The original $200 or so device from Saleae is now produced (equivalently) and sold for $15 (or so), without software. Open Source Software exists for it.

Saleae continued their development efforts and now produce several products, priced from $399 to $999. Their build quality is high, and their software is excellent. If you go with the least expensive device ($399 at the time of this writing), you can get 100 MHZ sample rate. Very few inexpensive units out there provide this sample rate. If you need this speed and quality, Saleae is still an excellent goto choice.

On a maker budget, I tend to want to spend as little as possible on all my items. I have worked with $20,000 USD logic analyzers on high end projects (Agilent, formerly H.P.), so I am familiar with their features and accuracies (down to the picosecond). If you need some of those features and accuracies, you have to get those units.

The high end analyzers are rarely needed for home projects. The PSOC runs at most 80 MHZ for its ARM processor. Its internal logic can generally operate at around a maximum speed of 50 MHZ for internal logic (there are some exceptions). However, for higher speeds, the routing of signals will sometimes fail, depending on how much internal logic you use.

For the PSOC projects I work on, a 25 MHZ clock typically provides the internal timing to any clocked logic. That puts a 24 MHZ maximum speed analyzer within the ballpark for most logic outputs. Usually, with a 25 MHZ clock, most of the output signals are 12 MHZ or less. Typically much less.

So, for simple troubleshooting of waveforms I use the logic analyzer that incorporates the FX2 device. It works with PulseView (SigRock). It comes in the following package, usually from HiLetgo, found on Amazon at this link: https://smile.amazon.com/gp/product/B077LSG5P2/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

Cheap USB Logic Analyzer

Other analyzers on Amazon include the LHT00SU1. It comes in a variety of prices (as low as $39 USD), and is also supported by a software package called PulseView. It includes two analog channels that can sample up to 5 volt signals and display a waveform synchronized with your digital logic. That has been useful from time to time.

If you need higher data acquisition rates (around 100 MHZ) on a severely restricted budget, the LA2016 logic analyzer is available on Amazon. It is available for around $130, and provides a 200 MHZ sample rate. I have not used this device, but the ratings and reviews on it are good. It comes with its own software for Windows, Macintosh, and Linux.

Logic Analyzer Software: PulseView

A logic analyzer is useless without software. Fortunately, there is an open-source software package out there, that works on Windows, Macintosh, and Linux. It is called PulseView, and is on the SigRock site: https://sigrok.org/wiki/PulseView

At the time of this writing, the stable release builds are at 0.4.2, and come in 32 bit and 64 bit flavors. I downloaded a nightly build (not considered “stable”) and dragged it to the desktop on my Mac to be readily available. I was pleasantly surprised at how well it worked.

Note that several years ago I tried to use PulseView, and it was a miserable experience, as I could not get it to build. Today, however, on the Macintosh, with the pre-built apps, it is a great experience. (Your mileage may vary.) It supports the FX2 clone device (above) and the LHT00SU1 device without hassle. It may also support the LA2016 (It is listed as a work in progress for that device), but I have not tested it.

The PulseView software is intuitive, and works with many protocols including the SPI and CAN Bus protocols. I have used it several times at work, and find it to be very useful.

Conclusion

There are many choices and prices for test equipment. Do your comparison shopping. You will generally trade price for time and ease of use, but that is not always the case. If your budget can support it, get the best equipment with the best ratings. Generally, Amazon and EBay are good places to look. Be aware that EBay is used equipment, and not everything on EBay will work when you receive it.

Enjoy!

Add a Comment

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