Creating a Custom Sensor Board for Arduino, Part 1

It's far faster and easier to achieve proof of concept for a new GPS, WiFi, or other module when the driver code is already written for the Arduino than it is on a bare-metal MCU.

I spend most of my microcontroller time with Microchip PIC processors. I'm far from being a world authority on their care and feeding, but I have been designing and programming PIC-based circuits for more than a decade. They do what I need. They are easy to use (fuse bits notwithstanding) and inexpensive.

Until recently, I've largely ignored the Arduino as an alternative. As far as I was concerned, it was a good learning and light hobby tool but not something for real-world applications. My gut feeling was that the Arduino infrastructure added too much overhead to a garden-variety eight-bit Atmel MCU. However, I started to change my mind when I took a look at the PIC32-based chipKIT Arduino compatible board and the "official" 32-bit ARM-based Arduino Due.

With the Arduino platform being made available on higher-power processors, the overhead of the extensive library/abstraction layer becomes less of an issue. That prompted me to re-examine the Arduino. The combination of 32-bit processing power and the extensive library set offers an incredible amount of value. In fact, even on the eight-bit MCUs, I now see value in the extensive set of libraries. It's far faster and easier to achieve proof of concept for a new GPS, WiFi, or other module when the driver code is already written for the Arduino than it is on a bare-metal MCU.

With prompting from Designline Editor Max Maxfield, I recently dove further into the Arduino ecosystem by creating some custom-designed, Arduino-compatible hardware. In brief, I'm designing an Arduino-compatible sensor board for use with small and midsized robots. Without the Arduino platform as an option, this would have been a PIC-based design for me. That would have been fine for my own use, but Max has been spending time learning the Arduino, not C or ASM on a PIC MCU.

This illustrates one reason to consider the Arduino in a professional environment: The language is now well known enough to be a factor in the selection process. When building a device that someone else may need to customize, the device's sales potential opens to a much larger group of people if it's Arduino-compatible. Many of you reading this blog are familiar with MCU programming, but the majority of people out there are not.

This board will have a set of SRF04 ultrasonic range finders. To find a range with this sensor, the SRF04 is instructed to send out an ultrasonic ping. The MCU times the interval until the return echo. This time is translated into a corresponding distance value.

An Arduino library for this sensor handles all the nitty-gritty details, so there's no need to spend a lot of time getting to know the sensor. That can always be done later, but you can get a lot of work done before needing to dig deep. The key remaining question to me: What makes an ATmega chip into an Arduino?

The Arduino uses an open-source design, so it's easy enough to find and examine the schematic. However, the schematic doesn't hold the answer. It's more or less a garden-variety Atmel MCU design. Some versions use a second MCU for USB connectivity. Some communicate over RS232, and at least two varieties use the ATmega32U4 with built-in USB connectivity.

Further study reveals that it's not the hardware that makes an ATmega chip into an Arduino -- it's the boot loader. This means that nothing special is required in the MCU portion of the hardware design. The ATmega32U4 and just a few popcorn components comprise all the required base hardware. The following image shows a minimal, hand-wired board that is fully compatible with the Arduino IDE, which recognizes it as an Arduino Leonardo.

The Arduino ecosystem may be primarily an education and hobby world, but it may not stay that way. The availability of higher-power MCUs and today's rapid design requirements mean that the Arduino may very well end up solidly in the commercial developer's tool kit.

In my next blog, we'll walk through some of the decisions that will mold this into the "Sensor for All Seasons" Max hopes to get.

And, just for kicks, I took the sensor board, removed the sensor ports and put in a motor driver without changing the form factor. I'll stack the two and have a small Robot. I'll be talking about it at EELive in the Gadget Smackdown.

So do I LOL. In fact we have two projects on th ego. The first is our Universal Screw-Block Proto-Shield for Arduino -- we're poised to launch this as a Kickstarter project -- we already have the Kickstarter page ready to rock-and-roll -- we're just waiting for Kickstarter itself to give us the green light.

The second is the sensor board for my Arduino-powered robot. Ideally I would like to use a 32-bit Arduino (or chipKIT equivalent), but I'm using motor controllers from Adafruit and their libraries access low-level MCU stuff that means they work only with Arduino Unos or Megas. My robot has three wheels and can move in any direction -- I'm planning on having 9 ultrasonic sensos all around -- handling these would bring my little mega to its metaphorical knees. Enter Duane's Sensor Board for All Seasons -- this will handle all of the "grunt work", so all my main Mega has to do is send an I2C command to one of the sensors saying "Sup?" and the sensor board will respond along the lines of "there's an object at 60cm and it's approaching us at 5cm/sec" ... the main controller will know which direction we're moving in and how fast, so it can then use this info to decide whether or not to "raise shields" and zap the dog or run and hide LOL

I look forward to seeing your project with Max. I was imagining the Arduino as a rapid prototyping platform for new sensors and peripherals that need either a I2C or SPI interface. I started a UAV telemetry project based on the Arduino Micro. The design is done, and I"m puting together the bom to order the parts at the moment. The PWB design will follow. I'm using it to test some 900Mhz radio modems and learn their care and feeding.

By the way, I never realized you work for Screaming circuits. Our company will be looking to you in the near future for quotes on some prototype builds....small world!

@Duane: Just to clarify and/or summerize -- you built this hand-made board as a proof-of-concept that you could use the Atmel CPU and make an Arduino Leodardo-compatible board. The next step is to create a custom Arduino Leodardo-compatible sensor board that can handle up to four ultrasonic ranging modules. The idea is for this sensor board to off-load the main CPU on my robot. I'm doing my happy dance :-)