Search This Blog

2009-10-22

Introduction to Microsoft .NET Micro Framework (NETMF)

Introduction: The Microsoft .NET Micro Framework is a small and efficient .NET runtime environment used to run managed code on devices that are too small and resource constrained.

Scope :
Here is a scenario, you want to make a pocket-GPS-data-logger that saves position,acceleration, and temperature on a memory card. you also want to display some info on a small display. GPS devices send position data over serial port so you can easily write some code on the PC to handle that. But, a PC wouldn't fit in my pocket! Another problem is how would you measure temperature and acceleration on a PC? If you make this project using classic microcontrollers, like AVR or PICmicro, all this can be done but then you need a compiler for the micro you choose (probably not free), a week to learn the processor, a week to write serial driver, a month or more to figure out the FAT file system on memory cards...etc.Basically, it can be done in few weeks of work. If you have done this in the past, how was your experience with the IDE used for programming? Mine were all horrible, full of bugs and
debugging was near impossible!

Advantages of Micro Framework:
1).A memory footprint of about 300 KB; for comparison, the next smallest .NET implementation, the .NET Compact Framework running on Windows CE, needs about 12 MB Memory.
2).Supports common embedded peripherals and interconnects, including flash memory, EEPROM, GPIO, I2C, SPI, USB.
3).It runs on Microsoft's Visual C# express. Best IDE you will ever work with and it is FREE.
4).NET Micro Framework is open-source and free, in case you want to port it to your own hardware.
5)Many OEM devices are already available with .NET Micro Framework pre-installed.
6)Your code will run on all devices with almost on changes.
7)Full debugging capabilities. Breakpoints, stepping in code, variables...etc.
8)Has been tested in many commercial products so quality is assured.
9)Includes many bus drivers so using SPI, UART or I2C will require very little knowledge.
10)You almost never need to look at manuals or datasheets because of the standard framework.

System Setup:
Before we try anything, we want to make sure the PC is setup with needed software.
1.First download and install Visual C# express 2008 with SP1.(http://www.microsoft.com/express/vcsharp/)
2.Now, download and install .NET Micro Framework 3.0 SDK (not the porting kit).
http://www.microsoft.com/downloads/details.aspx?FamilyID=9356ed6f-f1f0-43ef-b21a-4644dd089b4a&displaylang=en

Devices that support MF:
Micro Framework is running on GHI Products. Microsoft has released the beta of .NET Micro Framework 4.0 and it is already ported to GHI Electronics .NET Product. Here is a quick review of Some Products:

A.ChipworkX Module/DevSys : If processing power and customization is needed then this is the right choice.ChipworkX runs a 200Mhz ARM processor with 64MB 32-bit SDRAM and 8MB for user
applications. It also contains a 256MB internal flash for file system storage. It includes all NETMF major features and adds all GHI exclusive features like WiFi and USB host support.
ChipworkX also adds SQLite database support and allows users to load their own native code
(C/assembly) on the device using RLP (Runtime Loadable Procedures). RLP allows for advance processor intensive and real-time applications.



B.Embedded Master Module/DevSys:
This small module includes all NETMF major features and adds many GHI exclusive features. On the software side: Filesystem, TCP/IP, SSL, Graphics, debugging and more NETMF features are included. GHI also adds: WiFi, PPP,USB host, USB device builder, CAN, Analog in/out, PWM and more. As for the hardware: It is 72Mhz ARM processor with 8MB SDRAM and 4.5MB FLASH. The processor on
Embedded Master contains Ethernet MAC built right in with DMA transfers, which gives it a large boost when compared with classical SPI-based Ethernet chipset used by other module makers.

C.USBizi Chipset: USBizi is the smallest and only single chip running NETMF in the world. The software running on it is a scaled down version of Embedded Master. It includes all features except networking (TCP/IP and PPP) and native graphics. Even though these features are missing, USBizi can be connected to a network using TCP/IP chipsets like WIZnet and can run simple displays. There are example projects already provided showing how USBizi can be networked and can display graphics.

D.FEZ Board: FEZ and FEZmini are very small boards targeted for beginners. They are based on USBizi chipset and so they have all USBizi features. Those little boards offer a lot of peripherals not available with any hobby-targeted board. Even tough it is targeted for beginner, it is a low-cost starting point for any professional wanting to test out NETMF.FEZ stands for “Freakin' Easy!”
Features available in FEZ but not available in Arduino, BASIC STAMP and others:
1. Base on Microsoft .NET Micro Framework.
2. Support runtime debugging (breakpoint, variable inspection, stepping...etc.)
3. Uses free VS2008 C# express edition for development.
4. High-end features like FAT, USB device and USB host
5. Hardware independent. Easily upgrade to more fancy hardware like ChipworkX.
6. Open source hardware design files.
7. Already available shields and holder boards.
8. Base on USBizi chip. Use the chipset to create new designs.

Create a Project:
Open Visual C# express and, from the menu, select file -> New Project. The wizard now
should have “Micro Framework” option in the left menu. Click on it, and from the templates,
select “Console Application”.



In Program.cs

using System;
using Microsoft.SPOT;

namespace MFConsoleApplication1
{
public class Program
{
public static void Main()
{
Debug.Print("Hello Avijit Da");
}

}
}
Press F5 to run and you will get following output:


To test the Project output ,we need devices like USBizi Chipset, FEZ and FEZmini Board, ChipworkX Module/DevSys or Embedded Master Module/DevSys. And these should be connected via USB,TCP/IP or Serial Port with PC.
And set the target devices from the project properties.


Deployment:
Before we use the hardware, let us make sure it is properly connected. The SDK comes with a software from Microsoft called MFDeploy(C:\Program Files\Microsoft .NET Micro Framework\v3.0\Tools\ MFDeploy.exe). This is good to make sure the device connected properly and transport with it has no issues.

If you get reply after pinging ,then start the deployment from Target->Application Deployment->Create Application Deployment.


Limitations:The platform does not support symmetric multiprocessing, multi-dimensional arrays, machine-dependent types, or unsafe instructions. The CLR is an interpreter rather than a just-in-time compiler, and uses a simpler mark-and-sweep garbage collector rather than a generational approach. Interoperation between managed and native code currently has a number of limitations. The .NET Micro Framework does not support any .NET languages other than C# at this time.

References:
http://www.microframeworkprojects.com/
http://www.ghielectronics.com/downloads/Beginners%20guide%20to%20C%23%20and%20.NET%20Micro%20Framework.pdf
http://www.microsoft.com/netmf/about/default.mspx

1 comment:

Kurtnelle said...

Good stuff. That Fez really is Freaking Easy. My mind is expanding!