This tutorial shows how to get started with the Arduino debug tools from Visual Micro. The debug tool is integrated into the Microsoft Visual Studio Professional development system which also provides 100% compatible Arduino programming, compile and upload.

Programming with a debugger has long been considered an important tool for every software developer. Arduino does not normally provide debug facilities, so this tool is, in some ways, breaking new ground.

In this video we demonstrate how to add breakpoints that allow us to inspect expressions while an Arduino is running.

This video tutorial also demonstrates how to add conditions to breakpoints. Conditions are very useful when looking for exceptions to the "norm".

The tutorial also shows how to switch between normal Arduino compilation and debug compilation, how to compile and how to upload to any Arduino board.

The Arduino plugin for Visual Studio is free, the debug tool, which is in final beta, will be an optional low cost upgrade but is currently available for free to anyone who wants to try it. We expect this offer to end in December 2012. To obtain a free copy of the debug tool simply join the Visual Micro Forum and request to join the debug beta team.

If you do not have a copy of Visual Studio 

Microsoft Visual Studio 2013 Community Edition is free. Download  :)
I forgot to mention one other point related to the comment by maewert. <br> <br>We found a slightly different but related issue that affected new users to Arduino. <br> <br>The first thing new users tend to do is to add a debugger TracePoint in the main loop() of the Arduino without any conditions and without any form of delay. <br> <br>The problem with that was that the Arduino can send messages faster than some slower computers can process them. This would cause the debugger display on the pc to drop behind real-time and be out of sync with what is really happening on the Arduino.. <br> <br>So many messages is not very useful for real world debugging but we wanted the debugger to handle this situation and prevent users from loosing confidence in the tool. <br> <br>As a result we implemented an intelligent throttling system on the Arduino that blocks and forces the Arduino to wait for up to 40 milliseconds if two Tracepoints are hit within a 40 millisecond time span. <br> <br>The throttle delay is On by default, the delay is configurable in the project configuration properties window and can be disabled entirely (set to false) if required.
Wow, a very nice and needed tool set for the Arduino! <br> <br>In a nutshell breakpoints are compiled into the code and are implemented as serial data exchanged between the PC and the Arduino. The downsides of this approach include larger code size (which could make it too large to load into some chips) and is disruptive to actual code timing. <br> <br>Very beautiful and useful but the user must be aware of the tool's limitations (which is always true:-) <br> <br>I assume the tool treats all of the Arduino library calls as atomic calls and can not step into (provide visibility into) those. Might be interesting to see how the tool works with both older and newer serial calls which are now non blocking - would the message ordering change? <br> <br>Too bad the tools are closed PC-centric tools. Maybe someone will create an open source IDE for the debugger. <br> <br>Thanks again!
Thanks for the feed back. Initially we thought the memory overhead of the debug commands might not be practical but in reality it is very small and works well. So far none of the 100 testers have encountered a memory limit issues. <br> <br>However, it turned out that debugging with this tool takes a lot less memory than using normal serial debug messages because, with the debugger, none of the string messages are compiled onto the Arduino. <br> <br>It is the strings that suck the Arduino memory. Instead, each breakpoint is allocated a number staring at 1 allowing the tool to show the correct text message in the trace windows when required. <br> <br>We found that new users tended to litter their code with serial debug text messages. One user had 1600 bytes of &quot;old style&quot; manual debug messages which caused his Arduino to crash. He switched all of his debug messages to breakpoints using the new tool which consumed less than 200 bytes. A happy user was he :) You will find more examples similar to this on our forum. <br> <br>The more advanced an arduino program is then the less memory the debugger uses. This is a result not of our code but of how the Arduino compiler works. For example, if you are already using Serial in an Arduino program then the debugger will appear to consume very little memory. If not then it will consume the normal overhead associated with use of the Arduino Serial object. <br> <br>Stepping is only between breakpoints, you can not step line by line unless you add a breakpoint to every line you want to step. This is a compromise that seems to work nicely for everyone who has tested it so far. <br> <br>Debugging .Ino and cpp files is supported, libraries in the next release due in a few weeks. <br> <br>A restriction of this system is that you are only able to add breakpoints where you would normally be able to add Serial commands. But that is a lot better than nothing and will satisfy most users! <br> <br>The system is unaffected by serial methods, the Arduino streams the messages in the correct order even when not blocking. <br> <br>We have also tested with SoftwareSerial on random digital pins and it works really well. Actually if you do not want to enable break/pause/continue and you work in trace/report only mode then you only need 1 digital pin, 1 wire and an FDTI cable. The debugger is just as smooth with software serial. <br> <br>One upside of serial transports for debugging is that is works over radios such as xbee, so this means we also have remote debugging. Another upside is that is doesn't require additional hardware or a rocket scientist to make it work :) <br> <br>Yes we would like to add this feature to other IDE's, hopefully open source. <br> <br>However if you investigate the open source debugger visualization extensions on visualmicro.com you will see that they are built using C#. So in this case Visual Studio Professional provides Arduino Compilation, Arduino Debug and also the ability to build new Windows Controls as Graphical Debug Data Visualizations. <br> <br>Visual Studio also manages the docking and layout capabilities of all debug monitor and tool windows. So it won't easy to find another IDE that does it all! <br> <br>However, the basic debugger doesn't need the visualizations to work and I know how this community loves a chellenge :) <br> <br>Thanks again for your good observations. I know that Arduino are working on a new IDE due over the next year or two. If the tool provides some of the features we feel are important for micro-controller development such as intellisense and code completion then we will be excited to help bring this debug tool to a more open world.

About This Instructable




Bio: Author of the Arduino plugin for Visual Studio and Atmel Studio
More by visualmicro:Arduino Debugging - Breakpoints, Tracepoints and Expressions 
Add instructable to: