04 Jan 2013
Introduction to Arduino
Stuart Cording, Technical Sales Engineer at Atmel Munich gives a concise introduction to Arduino detailing what it is and how to use it.
A small blue circuit board is causing a tiny revolution in the electronics arena. Its name - Arduino.
Hardened embedded developers are likely, upon their first acquaintance with the platform, to turn their head away, seeing the diminutive board as a mere toy and not for real programmers.
But it is exactly for this reason that it has become so popular and that its popularity continues to grow. Since its inception, the family of Arduino boards has grown to around a dozen, offering a range of form factors and microcontrollers to suit a wide variety of needs. Atmel’s AVR® microcontroller has been selected as the brains of these boards, with Atmel’s ARM® processor-based SAM3X device appearing on the most recent addition.
So, with so many different development boards and platforms available on the market, why do we need yet another? The reason is very elegant: microcontrollers are far too complicated. Naturally, they are not too complicated for those of us who have spent a decade or more developing on them. However, those outside of our industry, who are looking for ways to add some sort of control to whatever they develop, need a tool that does not have such a steep learning curve associated with it, as pure microcontroller devices typically do.
Take, for example, a USART. A typical AVR microcontroller has more than one, so the first decision to be made is to select the one to be used. Inevitably the chosen interface is associated with pins that are multifunctional. So, before we can undertake any task, we first need to read the datasheet chapter on the USART and the necessary documentation that describes how the USART functionality can be selected for the chosen pins.
Once that is complete, we need to consider additional items: how to calculate the baud rate; how the baud rate is associated with the AVR device’s oscillator frequency; how to enable USART interrupts; how we can write an interrupt routine for the chosen build chain we have selected. The list is long and a beginner’s time is short. Those of us working full-time with microcontrollers know that it takes years to build up the necessary experience to be able to quickly and efficiently implement such an interface.
The developers of the Arduino platform have realized this and, through their companion development environment, provide an API (application programming interface) and libraries that allow complex functions, such as serial interfaces, to be realized with little code and even less understanding of what is happening in the engine of the platform. Thus, the world of embedded programming and electronics is opened up to hobbyists and students, as well as other areas such as art and fashion design. In fact, embedded programming and electronics can be anywhere, where electronics can be merged with other disciplines.
Why another platform?
There are already many different platforms available for almost all of the well-known microcontroller architectures. However, they tend to be a variation on the same themes – providing a physical microcontroller device in a format that can be used easily without soldering, and enabling a fast start-up by including necessary external circuitry (quartz, transceivers and power supply). Semiconductor vendors are obviously using their development tools as an extension of their marketing programs to promote certain products or on-chip features. According to the Arduino website1, the following features differentiate this platform from the competition:
Inexpensive – pre-assembled modules cost under $50, and the simplest can even be built by hand.
Cross-platform – the coding development environment runs under Windows, Linux and Mac OS. This is a feat that still challenges most microcontroller vendors.
Simple, clear programming environment – based upon the “processing” programming environment, the IDE (integrated development environment) is ultra-clean, limiting itself to just a handful of buttons and a text editor. Additionally, standard C code can be added to a project if desired.
Open source and extensible software and hardware – following the trend of the day, all of the software elements and hardware designs are released under a Creative Commons license. This allows users to modify everything that is made available and improve upon it. Naturally, sharing is also encouraged!
Figure 1 – Side by side comparison of Arduino IDE with Atmel Studio 6 showing Arduino’s simplicity
There is, however, a price to pay for all of these advantages. How disadvantageous the following points seem depends, ultimately, on your point of view:
No debugging – the Arduino development environment only supports programming of the target Arduino board. The lack of debug support is made up to some degree by implementing an easy-to-use textual output via the USART, allowing the output of debug messages. Additionally, the development environment provides a built-in serial monitor.
Fixed software framework – the oscillator speed, for example, is fixed. This means that all the other features of Arduino can only operate within the bounds resulting from the chosen oscillator frequency. Additionally some of the other libraries offered make use of certain hardware features (e.g. timers), which means that they are not available for our application.
What do I get with Arduino?
On the surface, not very much. An Arduino board consists of a power supply regulator; a USB interface that supports both the programming interface and user CDC class serial interface, as well as being an alternative power source; the AVR microcontroller; a reset button; and an array of pin headers. The pin headers themselves are grouped according to a rough function in a way that is easy to understand.
Firstly there is the power header, for Vin, 5.0V, 3.3V, GND and an IOREF to support interfacing to microcontrollers that have a 3.3V I/O supply, rather than the more common 5.0V supply. The “ANALOG IN” header provides analog measurement capability via the microcontroller’s ADC module.
The remaining pins are “DIGITAL”, allowing them to be used as either GPIO inputs or outputs. These pin headers are then further sub-divided into “PWM” capable outputs, and “COMMUNICATION”, where the serial interfaces are available. The only hardware features available on most boards are a single LED connected to a DIGITAL pin, and the USART that is linked directly to the CDC class USB interface on the board.
The intent here is not to provide an all-singing, all-dancing development platform. Rather, the Arduino team is encouraging potential users to meld Arduino together with self-conceived electronic circuits to implement their own creations. Arduino is a means to an end, rather than being the end itself. However, there are some potential functions we might like to implement that suffer from similar problems of silicon package handling or complexity. For example, an Ethernet connection or a wireless link is not a simple task to implement, even for experienced engineers. The Arduino’s mechanical design makes it very easy, via the development of “Shields”, to share standard modules to add this functionality.
Since the mechanical layout of the headers is kept consistent across most Arduino boards, and since the larger boards are a superset of the Arduino Uno board, it is possible to design standard modules, or Shields, that have a high level of compatibility with the Arduino board family as well as with other Shields.
Figure 2 – Arduino UNO superimposed upon the Arduino MEGA 2560, showing the superset relationship across the family
Designing an Arduino shield Despite the shininess of the boards and the glamour of the website, Arduino is still part of the wild-wild-west of all things open source. This typically means a great product and/or service, but documentation is a little on the light side.
There is, unfortunately, no official documentation regarding how to develop an Arduino Shield. Nor is there any official channel by which we apply for official recognition of a new Shield design. Rather, we should simply apply the “thrown it at the wall and see if it sticks” approach, the hope being that if enough people show interest in a Shield, the community at large will self promote it to a point where it becomes too important to ignore.
There are certain challenges with developing an Arduino Shield. Let’s consider them here:
Differing physical board sizes – as we have already seen, some Arduinos have more header pins than others. Obviously not every Arduino shield can define a fixed resource from the underlying Arduino board, since other boards in the stack may also want this resource. Thus, differing Shields could potentially end up being incompatible with one another when stacked.
Differing Arduino versions – as of revision 3 of the Arduino boards, an IOREF pin has been made available so that a Shield can determine if the microcontroller uses a 3.3V or 5.0V input/output power supply. Previous revisions of the Arduino platform do not have this, but future Shields should both use this feature and still be backwards compatible.
Standard PCB templates – there is no real official template or PCB footprint for a Shield, an obvious help when laying out any board that is to be compatible with a given system.
No deliverables defined – obviously, hardware without software examples, software drivers or documentation is less useful than with them.
Of course, as is the way in the wild-wild-west of open source, there are suggestions, work-arounds and recommendations2 for those who care to search for them. If you are the type of person that likes to fit the idea to the specification, rather than create the specification based upon the idea, you won’t feel very comfortable.
Practical implementation of a QTouch shield
The process of developing the hardware element of an Arduino Shield is no different than designing any other circuitry. To complement this article, a capacitive touch shield based upon Atmel’s QTouch® technology was developed. The project is named “TickleShield” and is hosted on the new “Spaces” collaboration website3 from Atmel. The intention behind the project was to create a simple-to-use board that would provide a simple touch interface to compliment any project that needed simple control or the control of a graphical, menu-based system.
For this purpose, the AT42QT2120 capacitive touch controller was chosen, as it provides for five buttons along with a guard-shield to protect from unwanted detections while wiping moisture or liquid from the touch surface. Additionally, the controller offers a proximity detection input that could be used to turn on ambient lighting as an approaching hand is detected.
The status of the AT42QT2120 can be read via six logic outputs that are linked to six of the digital inputs of the Arduino to which it is connected. For the shield to be used in a stand-alone configuration, the outputs of the AT42QT device are also fed to a standard 0.1” header. In the event that the standard wiring of the shield does not meet the user’s needs, 0Ohm links can be removed and the AT42QT controller’s outputs can be reconfigured as desired.
Figure 3 – Block diagram of the AT42QT2120
The schematic for the design is relatively simple. The main challenge lies with designing the PCB. In order to achieve a robust and reliable capacitive touch design, careful attention must be paid to the design and layout of the touch button, proximity detection and guard ring elements of the board. Atmel’s QTAN0079 Application Note (Buttons, Sliders and Wheels Sensor Design Guide) is an excellent source of information in this case.
To avoid redesigning the layout of the Arduino platforms, the open source hardware designs, which consist of EagleCAD projects, can be used as the basis for a shield. Here the Arduino MEGA 2560 was used, taking the board layout and stripping everything away except for the through-hole interconnects around the sides of the board. Importing this back into EagleCAD as a new component guarantees the exact layout of the pins and, if required, the holes.
Exporting the design using the open source EagleUp plug-in, it is possible to then create a proof-of-concept 3D layout in Trimble’s SketchUp tool. Exporting the result into the Maxwell rendering tool, a photo-realistic board design can then be created for marketing purposes.
To complete the package of deliverables it is important to provide, at a minimum, some software for the Arduino platform to serve an example of how to use the shield’s features. From here, the steps to create a library are not particularly complex. There is an excellent tutorial4 on the Arduino website that describes a simple process to move from working application code to a full library that integrates into the Arduino IDE.
Figure 4 – 3D design of TickleShield with SketchUp design superimposed on a Maxwell rendering of same
Page 1 of 1
About the author
Stuart Cording is a Technical Sales Engineer with Atmel GmbH. Over the past decade he has worked with a broad range of different embedded microcontroller DSP platforms from a variety of silicon vendors. He proactively seeks to add to the open source community using github as a means to share useful software projects targeted at embedded systems. Originally from the United Kingdom, he relocated to Munich, where he lives with his family.
Atmel Corporation (NASDAQ: ATML) is a worldwide leader in the design and manufacture of microcontrollers, capacitive touch solutions, advanced logic, mixed-signal, non-volatile memory and radio frequency (RF) components. Leveraging one of the industry's broadest intellectual property (IP) technology portfolios, Atmel is able to provide the electronics industry with complete system solutions focused on industrial, consumer, communications, computing and automotive markets.
Most popular articles in Processing & embeddedembedded world 2014
Capacitive Proximity Sensing Technology Update
Choice: Microcontroller, MCU or Microprocessor, MPU
Introduction to Arduino
Embedded Linux Challenges for Yocto Project