Visual Studio Arduino Object Browser

by Visual Micro 2. May 2010 17:17

The visual studio object browser simplifies browsing of arduino/wiring libraries, custom libraries and your own code.

 

How to link an arduino code library to a visual studio project

by Visual Micro 11. April 2010 19:56

You can easily attach libraries into your arduino projects using the free visual studio addin. Library files are linked and not copied to the project which means that when libraries are updated your projects are automatically updated.

Clicking the libary button on the tool bar provides a list of installed arduino libraries (core libs only at the moment). Selecting a library from the list automatically adds a new filter folder called "_libraries\Core\<libName>" and links all of the source and header files from the library into the project.

An #include is also automatically added to the open .pde source. Example...

 

How to open a sketch in the arduino ide using visual studio

by Visual Micro 11. April 2010 19:52

You can use the visual studio tools menu "open sketch in arduino" to open and compile the current sketch in the arduino ide

The option works well if you set the arduino preferences to use an external editor.

When you click "compile", in arduino, it will automatically reload the sketch if the source has altered

How to select an arduino serial port in a visual studio project

by Visual Micro 11. April 2010 17:20

The serial monitor is not included in the initial version of visual micro. Therefore the serial port need only be selected to upload to an arduino board using visual studio. An arduino serial port is select using the tool bar drop down menu as show below. When the project is next opened the addin will reselect the same port.

The serial ports menu is dynamic, the menu will detect changes to the connected serial port list of the computer (even whilst the menu is dropped down). The list is in order of device connection. These features are especially useful for device identification when working with multiple boards and ports

Example 1

 

Example 2

 

Uploading will invalidate your arduino warranty, we accept no liablity should any problem arise from using this tool to upload to arduino

 

 

Using the arduino boards menu in visual studio

by Visual Micro 11. April 2010 16:59

The visual studio tool bar provides a way to select which arduino circuit board each project will use

When a board is selected, all of the items in the "_core" filter are removed and replaced by the files from the newly selected boards arduino core

If the _core filter does not exist then it is created. In the example below, the board is about to switch from "atmega168" to "arduino mega"

In the current visual micro version the include and source files are automatically separated into "inc" and "src" filters (see below)

 

 

"One Click" add new source and header file(s)

by Visual Micro 11. April 2010 16:57

The "New" menu contains two very useful options enabling new files to be quickly added to an arduino visual studio project . This is a useful features if you often need to add a new .c and .h files to your projects.

note: To add files to your arduino projects in visual studio you can always use the standard visual studio "add file" or "add existing file" options.

Workflow Objective

Create a new .c file named MySubFile.c to the project (if it does not already exist) folder and link it to the project "Source Files" filter

Create a new .h file named MySubFile.h to the project folder (if it does not already exist) and link it to the project "Header Files" filter

Insert an #Include for MySubFile.h to the currently active source file (or .pde)

Open the new files for editing

 

How To

1. Choose to add .c/.h or .cpp/.h

 

2. Provide a name for the new files

 

3. Visual Micro does the rest!

How to automate arduino development using visual studio

by Visual Micro 11. April 2010 11:16

You may add any of the visual micro arduino commands to the visual studio tool bars and menus. You may also reference the commands in your visual studio macros. Serial ports, libraries, boards are also available as commands.

Example

The "Arduino Mega" will appear as a visual studio command (Tools, Customise), COM23 (if it exists) will also appear as a command, the SoftwareSerial library will also appear as a command.

Therefore you could add there new tool bar buttons for each providing a "one click" option to select options you use regularly. or you can create a workflow (macro) that automatically selects the "mega" board, sets COM23 and includes the software serial library into the current project.

Example: Customise Visual Studio Arduino Commands

 

Unsupported Upload Note

The compiler outputs .hex files into the <project>\_vsaddin\_build folder. The addin projects can be run from the visual studio command line. This makes it possible to design windows applications using visual stuidio that upload different arduino sketches based upon conditional factors. If you use the arduino visual studio compiler or the arduino uploader then please beaware that no liability is accepted by us and that you will break your arduino warranty

Quick Start Guide to Arduino Programing in Visual Studio

by Visual Micro 11. April 2010 10:54

 

After installing the .dll and resource files, you must configure your Visual Micro options:

 

Visual Studio | Tools | Options | Visual Micro

 

The most important option to set is the Arduino Application under [Locations]. Select the path to your Arduino executable (arduino.exe).

 

 

I suggest copying the latest Arduino (0018) to a folder called C:\Arduino\ArduinoIDE. By using a common Arduino folder you will find it easier to update to the latest Arduino versions in the future without having to reset your Visual Micro options.

 

After entering a valid Arduino folder, click the Arduino Library and the GCC Application (WinAVR) folder paths. They should automatically determine their locations.

 

 

 

 

 

After setting the Visual Micro properties, click [OK] to close the Options window. After a short pause (< 2 sec), the Visual Micro toolbar should appear containing the Boards and Serial ports menu.

 

 

Select your Arduino board and the serial port it is connected to.

 

Opening an Existing PDE

 

In Visual Studio select File|Open, and navigate to a folder containing an Arduino sketch (.pde). Select the sketch and click [OK]. The sketch will open briefly and then the following will happen automatically: the sketch will close, and it will be re-opened in a Project & Solution with the same name as the .pde; the Project & Solution will be created automatically in the sketch's folder.

 

Adding Libraries

 

You can add libraries using the Libraries menu on the toolbar, or add files to your projects as you normally would. When you add .c or .cpp files you will find that they automatically associate themselves to a custom build action of AVR_C_GCC or AVR_CPP_GCC (right-click with your mouse a source file to see what I mean).

 

If you encounter any problems just re-associate source files to the correct custom build tool. If you have an older Visual Studio project and want the toolbar to work with it then just edit the Visual Micro .vcproj and .sln files with Notepad, and copy over the platform and build settings.

 

NOTE that Visual Micro only compiles correctly when the build type is set to AVR|Win32. This is designed to ensure that Visual Micro doesn't mess with your normal Visual Studio projects.

 

Click compile and enjoy!

 

How to compile an arduino sketch in visual studio using avr-gcc

by Visual Micro 11. April 2010 10:50

The following visual studio arduino compilation overview is for information only and is not required knowlege to make use of the addin

The gcc system is used to compile .hex files (*see note at the end of this document) that you will find in the _vsaddin folder of each project. In this folder you will also find the .bat files that visual micro uses to compile each sketch

When a project has been compiled a folder will be created called _vsaddin\_build. This folder will contain the .o object files from the gcc compiler and also the compiled .elf and .hex files

Prior to compile/rebuild, the addin creates a unique list of include paths from all of the .h files included in the project. These paths are passed to the gcc compiler along with the avr\include folder. 

The list of paths will also include the current projects' reference paths (see visual studio project options). (The arduino addin does not add or alter visual studio project reference paths, it just uses them if they exist)

note: in the initial version using build>solution from the visual studio solution menu fails to compile. Use either the solution rebuild option or use the compile buttons on the addin tool bar

The .\_vsaddin folder

The Build/Compiler Output Window

note: when you compile, if a previous compilation does not exist, you might see some warning messages in the visual studio output window. these can be ignored. the output window will show you if the compilation succeeds

 

arduino visual studio compiler .bat files

The following .bat files are created and maintained automatically by the addin. The events that cause these files to alter are as follows:-

When you switch board

When you add an arduino library

When you compile the project

 

Description of each file

avr_build.rules 

this is a static file containing the definition of the custom build.rules for the project. the file is configured custom build rules on the visual studio project menu 

this file is responsible for providing the GCC_C_AVR and GCC_CPP_AVR custom build tools. when you add .c or .cpp files to your project they should automically be assigned to the respective rule./tool

 

build_all_begin

clear temp files from prev build

build_env.bat

enviroment variables and board/port settings 

build_c_item.bat

called once for each .c file in the project. creates a filename.c.o file using avr-gcc

build_cpp_item.bat

called once for each .cpp file in the project. creates a filename.c.o file using avr-g++

link_all.bat

 

creates a .hex from all the .o files using the avr tools and/or uploads to the arduino using the avr upload tool

 

* The visual studio arduino compile option is provided as way for you to verify that your code is correct. You should not upload the resulting compilations (.hex) to your arduino unless you are happy to void the arduino warranty. These feature(s) are also provided by us without warranty or liability.

 

How to enable arduino Intellisense in visual studio

by Visual Micro 11. April 2010 10:40

2nd may please see archive for visual studio 2010 intellisense ardupilot overview

 

The visual micro addin provides intellisense using visual studio for all arduino core, library and your own project files

If you add or link your own files to a visual micro project and the intellisense doesn't detect them. Just click compile on the tool bar (or rebuild the vs project)

Click CTRL+J in your code to see a master list of properties. See example...

When switching board, when adding an arduino library or when you add or link multiple existing files to a project you will see the background progress for the intellisense update

If your arduino intellisense stops working (somestimes happens with visual studio) then shutdown visual studio and delete the .ncb file of the project (it's in the projects folder). Important - Only delete the .ncb!

 

News - 2010

2nd May - Visual Studio 2010 - Navigating the Navigator with ArduPilot

18th April - Supports multiple sketch (pde) files in a single project (ArduPilot)

17th April - Supported on all windows language versions

14th April - First test success

11th April - The arduino visual studio beta was released today

Links and References

Visual Micro Forums here

Visit the Arduino forums here

A different solution here

Bob Powell's solution here

Ardupliot example here