A few weeks ago the new version of the free Visual Micro addin for Visual Studio was released. The addin provides full featured, 100% compatible, arduino development inside all Visual Studio 2008 and 2010 versions (except for express). This release means that we can code, compile, upload and burn bootloaders to any Arduino microprocessor using Visual Studio. Arduino for Visual Studio can be downloaded from here
Click to see more example images of arduino visual studio
The addin provides complete compatibility with all arduino libraries and cores, in addition to intellisense, goto compiler errors and many other useful features. One useful example is the "Auto Pause" and "Auto Resume" of serial before and after upload (unless using ISP).
Multiple ground station and/or uav projects can be organised in a single Visual Studio solution
Compiler #defines are shown clearly in all source code. A high speed compiler uses file modification times to optimise the work required. Below you can see that an arducopter compile was completed in 5 seconds. An unlimited number of serial tool windows are available.
This example shows the compilations resulting from clicking a visual studio "Build Solution" command.
Note: The ArduCopterMegaHybrid project is a full arducopter program with a minor change to the "pwm out", it's switched to i2c for the SD21 servo board. This project is not available for release it just happened to be available to demonstrate the speed of the visual studio arduino compiler
There are a few un-documented features still to be tested. One, for example, is an option to switch on support for parent library folders. This might be useful for diy drones projects that require two different versions of the same library. The feature allows the compiler to look for an additional "Libraries" folder in the parent folder of the current sketch.
Another feature we might find useful is a menu command that toggles all related sources in/out of the current project. "Project>Show All Arduino Files" does not affect sketch compilation, instead, this feature includes the sources of the arduino core and all of the libraries that have been "#included" into the current sketch. This makes is very easy for library developers/explorers to optionally work with libraries and core within their sketch projects.
Read more about Arduno for Visual Studio
Comments
This is ******* AMAZING!!!!!!!!!!! I just discovered this... It is going to make my development life so much easier!
Wow, Fab, this is really helping me now. I'm able to follow the code as it flows through all the difference files. That was the biggest problem I had. Right-click-find-references is SO good. Thanks for all your help.
1) I don't know for sure that is the case, in fact, I suspect it is not. I think that what happened is I was in my Admin account because I had just installed VS, and then immediately ran the VM installer without changing over to my normal account. I played with it in that account for a few minutes. Then when I changed over to my normal account, that's when I found it wasn't working. It largely precipitated because I followed your directions to download VM for free in the other blog post, then went right ahead and did the VS installer.
But yes, that note would be helpful for guys like me. ;)
2)No, I did not see that, but I can't say it wasn't there. Perhaps I can log into my wifes account and check, since VS should be installed, but wouldn't have the user preferences set yet.
Ok, I just did that. I ran the VS installer, from within her non-admin account, no problem. Then I opened VM and got a nice pop-up telling me I need to run Arduino first, since I hadn't done that in her account. So I did that, and the readme did pop up in the window.
Before I did the tools/options/visualmicro thing I was able to open Arducopter, and had the same "problem" I experienced before. So that explains it all. There's probably not much more you can do to make it fool-proof other than putting a note about accounts in the install notes.
@robert that is good news. yes the arduino.exe path is the only setting that is required. without it the addin can't find the boards list, libraries, avr stuff etc. I made it relative to the current user because the addin also uses the arduino settings file (preferences.txt) which is stored in the current users local roaming profiles.
Two Questions Please
1) It does seem that a minor change to the install notes might be required. Are you saying that because of the way your machine is secured you have to logon as admin to run an installer? If so then a note should be added to the install notes to remind users to logon as a normal arduino user before running setting the arduino path in Visual Studio??
2) When the arduino path was NOT set you should have seen a big "Welcome" note with a readme in the "Sketch Builder" output window. Did you see that when you had the problems?
Ok, nevermind... I went back and RTFM again, and I think I fixed it. I had to go back and do this: Open Visual Studio and set the location of the arduino.exe in "Tools>Options>Visual Micro>Arduino>Arduino Application
I think what happened is that I'm not Admin on my WinXP installation for security reasons. I installed VS in my Admin account, and made that change. Then I went into my normal account and started playing with the software. I must have two instances of the VS, and needed to make the changes to both?
I now have Tools>Show All Arduino Files. And they're all there, even the standard Arduino examples... which I have to get rid of now. ;)
Still can't find HS4_REV however...
OK, nope, not doing what I want.
So I'm in Arducopter.pde, line 1330, I want to find out where "calc_loiter" is defined. It says it can't find the definition. Actually there are a lot of functions that are underlined in red and show undefined?
That is the name of the variable HS4_REV shown in Mission Planner. Not sure, maybe it doesn't carry over into the arducopter project?
Sorry, I answered that up above but was not clear. I do not have "Project>Show All Arduino Files" or "Add Arduino Library". I do have "Show All Files" if that's worth anything.
Aha! That brought in all the files, I think.
All I want to be able to do is to right click Go To Definition or Find All References, and have it find all the references. Before, it wouldn't find things because they weren't open, which seemed a bit nonsensical to me. You know, I'd click on something and it would say it can't find the definition.
Ok, so now maybe it's working right... maybe you can help me with an example. So right now in Arducopter for the trad.heli, the tail servo output reverse function does not work. I'm trying to see why. The variable is HS4_REV. So I do Edit/Find and Replace/Quick find, and it says it can't find anything. I've searched entire solution, and current project. Nothing. Doesn't make sense. Am I doing something wrong?
@Robert it all sounds okay so far.
1) it doesn't auto open any files except that it auto opens the arducopter.pde if there were no other files open the last time you closed the project. the way visual studio works is that it remembers which files you had open.
2) as you rightly say the libraries and core files can be seen under external dependancies. this allows you to use "fine & replace in files" without mistakenly updating core or library files. The compiler should be working if you select the correct board and click "Build Solution" or "Build Porject"???
3) if you would like to actually see the library files in the project then we need to see if you have that menu item "Project>Show all arduino files"? and I also need to know if you have the "Project>Add Arduino Library" menus that I mentioned in a previous comment??
thanks
Looks like I can add the other files by going Project/Add Existing Item But i don't know why I should need to? I know once when I opened it, it opened all those files together.
Fab, no they are not in solution explorer either. They do not, have not ever, automatically opened the way they do in Arduino. Even Arducopter.pde must be opened by double clicking in S.E.
No, the sketch would be:
C:\Documents and Settings\Robert\My Documents\Arducopter_2_0_49\Arducopter_2_0_49\Arducopter\arducopter.pde
I didn't make the directories. That how they are when I unzip them.