Monthly Archives: March 2015

.NET Micro Framework and Visual Studio 2013

With a lot of people talking about the Internet of Things, there is renewed interest in the .NET Micro Framework (NETMF). The current version, SDK v4.3 (QFE2- RTM), can amongst others be used in combination with Visual Studio 2013 to develop applications for very small target systems.

Last week I got a FEZ Spider Board with a lot of peripherals to create a number of (hopefully) cool demos. The first step is to install all necessary software on the development system and to make sure that a working USB connection is set up between the development machine and the target system. Installing software on the development system is easy and straight forward. The only thing to keep in mind is that you need to remove any previous NETMF installations before installing the latest version. This is also true for .NET Gadgeteer installations and optional GHI SDKs. The next step is installing the different NETMF packages that are necessary to develop NETMF applications with Visual Studio 2013.

The following software needs to be installed in this order:

After installing all software, you can start developing your first project, which in my case is the Hello World for IoT: A blinking LED. When you develop a Gadgeteer project, you can make use of a designer to connect different hardware peripherals to the motherboard (and automatically create an object to be able to use the peripheral in your application). For the initial test, my hardware looks very simple, just the FEZ Spider Board and a USB module to power the motherboard and connect to the development machine.

HW

Once all components are connected to the motherboard, it is time to connect the USB cable to the development machine. After installing necessary drivers on the development machine, it is now possible to select the FEZ Spider Board as target device inside Visual Studio. After doing that, your application will be deployed automatically to the target device when you start debugging. You will also have a full debugging experience when you deploy your application in this way to the target. However, this will only work if you have the right version of the boot loader and the FEZ ConfigTinyCLR present on the device. If you have an older version of the firmware on the device, Visual Studio cannot deploy your application and gives an error message instead. In my situation I had the right loader, but an older version of the TinyCLR. To update to the latest version of the TinyCLR, you can use the application FEZ Config, which is installed together with the Vendor SDK you installed previously. FEZ Config can be found under C:\Program Files (x86)\GHI Electronics\GHI FEZ Config for a default installation.

The application I developed is extremely simple, it just uses a timer to toggle the onboard LED for 10 times.

using System;

using System.Collections;

using System.Threading;

using Microsoft.SPOT;

using Microsoft.SPOT.Presentation;

using Microsoft.SPOT.Presentation.Controls;

using Microsoft.SPOT.Presentation.Media;

using Microsoft.SPOT.Presentation.Shapes;

using Microsoft.SPOT.Touch;


using Gadgeteer.Networking;

using GT = Gadgeteer;

using GTM = Gadgeteer.Modules;

using Gadgeteer.Modules.GHIElectronics;


namespace GadgeteerApp1

{

    public partial class Program

    {

        Timer t;

        int maxNrTicks;


        // This method is run when the mainboard is powered up or reset.   

        void ProgramStarted()

        {

            Debug.Print("Program Started");


            var t = new GT.Timer(1000);

            t.Tick += OnTick;

            t.Start();

        }


        public void OnTick(GT.Timer timer)

        {

            this.PulseDebugLED();

            maxNrTicks++;


            if (maxNrTicks > 10)

            {

                timer.Stop();

                timer = null;

            }

        }

    }

}

Using Visual Studio 2013, it is very easy to develop a simple NETMF application targeting the FEZ Spider board. Having said that, depending on the peripherals you are using and depending on the desired functionality, you can create complex projects that participate in an IoT type of solution. In the upcoming time I will post more articles about application development with the .NET Micro Framework.

Advertisements