The Case For Arduino In “Real Engineering”

For over ten years, Arduino has held onto its popularity as “that small dev-board aimed to get both artists and electronics enthusiasts excited about physical computing.” Along the way, it’s found a corner in college courses, one-off burning man rigs, and countless projects that have landed here. Without a doubt, the Arduino has a cushy home among hobbyists, but it also lives elsewhere. Arduino lives in engineering design labs as consumer products move from feature iterations into user testing. It’s in the chem labs when scientists need to get some sensor data into their pc in a pinch. Despite the frowns we’ll see when someone blinks an LED with an Arduino and puts it into a project box, Arduino is here to stay. I thought I’d dig a little bit deeper into why both artists and engineers keep revisiting this board so much.

Arduino, do we actually love to hate it?

do-we-love-arduinoIt’s not unusual for the seasoned engineers to cast some glares towards the latest Arduino-based cat-feeding Kickstarter, shamelessly hiding the actual Arduino board inside that 3D-printed enclosure. Hasty? Sure. Crude, or unpolished? Certainly. Worth selling? Well, that depends on the standards of the consumer. Nevertheless, those exact same critical engineers might also be kicking around ideas for their next Burning Man Persistence-of-Vision LED display–and guess what? It’s got an Arduino for brains! What may seem like hypocrisy is actually perfectly reasonable. In both cases, each designer is using Arduino for what it does best: abstracting away the gritty details so that designs can happen quickly. How? The magic (or not) of hardware abstraction.

Meet HAL, the Hardware-Abstraction Layer

In a world where “we just want to get things blinking,” Arduino has a few nifty out-of-the-box features that get us up-and-running quickly. Sure, development tools are cross-platform. Sure, programming happens over a convenient usb interface. None of these features, however, can rival Arduino’s greatest strength, the Hardware Abstraction Layer (HAL).

HAL is nothing new in the embedded world, but simply having one can make a world of difference, one that can enable both the artist and the embedded engineer to achieve the same end goal of both quickly and programmatically interacting with the physical world through a microcontroller. In Arduino, the HAL is nothing more than the collection of classes and function calls that overlay on top of the C++ programming language and, in a sense, “turn it into the Arduino programming language” (I know, there is no Arduino Language). If you’re curious as to how these functions are implemented, take a peek at the AVR directory in Arduino’s source code.

With a hardware abstraction layer, we don’t need to know the details about how our program’s function calls translate to various peripherals available on the Uno’s ATMEGA328p chip. We don’t need to know how data was received when Serial.available() is true. We don’t “need to know” if Wire.begin() is using 7-bit addressing or 10-bit addressing for slave devices. The copious amounts of setup needed to make these high-level calls possible is already taken care of for us through the HAL. The result? We save time reading the chip’s datasheet, writing helper functions to enable chip features, and learning about unique characteristics and quirks of our microcontroller if we’re just trying to perform some simple interaction with the physical world.

Cross-Platform Compatibility

Teensy 3.2 keeps form factor but adds hardware features
Teensy 3.2 keeps form factor but adds on-chip hardware features compared to 3.1

There are some cases where the HAL starts to break down. Maybe the microcontroller doesn’t have the necessary hardware to simultaneously drive 16 servos while polling a serial port and decoding serial data. In some cases, we can solve this issue by switching Arduino platforms. Maybe we actually do need three serial ports instead of one (Teensy 3.2). Maybe we do need pulse-width-modulation (PWM) capability on every pin (Due). Because of the hardware abstraction layer, the rest of the source code can remain mostly unchanged although we may be switching chip architectures and even compilers in the process! Of course, in an environment where developing code for the target platform does matter, it doesn’t make sense to go to such efforts to write the general-purpose code that we see in Arduino, or even use Arduino in the first place if it doesn’t have the necessary features needed for the target end-goal. Nevertheless, for producing an end-to-end solution where “the outcome matters but the road to getting there does not,” writing Arduino code saves time if the target hardware needs to change before getting to that end goal.

HAL’s drawbacks

arduino-serial-buffer-sizeOf course, there’s also a price to pay for such nice things like speedy development-time using the HAL, and sometimes switching platforms won’t fix the problem. First off, reading the Arduino programming language documentation doesn’t tell us anything about the limitations of the hardware it’s running on. What happens, let’s say, if the Serial data keeps arriving but we don’t read it with Serial.read() until hundreds of bytes have been sent across? What happens if we do need to talk to an I2C device that mandates 10-bit addressing? Without reading the original source code, we don’t know the answers to these questions. Second, if we choose to use the functions given to us through the HAL, we’re limited by their implementation, that is, of course, unless we want to change the source code of the core libraries. It turns out that the Serial class implements a 64-byte ring buffer to hold onto the most recently received serial data. Is 64 bytes big enough for our application? Unless we change the core library source code, we’ll have to use their implementation.

Both of the limitations above involve understanding how the original HAL works and than changing it by changing the Arduino core library source code. Despite that freedom, most people don’t customize it! This odd fact is a testament to how well the core libraries were written to suit the needs of their target audience (artists) and, hence, Arduino garnered a large audience of users.

Pros of Bare-Metalspeak

digitalWrite takes a whopping 52-55 cycles to change pin direction! [image source]
digitalWrite takes a whopping 52-55 cycles to change pin direction! [image source]
Are there benefits to invoking the hardware directly? Absolutely. A few curious inquirers before us have measured the max pin-toggling frequency with digitalWrite to be on the order of ~100 KHz while manipulating the hardware directly results in a pin-toggling frequency of about 2 MHz, about 20 times faster. That said, is invoking the hardware directly worth it? Depends, but in many cases where tight timing isn’t a big deal and where the goal of a functional end-to-end system matters more than “how we got there,” then probably not! Of course, there are cases when tight timing does matter and an Arduino won’t make the cut, but in that case, it’s a job for the embedded engineer.

Use the HAL, Luke!

To achieve an end-to-end solution where the process of “how we got there” matters not, Arduino shines for many simple scenarios. Keep in mind that while the HAL keeps us from knowing too many details about our microcontroller that we’d otherwise find in the datasheet, I don’t proclaim that everyone throw out their datasheets from here on out. I am, however, a proponent of “knowing no more than you need to know to get the job done well.” If I’m trying to log some sensor data to a PC, and I discover I’ll be saving a few days reading a datasheet and configuring an SPI port because someone already wrote SPI.begin(), I’ll take an Arduino, please.

If you’ve rolled up your sleeves and pulled out an Arduino as your first option at work, we’d love to hear what uses you’ve come up with beyond the occasional side-project. Let us know in the comments below.

Itsy Bitsy Teenie Weenie 3D Printed RC Truck

I think it’s safe to say that almost all of us grew up playing with toy cars. They were cheap, and darn near  indestructible. Some went by the brand name of “Hot Wheels”, and others “Matchbox”. As a kid, you most likely spent many an hour on the floor imagining your “toy” to be a real car – and of course, adding the all important sound effects. Vroom-vroommmmm!

Flash forward to 2015, and see how things have changed. There are several “micro” RC cars and trucks on the market you can buy for about $10, but this is the first micro-sized, DIY, 3D printed, 4×4 truck we’ve seen. And to add to that, it even has a working articulated front end loader.

Coming in at a minute 1/87th scale, this tiny truck and matching controller boasts 6 channels, 4-wheel drive, and a working trailer hitch. In the video after the break, you can see the amazing amount of work that [Mortimer] had to put into this build to get everything to fit in such a small space. Although the video is German, we think it’s fairly easy to see what’s going on. [Mortimer] is sharing the 3D printed files on his Shapeways page if you would like to give this build a go.

Continue reading “Itsy Bitsy Teenie Weenie 3D Printed RC Truck”

Thor’s Hammer Build Recognizes Its Master’s Hand

electromagnetic-thors-hammerOnly those who have completely insulated themselves from modern pop culture will miss the meaning of a Mjolnir build. It is, of course, the mythical hammer wielded by Thor, and only Thor. It’s a question of being worthy; a question solved perfectly by this electromagnetic Mjolnir build.

Using an electromagnet is smart, right? Just plunk the thing down on something metal (that is itself super-heavy or well-anchored) and nobody will be able to pick it up. It starts to get more interesting when you add a fingerprint reader, allowing only Mjolnir’s Master to retrieve it from atop a manhole cover.

But for us the real genius in the build is that the hammer isn’t burning power from the four 12V batteries most of the time. All of the people in the video below could have picked up the hammer had they first nudged it off the metal plate with their foot. The build uses a capacitive touch-sensor to enable and disable the microwave over transformer used as the electromagnet. An engineering trick like this really separates the gods from the posers.

We hate to admit it, but this is probably a cooler build than the Telsa-Coil powered Mjolin that [Caleb] built a few years back. Still, his held up as the best for many years, and if you’re going to be displaced this really is a build worthy of the new title: coolest Mjolnir hack.

Continue reading “Thor’s Hammer Build Recognizes Its Master’s Hand”

Electronic Ruler Works Out Logic Truth Tables

Like [Brad], we’ve seen a number of PCB rulers out there. [Brad] was looking to take the idea and run with it. His DigiRule is a ruler with a logic gate simulator. What he built is a mash-up between PCB rulers, and the concept of electronic business cards.

All told it simulates seven logic gates, four flip-flops, and includes a four-bit counter. On one end of the ruler a CR1220 battery feeds the 18F43K20 which is performing the logic operations using buttons and LEDs. Of course the truth tables are printed on the back silk-screen, but playing with the lights is a lot more fun. We do find it fairly amusing that the centimeters on the bottom of the ruler are notated in binary.

It makes a lot more sense to hand out rulers than business cards; people might actually use them after you leave and you can still include contact info. This form-factor also breaks the mold. You can have a lot more space on a ruler and you’re not constrained by thickness (although [Limpkin] solved that problem). While we’re on the topic of business cards [ch00f’s] USB etch-a-sketch style card and this logic-based information delivery device top our favorites list.

Continue reading “Electronic Ruler Works Out Logic Truth Tables”

Homemade Soldering Station Does It Better

Soldering stations are probably one of the most important tools in the hacker’s arsenal. Problem is — good ones are expensive, and sometimes the only difference between being okay at soldering versus being great at it, is the quality of the tool you’re using! Which is why [Albert] and [Matthias] decided to make their very own home-made Weller clone.

Since the most important part of the soldering iron is a good tip, they’re using a needle from Weller — they just need to be able to control it. They designed a 3D printed housing (source files here) for a small 1.8″ LCD screen, an Arduino Pro Mini and a MOSFET shield, and the 12v 8A power supply they chose. There are only two controls — on/off, and a potentiometer for adjusting the temperature.

Continue reading “Homemade Soldering Station Does It Better”

The Worst CAD Package Ever Is Still Handy

A lot of great schematics wind up on the back of bar napkins or diner place mats. When inspiration strikes, you have to capture it, after all. Today, you are as likely to draw schematics on a computer and there are plenty of options for that; if you can install software your options are almost limitless. And if you have a modern Web browser, there are lots of good options that don’t even require an install.

But what about those times when you need a quick schematic to pop into a presentation? You are on some ancient conference room computer where you can’t install anything and it’s still running a browser that understands the <BLINK> tag? Try out the Klunky Schematic Editor. Your browser will need Javascript, but that’s about all. No HTML 5 or anything fancy.

Continue reading “The Worst CAD Package Ever Is Still Handy”

the perfect exacto handle

The Perfect Pen Knife Handle

If you’ve ever tried to use a pen knife for anything other than cutting open a box or slicing material in one direction, you’ll know they really aren’t that ergonomic. When [Seamusriley] started Architecture school a few years ago he started on a journey — an epic journey to make the perfect pen knife handle.

He started by analyzing existing handles — the biggest problem with them is the skinny pen shape causes hyper-extension of the first joint in your index finger, so once he identified that as the root cause he started crafting a more ergonomic version. He started out with foam, then up to wood carved by hand, then 3D printing, and back to wood — but this time, with a CNC machine. Literally dozens of prototypes later, he’s come up with a very nice pen knife handle, so much so, he was asked to present it around Boston at design events!

This is a great example of the hacker mindset — identifying a problem, trying out a solution, trying out another solution, trying out a solution… and then finally getting to a finished product. It’s the tenacity that keeps us going which rewards us in the long run.

[via r/somethingimade]