APC Australia

Arduino Troublesho­oting 101

Not every Arduino project goes to plan. Being able to troublesho­ot is a vital skill for any electrical engineerin­g project. Darren Yates explains.

-

Arduino provides infinite options for making your own computing projects. But just like writing code, it’s rare that a project will work perfectly the first time you power-up. The science (or, sometimes, black magic) of ‘troublesho­oting’ is an important skill to learn and one best learnt by practice.

IT DOESN’T WORK

Look on almost any maker website at almost any project presented and, chances are, there’ll be a comment somewhere along the lines of ‘I built this and it doesn’t work’, followed by a few choice words we can’t publish. No matter how good you are, few projects ever work first-go. It’s just the nature of the beast.

But unfortunat­ely, this is often the point at which many people give up. Like everything in life, it’s from your mistakes that you learn most — and it’s also how you best hone valuable troublesho­oting skills.

A METHODICAL MINDSET

Troublesho­oting anything is about patience and having a methodical mindset — you start looking for the easiest, most obvious areas first and progressiv­ely dive deeper into your project design once the obvious things have been checked. Here’s my basic list:

1. WIRING

Wiring is always the first thing to check. Make sure you understand how your project goes together and that the wiring makes sense. Remove the power first and check for things like correct voltage polarity, loose connection­s and even components in the wrong way around. I reckon at least half of the problems I’ve read online regarding Arduino projects are solved by the builder checking the wiring and finding they made a mistake.

2. SIGNAL FLOW

A few years ago, a mate asked me to look at his Fender guitar valve/tube amplifier — all he could tell me was it suddenly stopped working and made a buzz. Taking care for the dangerous 500VDC voltages inside, I was able to follow the audio signal path with a circuit diagram from input to output and traced the fault to an ageing resistor that had gone open-circuit (internal broken connection). Yet even in modern microcontr­oller-powered circuits, you need to similarly identify the digital signal flow — understand the point of origin and follow where that signal is supposed to travel. Check also for ‘continuity’, that each wire has a good low-resistance connection between the wiring points. For example, if I have a robot where one motor isn’t spinning, I’ll take a digital multimeter (DMM) on a low or auto ‘ohms’ range, connect the DMM probes to the two ends of each wire and check for a ‘zero ohms’ reading or very close to it. If the DMM reads in ‘megaohms’, it’s either a ‘dry-joint’ (a poor solder joint) or a wire that’s gone open-circuit, meaning there’s no electrical connection between the two points. Always remove the power before testing anything.

3. CODE FLOW

Bringing microcontr­ollers into your projects adds the dimension of code errors or ‘bugs’. Very quickly, there are two error types — ‘syntax’ errors or obvious boo-boos such as wrongly-spelt keywords or missing semi-colons at the end of a codeline (if we’re talking Java/ C++), and ‘logical’ errors, or errors of code logic, where digital data paths don’t align correctly. Logical errors are much harder to find. You can have perfect electrical wiring, but your code is causing problems. That’s why I aim to design and code projects one section at a time. For example, I always start by getting an LED to light up or a motor to spin — just to be sure the component works. When building a house, you start at the

foundation­s, get those right, then work on the frame, electrical and plumbing — it’s only after that the Gyprock goes on. Being methodical is key.

WATCH YOUR POLARITY

In electronic­s, ‘polarity’ describes how power must be applied to a component or device. A common convention is the ‘Vcc’ label refering to the positive (+) pin, connecting to your project’s positive supply rail, while ‘GND’ is the ground or 0V rail. Not all components have polarity requiremen­ts — for example, resistors, polyester capacitors and inductors. But many components do — transistor­s, CPUs, LCD/OLED panels and most electrolyt­ic capacitors. You have to ensure correct polarity for these components. Otherwise, they’ll blow up — sometimes, literally.

And when it comes to Arduino add-on modules, you’ll find consistenc­y is not always guaranteed. Check the photo of these 0.96-inch OLED panels (below). They look identical — they’re the same size, have the same resolution, use the same chip. But take a close look at the header pins — the panel on the left has the left-most pin as the GND pin and VCC next to it. On the other panel, they’re reversed. Frankly, I’d like to meet the genius who thought swapping these pins was a great idea. That aside, the new panel on the right is now flooding the market — this means if you’re building any of our previous projects using one of these panels, you must carefully check the power pin wiring polarity before you plug in the panel and power up your project. Otherwise, you’ll toast the panel.

5V TOLERANCE

The other big issue is known as ‘5V tolerance’. Older Arduino boards like the Uno and Nano require 5VDC to run — not just for power, but also for the digital logic-level inputs. Here, a ‘high’ or ‘digital-1’ input level is assumed to be 5V and a ‘zero’ is GND or zero-volts. However, more modern ARM Cortex M-series chips, like those found in your fitness band or smartwatch, require 3.3VDC power. Now, you can typically connect a 3.3VDC digital output to the input of a 5V chip and it will work. However, the big question is whether you can safely connect a 5VDC digital signal to the input of a 3.3V chip. Technicall­y, the input signal being applied here is ‘over-voltage’ and, in many cases, this voltage level will blow up the input circuitry of the 3.3V chip. But in other 3.3V chips, the inputs are designed to handle this specific over-voltage — these inputs are called ‘5V tolerant’.

This might all sound a bit geeky, but it’s a question commonly asked of the popular ESP8266 Wi-Fi chip powering many Internet of Things projects (the chipmaker’s CEO has recently said the ESP8266 is 5V-tolerant, tinyurl.com/jhqga8b).

BE PERSISTENT

Forget being ‘passionate’ about making stuff — be persistent, instead. Troublesho­oting is better served by having perseveran­ce, backed by a methodical mindset — it’s a skill that will make you invaluable to any business.

 ??  ?? Lots of questions online ask if ESP8266 inputs have 5V tolerance.
Lots of questions online ask if ESP8266 inputs have 5V tolerance.
 ??  ?? A digital multimeter can check wiring continuity of unpowered projects.
A digital multimeter can check wiring continuity of unpowered projects.
 ??  ?? OLED panels with reversed polarity — check your wiring before installati­on..
OLED panels with reversed polarity — check your wiring before installati­on..
 ??  ?? Older Arduino boards like the Uno need 5VDC power.
Older Arduino boards like the Uno need 5VDC power.
 ??  ?? Most components, including motors, have voltage polarity — check first.
Most components, including motors, have voltage polarity — check first.
 ??  ?? Understand­ing code flow is as important to projects as your electronic­s.
Understand­ing code flow is as important to projects as your electronic­s.

Newspapers in English

Newspapers from Australia