1 of 72

How to debug almost anything

(but mostly hardware)

2 of 72

Foreword

We’re all here to learn and we all make mistakes! The nice thing about this field is that most of these are easily fixable. Just say “well I f’d that up” and move on.

You’ll even find relics of board surgery in commercial products.

In my experience ego is the largest time waster and cause of fried boards.

3 of 72

When to ask for help!

  • Don’t spend hours suffering in silence
  • Nothing good happens after 2am
  • The issue tracker is your friend

4 of 72

Pattern recognition

  • Issues tend to boil down to only a few main categories
  • Recognizing which failure modes correspond to which root cause is a skill that you will hone over time

Show stoppers

  1. Milling issues/solder bridges
  2. Cold joints
  3. Orientations
  4. Connections*
  5. Power/gnd shorts**

Soft problems

  • Wrong GPIO
  • transmit/receive issue
  • Clock issues

Is it powered on? Is it soldered?

5 of 72

Milling issues

Debugging actually starts before your board is even milled especially if you’re using mods!

DRC (Design Rule Check)

Ideal vs real

6 of 72

How’s this look?

7 of 72

Blue lines are cutting passes

Red are rapids to link the passes

8 of 72

Ideal vs Real

9 of 72

What’s this look like in person?

10 of 72

11 of 72

12 of 72

13 of 72

14 of 72

15 of 72

16 of 72

Spotting issues

Back lighting and magnification tips

Continuity testing*

Flying probes

*sometimes multimeters lie to you especially when big caps are involved

17 of 72

18 of 72

19 of 72

20 of 72

Cold joints

Look for sharp edges

Almost always solved with heat and maybe flux/new solder

Very in depth guide to issue causation and parameter tuning

21 of 72

22 of 72

Flying probe

23 of 72

Orientations

ICs, FETs, Diodes, some caps, and others have a defined orientation. Always check datasheets to make sure you’ve got it in the right way. Sometimes the dot can be hard to see so I shine a light at a steep angle. When in doubt use a scope.

LEDs can be especially annoying

TI is kinda mean

24 of 72

25 of 72

Connections

Sometimes it just boils down to cable A should be going to point B or something like that

Much more prone when it gets later into the evening

26 of 72

TX/RX swap

For some reason in UART connections you hook TX of one device to RX of the next device and vice versa.

You speak into someone’s ears not their mouth

This is one of the few standards that operates this way. C'est la vie

27 of 72

Table connecting underlying issue with observed problem (cause - effect)

Flow chart?

28 of 72

Now, on to the fun stuff!

29 of 72

How do we fix some of the larger issues?

30 of 72

Board surgery!

Tools to keep in your pocket

Magnet wire and strain relief

A nice guide

31 of 72

Magnet wire

Pros

  • Slim insulation that doesn’t melt*
    • Helps avoid shorts
  • Solid core
    • Holds shape and avoids 3 hands problem
  • Available in many sizes
  • Good heat tolerance

Cons

  • Requires strain relief
  • Some difficulty stripping
    • Utility knife scraping and spinning works well

32 of 72

Red or clear insulating layer (non-solderable)

Shiny copper (solderable)

33 of 72

Strain relief!

34 of 72

Cutting traces/bridges

Did you accidentally connect vdd and vddcore?

Milling issue leave some wispy copper causing shorts?

No worries just slice it!

Just be careful to not cut other traces too

35 of 72

36 of 72

External caps/resistors

Can add smoothing, pullup/pulldown, etc.

37 of 72

Easter Egg

Credit- Zach Fredin for this lovable monstrosity

38 of 72

A suggested process

  1. Check resistance of (all) power line to gnd
  2. Confirm voltage at known locations
  3. PtP connections of all programming pins
  4. Interconnects of programming pins
  5. Hunt for bridges

39 of 72

Test Equipment

  • DMM
    • Voltages (parallel)
    • Currents (Serial)
    • Resistance
    • Diode test
    • Continuity
  • Oscilloscope
    • Real time signals
    • Non-steady state
    • UART debugging

40 of 72

Digital Multimeters

  • Is my 3.3V regulator actually giving me 3.3V? Is my pin high when I think it is?
  • Is my LED in the correct orientation?
  • Are my joints/traces shorted? Soldered properly?
  • Be careful about how you probe!
    • Often the force of your probe can connect poorly soldered components causing you to think they are connected when in fact they are not

Be wary, sometimes these can lie to you generally because of big caps that you’re charging or small transistors that you’re enabling

41 of 72

  1. Off
  2. DC Voltages*
  3. AC Voltages
  4. Resistance
  5. Diode/Continuity*
  6. Capacitance
  7. Frequency/duty cycle
    1. Not found on many meters
  8. Temp
    • Requires thermocouple
  9. Current
    • Be wary of burden voltage
    • Measured in series

Multimeter functions

42 of 72

DC Voltages

In DC voltage mode we can verify pin states or regulator outputs

43 of 72

Resistance

0.L short for Overload means not connected

Note the units at the bottom!

44 of 72

45 of 72

Continuity test

Super useful for finding shorts on your board and verifying joint integrity

Make sure your board is unplugged!

Need to press mode button to get buzzer on

46 of 72

Oscilloscopes

  • Time variant things
    • Servo PWMs
      • Why isn’t my servo moving?
    • Sinusoid things
  • Communication line debugging
    • Real-time UART visualization!
      • My board isn’t responding but I think it’s getting the messages
  • Timing confirmation
  • Chip debugging
  • Triggering, vert/horizontal scaling

47 of 72

Decoding Serial example

Let’s say we have 2 devices and we want to send messages between them.

Flipping individual pins is fine for very small complexity projects but prone to a number of issues ( what happens if you unplug one etc)

Serial is a nice robust solution that is easy to decode (It’s just ascii!)

48 of 72

Idle start 0 0 0 1 0 1 1 0

49 of 72

This is LSB so once you have 8 bits flip the order

00010110 becomes 01101000

Consult an ascii table

50 of 72

So 01101000 is an h!

Now this is clunky. Is there a better way?

51 of 72

Decoding on a scope

52 of 72

53 of 72

Setup specifics

Match the baud rate (115200 for me)

Idle high (on TX)

Mode:uart

No parity

Order: LSB

54 of 72

Notes on I2C scanning

Ie my sensor is from amazon who the heck knows what its address is

#include <Wire.h> �void setup()�{� Wire.begin();� Serial.begin(9600);� while (!Serial); // wait for serial monitorSerial.println("\nI2C Scanner");�} �void loop()�{� byte error, address;� int nDevices;� Serial.println("Scanning...");� nDevices = 0;� for(address = 1; address < 127; address++ )� {� // The i2c_scanner uses the return value of the Write.endTransmisstion to see if a device did acknowledge the address.Wire.beginTransmission(address);� error = Wire.endTransmission();�

if (error == 0)� {� Serial.print("I2C device found at address 0x");� if (address<16)� Serial.print("0");� Serial.print(address,HEX);� Serial.println(" !");� nDevices++;� }� else if (error==4)� {� Serial.print("Unknown error at address 0x");� if (address<16)� Serial.print("0");� Serial.println(address,HEX);� } � }� if (nDevices == 0)� Serial.println("No I2C devices found\n");� elseSerial.println("done\n");� � delay(5000); // wait 5 seconds for next scan�}�

55 of 72

USB oscilloscope/Logic analyzer

(portable test equipment)

56 of 72

  • USB oscilloscope/Logic analyzer.

Bulky and hard to take with you everywhere

57 of 72

Analog signal processing circuit

Signal sampling/processing

Display/Control

  • USB oscilloscope/Logic analyzer.

58 of 72

Display/Control

Run on a laptop?

Analog signal processing circuit

Signal sampling/processing

  • USB oscilloscope/Logic analyzer.

A tiny equipment?

59 of 72

  • USB oscilloscope/Logic analyzer.

60 of 72

USB

  • USB oscilloscope/Logic analyzer.

61 of 72

  • USB oscilloscope/Logic analyzer.

62 of 72

  • USB oscilloscope/Logic analyzer.

63 of 72

  • USB oscilloscope/Logic analyzer.

A corner of CBA

Oscilloscope, spectrum analyzer,

signal generator, power supply,

64 of 72

  • USB oscilloscope/Logic analyzer.

A corner of CBA

Can we put all these equipments in pocket?

65 of 72

  • USB oscilloscope/Logic analyzer.

A corner of CBA

No (if you want the same performance).

Yes (you just need a moderate performance).

66 of 72

  • USB oscilloscope/Logic analyzer.

67 of 72

  • USB oscilloscope/Logic analyzer.
  • Oscilloscope,
  • Logic analyzer,
  • Spectrum analyzer (FFT),
  • Signal generator,
  • Power supply,

68 of 72

Not advertisement. Just want to let you know there are some fancy tools that can make your life easier.

69 of 72

Debugging workflows

70 of 72

Common Hardware Problems

Question

Try This First

Is this wire connected ?

Multimeter connection check

Is the solder bleeding ?

Multimeter dis-connection check

Is this device connected properly ?

Check device pinout

Is this device getting power ?

Multimeter voltage check

Is this device sending anything back to me? / Am I sending anything to it ?

Oscilloscope

How are these pins supposed to communicate ?

Find a working example and measure signals using Oscilloscope

Is this device getting enough power ?

Check its output pins using Oscilloscope

71 of 72

Common Software Problems

Question

Try This First

Is this code even being executed ?

In that code, try turning on the onboard LED (digitalWrite)

Is this IF statement being executed ?

In that code, try turning on the onboard LED (digitalWrite)

What is the value of this Variable ?

Serial.print

What data did I just receive ?

Serial.print (if you have Serial; if not, use the onboard LED)

Is my Arduino sending/receiving data on a pin ?

Check the pin using Oscilloscope

Are the serial wires working ?

Check the pinout diagram, and check the pin using Oscilloscope

72 of 72

In circuit debugging

Break points

Supported in Arduino 2.X IDE

Requires additional debugger