There is no better way to find out how a technology compares to an other one then doing a complete project with both technologies.
In order to compare working with the mbed and working with the arduino, I redid the first project I had done on the arduino, but this time using the mbed microcontroller.
The project consists of 3 servos, each controlled using a different potentiometer. The three servos are attached to arms and there is a pen at the end. So we have a drawing machine. On top of that, we want a record button that will keep in memory all the movements and a load button that will redraw what the machine had previously done. The machine needs to be able to unplug and keep the data in memory. For the sake of keeping it brief, the mbed machine keeps the data and read it but won’t redraw the actual drawing.
Since I made this project when I just started learning the Arduino, redoing it with the mbed is a coherent test.
Circuits :
Arduino
Mbed
The circuit is basically the same on both platform (the pins change but it’s globally the same). The big difference is that the mbed has an output current limit of 50mA. The 5v output of the Arduino has a limit of approx. 450mA. So the major change in the circuit between both microcontroller is that the mbed uses external power to power the servos and the computer USB to power the mbed. The Arduino only needs the USB power for everything. I guess in this way the Arduino was a tiny BIT simpler.
Code :
Arduino
You can download the code here :
http://slab.concordia.ca/wp-content/uploads/2013/04/servoPotentiometer_v5.zip
It uses the EEPROM of the Arduino to keep the data when the Arduino is disconnected. This has many disadvantages, first the EEPROM of the UNO is only 1kb. That is very little amount of space. Also, there is a finite amount of time you can actually write on the EEPROM, this limit is quite large (around 1,230,163 times based on this article : http://hackaday.com/2011/05/16/destroying-an-arduinos-eeprom/) but it is still a limit of the system.
Mbed
You can download the code here :
http://slab.concordia.ca/wp-content/uploads/2013/04/ServoProgram.zip
When you plug the mbed in your computer, the microcontroller acts as a regular usb flash drive. This means it simply shows on your desktop
In order to write on it, you can use the mbed to write it’s position to a text file, then load this text file on the mbed. This way, you have access to the full memory of the mbed (2.1mb minus the binary size of your program). This lets you save HUGE amount of data for later use and it also lets you look at the obtained data in a very user friendly way.
I guess for this case, the mbed wins by a long shot.
Comparison
Code cleanness : If you look at the code, you will notice that the Arduino code is all in on bug chunk. Creating a library in Arduino is a lot of work and is hell to debug. So most student projects all throw the code in one file, this is how the Arduino is generally used. It is very far from good OOP practices. The mbed working in strict C++ so it is easy to make your code clean and modular. Unzip the mbed code to see it’s structure. Remember it was made by someone with no prior C++ experience (but some OOP experience). So on this point, the mbed wins again.
Team work : The fact that the mbed lets you work in a more object oriented way is already a necessity for team work (each team member can work on their own module, in their separate set of files). But an amazing feature of the mbed online IDE is that it has built-in SVN capacity. This allows for a team of programmer to work together on the same project, keep various versions of the code and merge it all in a clean way. If you plan on working on a large project with a lot of code, then the mbed is your choice.
IDE : The Arduino IDE is simple, has very little features (if you compare it to a beast like eclipse) but works well enough. The online IDE of the mbed on the other side still seems more like a beta of something then a finished product. Simple command like cut and paste did not work, there was a strange bug where my cursor would not appear where I clicked and it completely crashed every time I lost the internet connection. As some of you might know, internet connection in the sensor lab is not super stable so this was a big issue. There exist other alternatives to the online IDE to work with the mbed but I didn’t test them yet. Final word is, compared to the online mbed IDE, the Arduino IDE is much more solid.
Documentation and community : The Arduino community is HUGE. For everything you try to do, you will always find 25 different ways of doing it. This is the advantage of open source technologies in general. On the down side, you have a lot of code (even directly on the Arduino web site) that is buggy or badly coded. The mbed community is much smaller but consists of more advanced programmer. The handbook and cookbook provided on mbed.org are great and allow you to import the code directly into the IDE to test them yourself. At the same time, you won’t necessarily find exactly what you are looking for. The fact that C++ is one of the most used language on the planet, you can generally find ways of doing what you want to do, but it will need more understanding and work. To sum it all, the Arduino community provides ready made code that will generally work but that might not be optimised, working this way is not a really good way to learn. The mbed community provides better code but you might have to work a bit harder to make it work with your project’s needs.
Learning curve : This is where the mbed takes a solid beating. For someone with programming experience like me, but none in C++, learning it is pretty hard. The mbed server side compiler is more strict then most C++ compilers out there and C++ is already a pretty strict language. Sure the code is nicer and will run faster but getting my project done was nearly two times longer on the mbed then on the Arduino. It is good to mention that learning C++ in general can open many doors in the future, while learning how to code an Arduino will pretty much only be useful in the hobbyist realm. But still, using the Arduino is MUCH more accessible for a newcomer.
Overall experience :
I completely see the potential of the mbed for larger projects. A project with a complete team of developer, working on large amounts of code, would never be productive using the Arduino. At the same time, the Arduino has its flaws but it’s very quick to work with and will fit most smaller projects. The mbed will probably please to the more advanced user, but people with less programming skills will be more at ease with the Arduino.