Debugger - Change the Values of Variables on a Running Arduino

DebugSetVariableRunningExample2.png?width=750

In May 2012 a unique serial debugger for Arduino was released in beta and has recently been updated to include the ability to change the values of variables while an Arduino is running.

In the image above you can see the entire code of a very crude (rubbish) Arduino program that is running a debugging session. You can see that the trace messages and variable values are different to those defined within the compiled program.

Approximately 300 people have joined the beta program. Feed back has been really great.

The debugger integrates seamlessly into the Visual Studio IDE providing conditional breakpoint, trace and expression watch features. Unlike a conventional debugger, the Arduino is not required to break (pause) to enable variable values to be altered (optional).

We can use any available Arduino code to conditionally apply breakpoints.

image.axd?picture=2012%2f5%2fArduino+Visual+Studio+Break+Point+-+Condition+Dialog.png&width=750

Complex or simple debug messages can be generated without the need to include the text of the messages in the final Arduino program. For most users this prevents the programs from becoming "bloated" with text/debug messages

image.axd?picture=2012%2f5%2fArduino+Visual+Studio+BreakPause+F5+To+Continue.png&width=750

APM FastSerial is fully supported. Debug using xbee is also supported but you should not fly a debug version without first becoming very familiar with how the debugger works. (If you are unsure then talk it over with us in the Forum). The image below shows a running apm debug session that is sharing the main serial port with the apm code. This is optional, we can share or use any arduino serial port (in most cases) or use other Arduino technologies such as SoftwareSerial.

ArduPlaneFastSerialDebug.png?width=750

The Arduino debugger is currently being distributed for free to anyone who would like to join the beta program. You can join the program by registering for the Visual Micro forum and including a request for the debug tool.

If you don't have a copy of Visual Studio Professional this article explains how to get a 3 year licence for free.

If you do use the debugger for an apm project (or with an apm example) then you will find a few tips for configuring an apm debug session here

The debugger is an upgrade to the free Arduino plugin for Microsoft Visual Studio Professional. Further reading, small wiki and a YouTube example can be found at visualmicro.com

The debugger optionally supports open source visualizations allowing us to create graphical controls that represent the various sensors of our Arduino projects

VisualMicroDebuggerExtensionsVisualizations1_Small.png

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Ok, I'll look into it.  Now, I think the version I downloaded before was 2010, can I somehow upgrade to 2012 with the free keys?  How much is it to actually buy?

    Yes login to msdn.com and you will have VS 2012 Professional as a download option. VS is never an upgrade it is always a full install. You can have both 2010 and 2012 installed on the same computer or can delete the version you are not using. On msdn the MY PRODUCT KEYS area should show your 2012 pro key. I think it's about $450 to buy.

  • and all of the examples :)

    ArduPilotMicroExplorerExamplesAndIntellisenseCodeCorrection.png

  • Does it let you work within the libraries as if they were mainline code?  That is one thing Notepad++ doesn't do well.  You have to figure out for yourself which library a variable is coming from, then go and open it manually.  Sometimes finding things when there are lots of libs is a chore.

    OH YES!! Click "Project>Show all Arduino files". This brings all of the libraries into the vs project so you can work on them just as if they are normal sketch source code. 

  • Ok, I'll look into it.  Now, I think the version I downloaded before was 2010, can I somehow upgrade to 2012 with the free keys?  How much is it to actually buy?

  • I take it back - it does go to the libraries just like the main code. I thought I tried this before, but apparently not.

    Andrew

  • Robert,

    When you right click it does't go for the libraries, however there is a search button that lets you select the folders to search (at least sub-folders from a main folder). As an example, I keep my GIT repository copy in a folder called "LocalAPMRepository". As you would expect, it has sub folders like Arducopter, Arduplane, and libraries. I can define a search that includes only "Arducopter" and "Libraries". Run the search for some text and you will find al occurrences. It just doesn't know anything about the logical structure of the code when you run a text search, whereas when you do the right click on a variable (or function) it will recognize that it is within a class and take you to the definition within the class, or to a global variable if that is the right thing to do. There is no going back once you start!

  • Does it let you work within the libraries as if they were mainline code?  That is one thing Notepad++ doesn't do well.  You have to figure out for yourself which library a variable is coming from, then go and open it manually.  Sometimes finding things when there are lots of libs is a chore.

  • It is worth the effort. I am no expert, but just being able to right click on a variable and have it let you select going to where it was defined, where it was declared, and all references, anywhere in the project makes life much easier. 

  • Interesting.  I got kicked off and couldn't see how to extend it.  Maybe I'll have another look.  I don't use Arduino for anything except compile/upload, because yeah, it isn't very good.  I'm surprised at how crude it is.  I use Notepad++ for all my surfing.  

    Although, I do wonder if VS is just too complicated for me without taking a course or something.  I know when I used it last year, it was definitely too much for me to figure out, which is why I didn't try to hard to extend the free offer.  But I've learned a lot since then so...

  • Robert,

    The VS deal worked fine for me in Montreal. 


    Andrew

This reply was deleted.