Arduino Community Joins Visual Studio Community

by Visual Micro 30. May 2015 16:44

Micro-controller circuit board manufacturers Arduino, Sparkfun, Adafruit and the entire community have joined together to make installing and programming micro-controllers much simpler. Previously different files and instructions had to be discovered from various places on the web, then downloaded and installed.

Arduino.cc have designed and included a tool in their development software called a 'Boards Manager'. The Boards Manager provides a simple way to see and install available hardware. The hardware is discovered from .json file(s) that are located under the arduino ide folder. The files contain definitions for avr and sam (arduino uno, arduino due boards)

The Boards Manager is supported with a free respository (managed by arduino.cc) that enables any software author to register (and make available for programming) packages of hardware and software tools.

Arduino have been bold and allowed competitive hardware manufacturers to also use the system, this provides a great facilioty for us all! Therefore, the facility also exists to add additional urls of package.json files that contain the software tools to build programs for different types of Arduino compatible hardware. This can be Arduno clones or entirely different hardware. For example sparkfun boards, adafruit boards, intel boards or the new esp8266 $5 programmable wifi server.

For more information about how to add your own .json urls please see the viaual micro "Ide locations configuration window" or the "arduino ide" file>preferences window. Both Visual Studio, with Visual Micro installed, and the arduino ide use the same system. Some arduino.cc approved thrird party urls are located on ths page

The list of urls shown at the bottom of this page result in the ability to install any of the hardware (and more) shown below. A clever design by Arduino.ccFederico Fissore and the community.

Microsoft Visual Studio management tool for Arduino Community hardware

 

Announcing the Wiring Ide for Visual Studio

by Visual Micro 7. March 2015 11:17

The Wiring Ide has been added to the standard list of supported Visual Studio Ide's.

The Wiring Ide gives an interesting alternative to building programs with the Arduino core/backend.

Hardware manufacturers, such as sparkfun electronics, make simple update packs for Wiring that extend the list of available boards that can be developed using the Ide.

Read more

Image of the Wiring Ide hardware being programmed in Microsoft Visual Studio

 

How to start the Atmel Studio Arduino simulator

by Visual Micro 5. June 2013 07:44

Visual Micro has a new facility due soon to make this process easier.

In the meantime this document describes how you can run the Atmel Studio simulator with an Arduino project.

NOTE: in 1406+ version of Visual Micro step 1) can be ignored because the compiler copies the output files to the local sketch debug/release folder

1) Switch Tools>Options>Visual Micro>Compiler>Always Show Build Path

2) Build your Arduino project, copy the path that appears in the output window to the windows clipboard (without the file:// prefix)

3) In a new instance of Atmel Studio, click "File>Open Object File For Debugging".

4) When prompted paste the build path and "name of your sketch.elf" into the "Specify Object F To Debug" field (example: c:\user\appdata\vmicro\sketch1\board\sketch1.elf). Give the sim project a name and click OK

4) When Atmel opens the new sim project click "No Tool" on the tool bar and select "Simulator" from the "Debugger/Programmer" drop down list.

5) Start debugging (Debug>Start debugging and break),  the sim will run with your Arduino program

That's it!

nb: Some avr processors are not yet supported by the Atmel Studio Sim

Differences between Arduino in Visual Studio and Atmel Studio

by Visual Micro 26. May 2013 16:12

This document is designed to be my own personal observations of note worthy functional differences between the development of Arduino programs in Visual Studio and Atmel Studio.

Both Visual Studio and Atmel Studio provide indentical Arduino compile, upload and debugging features.

Visual Studio Pro has more features for advanced users and if you already own a copy of Visual Studio it would be prefered.

Visual Studio 2008 and 2013 both open quickly and provide high speed intellisense (not perfect but good)

The plugin for Atmel Studio is currently lacking a few minor features such as "project>show all arduino files". This feature is very useful for explore library sources within the project and also aids the class explorers.

Atmel Studio lacks some of the customization features of Visual Studio such as macros.

Visual Studio "disables" source code based on #defined conditions, this is very useful but can also be fustrating because it also disabled intellisense within the disabled code. Atmel Studio does not do this.

Visual Studio intellisense code suggestions are more accurate. Example: you will see Serial,Serial1 etc for mega 2560 and just "Serial" for Uno, Atmel will show Serial,serial1 etc for all boards.

Atmel Studio has the simulator and various other tools.

Visual Studio intellisense understands only C++, Atmel Studio is naturally aware of the micro-controllers native language.

Visual Studio provides web authoring tools within an Arduino sketch project for web based boards such as the Yun (both Ide's support web/network compile and upload). Visual Studio Express or other web design tool can be used so this is not a huge weakness for Atmel Studio.

Atmel Studio is knows about its own micro-controllers and might have a brighter future than Visual Studio for Visual Micro

Visual Studio is required for other "non-atmel" architecures such as Energia and Chipkit

Arduino Robot and TFT Display

by Visual Micro 22. May 2013 19:22

I just read the article below about the new arduino tft that shows the code to draw a sensor value on the screen instead of serial debug :)

It is a nice little Arduino shield http://arduino.cc/en/Tutorial/TFTDisplayText

I recon the visual micro debugger could have an option to print some breakpoint data to the screen for the users. It would be a hell of a  lot easier :)

Maybe a debugger visualization can be created in c# to replicate the shield? Any offers anyone? 

#include <TFT.h>  // Arduino LCD library
#include <SPI.h>

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8  

// pin definition for the Leonardo
// #define cs   7
// #define dc   0
// #define rst  1 

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

// char array to print to the screen
char sensorPrintout[4];

void setup() {
  
  // Put this line at the beginning of every sketch that uses the GLCD:
  TFTscreen.begin();

  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);
  
  // write the static text to the screen
  // set the font color to white
  TFTscreen.stroke(255,255,255);
  // set the font size
  TFTscreen.setTextSize(2);
  // write the text to the top left corner of the screen
  TFTscreen.text("Sensor Value :\n ",0,0);
  // ste the font size very large for the loop
  TFTscreen.setTextSize(5);
}

void loop() {

  // Read the value of the sensor on A0
  String sensorVal = String(analogRead(A0));
 
  // convert the reading to a char array
  sensorVal.toCharArray(sensorPrintout, 4);

  // set the font color
  TFTscreen.stroke(255,255,255);
  // print the sensor value
  TFTscreen.text(sensorPrintout, 0, 20);
  // wait for a moment
  delay(250);
  // erase the text you just wrote
  TFTscreen.stroke(0,0,0);
  TFTscreen.text(sensorPrintout, 0, 20);
}

How to - Arduino code syntax in c++ (.c. cpp .h)?

by Visual Micro 1. June 2012 15:59

We often want to structure the code in our Arduino projects to keep it simple and organised. The Arduino system allows us to create two main types of source files. The first type of source file are the "standard" Arduino source files. These standard files have a .pde or .ino extension and are, behind the scenes, automatically combined into a single file during program compilation. This provides some advantages in terms of simplicity but is not as flexible as using standard C/C++ soure files.

The second type of file are normal C++ files. In Visual Studio it is possible to add C++ files to Arduino projects using the built in menu commands or the additional Arduino "quick insert" commands shown on the "Add New Item" button on the toolbar. The quick insert creates either a .c or a .cpp files and a .h file.

When c++ files are used in an Arduino project the Arduino core is not automatically available to the source code, as it is with .pde/ino files. However, the Arduino core can be included in various ways one of which is described below:-

If you look in "[arduinoide folder]/hardware/arduino/cores/arduino" you will see the arduino core files for include ideas such as hardwareserial.h, string.h or avr/pgmspace.h. HardwareSerial.h provides access to the Arduino serial commands that are normally available in a .pde or ino files.

In Arduino IDE version 1.0 and above the main Arduino program include is "Arduino.h", in older versions it is "WProgram.h". If required we can use the automatically defined ARDUINO constant to check for and use the correct include based on the current Arduino IDE version.

The following code example is how to include the correct Arduino core header and also to provide access to Arduino Serial functions from mycode.cpp and mycode.h files:-

mycode.c or mycode.cpp:-

#if defined(ARDUINO) && (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "HardwareSerial.h"
#include "myc.h"

mycode.h:-

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "HardwareSerial.h"
#include "myc.h"

Tip: All arduino versions 1.0 and above have a version greater than or equal to 100

BreakPoint Hit Count Condition

by Visual Micro 5. May 2012 18:36

Instead of, or in combination with a conditonal breakpoint expression (as described in earlier posts) to make an Arduino trace or break point we can use the "Hit Count" dialog.

The hit count dialog is opened by right clicking any break break and selecting "Hit Count" from the menu that appears (described in detail in earlier posts). The Hit Count dialog allows us to select 4 options.

The example below is self explanatory. If we are adding a break point into a frequent arduino loop we might set a hit count of 30000. In effect this will increment a counter in the code until 3000 is reached, then the breakpoint will be executed prior to the counter being reset to 0. To use a normal "count" for a hit counter then set the project or global property "Hit Count" to "Counter". The default "Hit Count" is "milliseconds"

Tip: The hit count is automatically combined with any conditional expression (as described in earlier posts). Example, we use "break when hit count is a multiple of 250 and we set the HitCount in the project properties to milliseconds (is the default) then we will see a breakpoint or tracepoint 4 times per second (every 250 ms)

How to control the Arduino execution speed during a debug session

 

note: when using non-breaking tracepoints the stream of debug messages are processed on the pc in batches of up to 10 per second (also depends on the amount of data). The time displayed in the pc debug trace is the time each message is processed on the pc, not the time the message was sent from the micro-controller. For example, we might use a tracepoint at 4hz (every 250ms). In this case the debug data will be an accurate reflection of the micro_controller every 4hz however the millisecond values in the pc trace might not appear enitrely consitent. 

Use Visual Assist X to refractor Arduino source code

by Visual Micro 7. February 2012 12:00

Visual Assist X by "Whole Tomatoe Software" is, amonst other things, a very good refractoring and code highlite tool.
 
I would not normally suggest an addin for Visual Studio, let alone one you pay for, because they all slow things down. However the Visual Assist X (VAX) tool is so well used and well written that it is worth trying it out.
Below you will find a brief overview of the VAX tool along with instructions about how to configure arduino .pde and .ino files as c++ files in VAX

Develop new code faster with fewer errors

Read code faster than ever with fewer errors with enhanced syntax coloring. Write code at blinding speeds with Suggestions, Acronyms and Snippets. Identify and correct errors before compiling.

Quickly understand existing code

Enhanced IntelliSense and enhanced completion listboxes help to shed light on unfamiliar classes and members. Get detailed information on current symbols and quick shots of info by looking at small context and definition fields.

Refactor existing code making it easier to read and cheaper to maintain

Visual Assist X offers fast and easy refactoring across ALL languages in your solution with its suggested refactoring and code outline view. "I have to say that I like this feature the most. Highlite a chunk of code and have a method automatically created for you! A great way to re-structure code."

How to configure VAX to recognise .pde or .ino source files as c++ files

You have two options... 

If you have already setup visual studio color coding (as per Visual Micros Arduino guide) then you might only need to follow the instructions below. Otherwise follow the official whole tomatoe C/C++ setup guide. You need to configure for both .pde and .ino Arduino file extensions
Add ".pde;.ino;" to ExtSource in the following location
HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VANet8

Press Rebuild on the Performance tab of the Visual Assist X options dialog and restart your IDE

NOTE:-
Replace 8.0 with 10.0 if you use VS 2010.
Replace 8.0 with 9.0 if you use VS 2008.
Replace 8.0 with 7.1 if you use VS.NET 2003.
Replace 8.0 with 7.0 if you use VS.NET 2002.

Replace VANet8 with VANet10 for Visual Studio 2010.
Replace VANet8 with VSNet9 if you use VS2008.
Replace VANet8 with VSNet if you use VS.NET 2003.
Replace VANet8 with VANet7.0 if you use VS.NET 2002

Arduino Visual Studio User Interface Images

by Visual Micro 7. October 2011 15:25

The Visual Studio Tools menu will automatically enable and disable when an arduino board or xbee is connected. We can override arduino programmer settings from within visual studio

Arduino Visual Studio Tools Menu

The Visual Studio "Tools" menu example below is taken from a machine that did not have a connected serial port.

Various arduino command are added to visual studio in all relevent positions such as the Standard Tool Bar shown below

Arduino Visual Studio Create New Arduino Project Using the Visual Studio Standard Tool Bar

The Visual Studio Tools menu allows an arduino board to be selected for a visual studio project as does the boards list on the tool bar

Arduino intellisense in Visual Studio is fully available and automatically built from any arduino sketch

Arduino Visual Studio Intellisense for the Selected Arduino Board

Multiple sketch projects in a single solution are fully supported. F5 will compile and upload the Visual Studio "Start Up" project. Board and Serial port can be selected for each sketch project.

Arduino Visual Studio Multiple Sketch Projects in a Single Visual Studio Solution

Ultra fast intelligent visual studio arduino compiler

Arduino visual studio ultra fast arduino compiler

 

Unlimited serial viewers in Visual Studio auto pause and re-start during upload to an arduino board. All arduino and user conditional compiler directives are fully visible as you code

Unlimited serial viewers in Visual Studio auto pause and re-start during upload to an arduino board. All arduino and user conditional compiler directives are fully visible as you code

How to reset the arduino visual studio interface

by Visual Micro 1. October 2011 19:11

October 2015 - To uninstall the "Extension" version of Visual Micro, open the Ide and click "Tools>Extensions & Updates". Visual Micro can be uninstalled from the list then re-start the Ide.

The following applies to the older version of Visual Micro which is now obsolete ...

NOTE: In Visual Micro versions 1308.18+ click "Tools>Visual Micro>Reset User Interface" instead of following this guide 

The old way or for uninstall ...

After installation sometimes some Visual Micro menu commands do not appear or Visual Micro menu /buttons commands appear multiple times. In this case you should close Visual Studio and re-start after ensuring that all "devenv.exe" processes have been terminated using "Windows Task Manager".

If the problem persists you can force the addin to repeat the Visual Studio procedure.

This is done by performing a reset on the addin/plugin as described below. A "reset" removes all Visual Micro commands from Visual Studio so that after a clean start all the commands are setup in the correct way. If you have uninstalled the addin then after the re-start the commands will not re-appear.

Visual Studio (devenv.exe) provides a standard '/resetaddin' addin switch that can be used to easily reset or remove any addin. You will see in the example below that the /resetaddin switch required a key to identify the addin that is to be reset. The Visual Micro key is 'Visual.Micro.Visual.Studio.Arduino.Helper'

To reset the arduino addin, run visual studio (devenv.exe) with the same paramaters as your "Visual Studio" application short cut passing the following /resetaddin command.

[path to devenv.exe] /resetaddin Visual.Micro.Visual.Studio.Arduino.Helper

Atmel Studio [path to atmelstudio.exe] /resetaddin Visual.Micro.Visual.Studio.Arduino.Helper

If the above fails then please follow the guide below:-

Depending on your security settings you might need to run Visual Studio as Administrator to either install or reset the arduino addin

  • Close all IDE instances.
  • Open a Visual Studio .NET Command Prompt ("Run...", "Programs", "Visual Studio .NET", "Visual Studio .NET Tools", "Visual Studio .NET Command Prompt")
  • Enter "devenv.exe /resetaddin Visual.Micro.Visual.Studio.Arduino.Helper" (without the quotes) and press ENTER
  • Close all IDE instances.
  • NB: Microsoft have changed visual studio. The command  prompt might now be available in the microsoft power tools extension 

    If you have uninstalled the addin then a reset will clean the Visual Studio interface removing customisations the addin makes during setup. After uninstall only the two arduino toolbars will remain which can be manually removed from Visual Studio using each tool bars' the right click context menu.

    Using the arduino boards menu in visual studio

    by Visual Micro 11. April 2010 13: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)