Saturday, June 28, 2014

Looking At Arduino From A Programming Viewpoint

Because the Arduino single-board microcontroller is a piece of hardware, most of my focus in trying to understand the world of microcontrollers (MCUs) so far has been on the hardware aspect. You know -- what components hook up to which pins on the Arduino, and what do the different electronic components do in each of the circuits I cobble together.

To get the most out of microcontrollers, though, one also needs to understand the software or firmware side of things. To get a better picture of how Arduino software functions, you may want to consider reading an article John H from the Humboldt Microcontrollers Group linked me to. The article is titled, "Understand Arduino development" and starts out this way,
"Arduino is a fantastic platform for getting started with embedded software development. You are provided a development board, and programming IDE all configured to work together immediately. As a developer, all you need to do is write your program, press a button, and it is compiled and uploaded to the board where it begins execution. It's important you understand the fundamentals of what is happening in the background to make this work for you."
I need to do more online research about the differences between learning C and learning C++. Then I need to buy Nick or John a beverage and have a discussion about whether my C / C++ studies should be done with tutorials, websites and books that focus on C or on C++. If I need the basics of C to do much of anything in C++, it might be helpful to know what specific aspects of C++ should spice up my C studies. According to the article linked above,
"The Arduino IDE compiles your project as C++ using the GNU AVR toolchain...So you are writing "real" C++ code, though there are a few hardware limitations to keep in mind. It's called the GNU AVR toolchain because it compiles code for the AVR micro-controller architecture."
I am especially interested in the section of the article that talks about large projects. Most of my 'learning' projects will be pretty simple, but down the road I hope to get to the point where I'll build an MCU project with fairly complex functions and programming requirements. It appears it
will likely be helpful to learn how to write libraries in the Arduino IDE as well as sketches. According to the "Understand Arduino development" article,
"The Arduino IDE has the concept of a "sketchbook", and the programs that you write are called "sketches". So the sketchbook is a folder which contains all of your sketches...The sketchbook should also contain a folder called "libraries", which allows you to share code across sketches. Similar to structure of a sketch, a library needs to be a folder where the name of the folder is the name of the library...The main reason you would consider this is because you should split your project into multiple files by their logical function. You are not limited to using libraries to achieve this either, a sketch can have multiple source files...Splitting the project into modular files is key for long term development. It allows you to reuse code later on without having to copy and paste individual functions out of source files, rather you just include the library or add the source files to your sketch. When you make your project modular, you can document each module on its own, which allows others to use that module in their own projects without having to understand how the entire program works."
There are lots of two hour introductory classes or sessions on 'Learning The Basics Of Arduino' where a person starting with no knowledge about MCUs or electronics can hook together a basic circuit and make an LED blink. But like anything complex and powerful, there are many hours of study and experimentation required to become reasonably skilled in the Art of Microcontrollers. Reading about "splitting the project into modular files" reinforces that blinking an LED is significantly different from becoming skilled with MCUs.

Reading the article (twice, so far) that John linked me to and doing a bit of related online research has had a definite impact. It convinced me I need to block out more time in my schedule for completing the work in the Jeremy Blum video tutorials and for gathering background information for a couple microcontroller projects that aren't in the videos.


No comments:

Post a Comment