PROFILING AN ARDUINO

Subhangi Choudhary
3 min readJun 2, 2019

--

Arduino, a great tool for people of all skills levels and a microcontroller that has explored its attributes and application to a much optimized level, has the most simple and accessible user experience. Arduino boards are able to read inputs-light on a sensor, a finger on a button, or a twitter message -and turn it into an output-activating a motor,turning on an LED,and publishing something online.Thus it is a key tool for open-source electronics platform and easy-to-use for beginners,yet flexible for advanced users.There are many other microcontrollers available for physical computing like Parallax Basic Stamp , Netmedia’s BX-24, ,Phidgets, MIT’s Handyboard, and many others offer same functionality but all of these tools take the messy details of programming and wrap it up in an easy-to-use package but Arduino simplifies the process of working and is relatively inexpensive compared to all others. The Arduino software(IDE) runs on Windows, Macintosh OSX, and Linux Operating Systems and can be expanded through C++ libraries, and people wanting to understand the technical details can make the leap from Arduino to the AVR C Programming language on which it is based and also AVR-C code can be added directly into Arduino Programs. The plans of Arduino Boards are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, leading to extension and improvision. Even relatively inexperienced users can build the breadboard version of the module to understand how it works and how money can be saved.

Arduino Uno Rev3

But in proper, high-level embedded development environments — and quite a few free and open source ones, as well — we get really cool features like debugging, emulation, and profiling. The Arduino IDE doesn’t feature any of these bells, so figuring out how much time is spent in one section of code is highly impossible. It’s a bit of a chaos, but when we are dealing with extremely minimal tools, any sort of help in debugging is sorely needed and greatly appreciated.When analyzing algorithms, we usually care about the complexity class. This is more of a magnitude of order estimation as it is concerned with asymptotic behaviour. This is rather far from the really of microcontrollers who are much more sensitive to the things we let ourselves fall under the table in common algorithm analysis.

Arduino Uno pin diagrams and its specifications

When we really want to know how our code performs it’s also not enough to just look at what we wrote. It’s much easier in the embedded world than for the actual instructions for the compiler to spew out and thus can be vastly different from what we get by naively translating our C code into assembly. Thus by reading up on compile time optimizations will be a better option and then there’s a lot that can happen.

And even then, if we branch on things that is not known at compile time (e.g. different behaviour depending on some input pin) we really can’t know what will happen. We will have to make assumptions. And assumptions tend to be wrong, even more so when being wrong would be a problem.

So in the end, there’s two sorted options from which we can get reliable results:
1. Just measure on the real hardware. That’ll give us the definite answer (in most cases).
2. Simulate the hardware.

Arduino also has a built in timer called “micros()” it return the time since the arduino has started (untill it overflows).Thus the simplest solution to all this can be to just make a variable “time_code_begin” and a “time_code_end”.Thus ultimately it depends on the user how he can mould some of the cons into pros and tackle the problems with a more accessible solution to make it fit for the specific dynamic program analysis and definite application of computerized data analysis.

--

--

Subhangi Choudhary
Subhangi Choudhary

Written by Subhangi Choudhary

GSOC’22 | Outreachy’21 Intern | GirlScript Mentor

No responses yet