Pages

Labels

Featured Posts

Wednesday 26 February 2014

Coding the Arduino in C++ - Choosing a development environment

So now that we have decided what language to write the code in, we need to decide what development environment we want to use, and with the passion that surrounds Arduino, it is not surprising to discover that we are going to be spoilt for choice.

It is however important to remember that we have a number of requirements that we should keep in mind when assessing each environment, these are:
  • Coding in C++
  • Ability to use testing frameworks, including:
    • Google Test (GTest)
    • Google Mock (GMock)
  • 'Projects' that can build on Continuous Integration (CI) build servers, in particular: 
    • Teamcity

Arduino Studio

The first option you are likely to come across, is Arduino's own development environment, Arduino Studio, which truly is a multi-platform set of tools. Even if you end up not using this application, it is strongly advisable to install it, ensure that items like the Windows USB device driver are installed and working, this is well put together and will ensure some of the easy to forget, and hard to retrospectively install are done for you. I would also encourage you to spend a little time going through the process of writing a few of the introduction sketches, as this will make the jump into Arduino development that a little smoother.

The biggest main reason I have chosen not to use Arduino Studio is that as I progress I want to be developing the coding side of the prototyping I plan to do using a truly Test Driven Development (TDD) approach, and run the builds themselves on CI build servers. Although that is not impossible, the TDD framework, and CI environment discouraged me from going down this route.

Atmel Studio

Another option out there, and the one built by the manufacturer of the microcontroller chips, is Atmel Studio, a fully featured Integrated Development Environment (IDE), which is in part because it has been built on top of an existing industry standard IDE, Microsoft's Visual Studio. The fear here would normally be that this would be an expensive option, but it isn't, both Microsoft and Atmel provide their portions of this product free of charge. The biggest problem I have with this is that in order to run the application you must be running Windows, and this does not easily fit in with the mixture of development machines that we use (a combination of Windows, and Mac).

Eclipse

So what else is there? In every branch of software development a product comes up time and time again, Eclipse, and I know that there are many out there that won't have a bad word said about it. However the consensus in our development team is very negative towards this product, so selling it as a development tool for Arduino could adversely effect on Arduino development.

Back to basics

Everything investigated above, and many other options not documented in this post, have all had issues that makes them unsuitable for our requirements, so in the end we have chosen the most universal of the coding environments, the text editor.

More precisely we have chosen a process for developing, rather than an environment, in particular using CMake to define a build file, and Rake as the script that will run it.

Now I know that there will be many out there that are shuddering at this idea, having spent many years working in the comfortable surroundings of Visual Studio, I know how easy it is to become dependent on an IDE that does much for you, and highlights clearly anything it has a problem with, and with third party plugins, like JetBrains Resharper, the process of coding becomes simpler still.

But in this day and age, understanding an assortment of languages, and environments is what all developers should be striving for, and a scripting language like Rake can be used on so many platforms that not learning about it would seem foolish.

What's Next

In the next couple of post I will go through setting up both Windows and Mac OS X, to build projects using this approach, and then I'll detail how to setup Teamcity to enable automated builds and tests to take place.

Once we have done this, I will start a series of posts in which I will take you through the process of developing Arduino projects in a truly TDD approach. 

Tuesday 18 February 2014

Coding the Arduino in C++ - The reasons behind my decision.

By default most people will code their Arduino boards using the Arduino Studio, which means writing code in a variation of C. Personally I don't have a problem with that, for most developers using this board it's perfectly fine, it's just that I want to do so much more than I can easily achieve with C. Therefore I'll be developing in C++, and will starting with this post describe the decisions, options and then steps I am taking to achieve this.

Firstly I feel I must explain what it is that I want to achieve that the variation of C that is used in Arduino Studio, either doesn't provide me with, or is not as straight forward as I feel it ought to be.

Firstly I am working in a truly agile development environment, and a key to agile development is Test Driven Development (TDD). Now I am aware that there are TDD boiler plates out there that can be used in Arduino Studio, the arduino_c_scaffold git repository created by the throwtheswitch.org guys looks a really good place to start, however I am looking for something with a little more support behind it, and Google Test (gtest) feels a better solution.

Going hand in hand with the unit testing framework, is object mocking, important because if you aren't mocking, faking, or otherwise separating code that you are testing from any dependencies that code is using, you are not doing unit testing, which in itself breaks a core part of TDD. The throwtheswitch guys do have this covered too in their product cmock, and I would fully recommend checking what these guys are up to, as for most this really can be seen as a solution to the TDD problem, but again what I am looking for is a framework that is more widely used and gtest sister product Google Mock (gmock) is the framework that I prefer to use.

Beyond TDD, there are other reasons for choosing to go down the C++ route, not least because we are anticipating having to incorporate hardware that is not currently available in pre-built Arduino shields. If you are building new hardware, or providing libraries of code that other developers will use on Arduino, these are typically written as C++ libraries, so the fact that we are expecting to be writing C++ for these libraries, and the unit tests, it seems sensible to write all the code in C++.

So those are the reasons behind my decision to code in C++, next I will select the development environment, and describe setting up the automated build system we use, Teamcity, to build, test, and deploy these projects.




Monday 17 February 2014

Arduino Uno - Unboxing

Having decided on prototyping using the Arduino broad, and having little previous experience of doing so, it seemed sensible to go with the most popular starter board on the market, the Arduino Uno. It has been a while since the original board first appeared, and so the board brought was actually the third revision of the board, the R3.

When the board arrived it came in a moderately sized box for a board so relatively small. In part I think this is because a lot of these boards are brought by first timers, and the box is the first part of giving the customer some reassurance of the quality of the device inside.


When you open the box up (simply removing, or slitting the tape), you first find what looks like a colourful booklet, this turns out instead to be an A2 sheet which can be used as a two sided poster. If your looking for instructions on getting started, the only thing you really get is a link back to their website, this though I think is a very sensible approach, almost everybody has internet access 24/7, and rather than reprinting hard-copy instructions whenever a change is made to the hardware (or firmware), the latest information is always available.

Having taken the pamphlet out of the box you get your first sighting of the board itself, and a very well manufactured board it is.


Taking the board out of the box an it looks anything but hobbyist built, with all components perfectly aligned, and securely fixed.


Turn the board over, and you get an extra level of sophistication, with the board coloured in an inverted palette to the front, and plenty of information about the board itself.


That just leaves the final thing to do, plug it in and start playing.



Saturday 25 January 2014

My hardy friend.

What is Arduino

Before heading full speed into the first of many posts about building the prototype, I thought I ought to introduce what will make all this possible, the Arduino. {For those interested in the entomology of the word, it's an Italian boys name, and means hardy friend, hence the name of the blog}.

The Arduino micro-controller board is today 'de facto' tool for prototyping smart gadgets, and can lay claim to being the platform used to develop some of the hottest gadgets around. From the Pebble watch to the Fitbit, a lot of today's tech either owes it's origins to the Arduino, in the case of the Pebble, or continue to owe it evolution to this device, as is the case with Fitbit which still uses Arduino's for rapid prototyping.

But what are the origins of this amazing device?

The original Arduino was released in 2005 Massimo Banzi, who design the board as a tool for his students to use, Massimo named the device in honor of the 'Bar di Re Arduino', a favourite drinking establishment of his in the northern Italian town of Ivrea.

The fact he came up with the device in the first place is very much a result of shrinking budgets, and reduced time teaching the students. Both of these, plus the changing requirements of courses teaching interactive electronics design, meant that the micro-controller that the academic world had been using for decades was no longer suitable for his requirements.

What he wanted was a cheaper, more powerful, and more flexible micro-controller that his students could use as the core of their development projects.

With strong beliefs in the open-source community, Massimo had sort to open the project to as many people as possible, and when it was announced that the course which he was teaching was going to be closed down, he decided that the whole thing should be made open-source.

What he did not expect to happen was that this device has since it's release revolutionise DIY electronics world wide, with a number of companies selling controllers based upon the platform he came up with. Today the basic board is cheaper than ever, and advances in electronic design and manufacturing mean smaller and smaller devices are becoming available.

And as for the pub that gave the device it's name, well fans of the device travel from all over the world to in the pub, the only problem is no one working in the bar knows what an Arduino is.
  

Introduction

Like anybody with an interest in technology, I have always felt that I have an amazing application or gadget somewhere inside of my mind, but up until now I have been unsure what it is. But over the last couple of days that has changed, I think I have found one and would like to share with you the processes I go through in making this idea a reality.

I won't say what the idea is at the moment, I don't want to have somebody else take it and build it before I had a shot at doing it myself, but over the months ahead I will document the various stages that I go through to product a proof of concept, and if it progresses further, how I take that concept and produce a product from it.

What I am prepared to disclose at this point, is that at the core of this idea is an innovative hardware platform. In order to make a proof of concept possible I will be building it on the Arduino micro-controller, more about this in the next posting, and during the process of building the concept will be discovering lots of useful information about this device, which I will share here.

I encourage anybody reading this blog that has any constructive input into this process, please feel free to leave any comment that you have so that not only do I learn from it, but hopefully others that discover this blog will learn too.

 
 
Blogger Templates ReadABlog.com