PROGRAMMING MICROCONTROLLERS WITH .NET AND C#

For some time now I have watched the market for microcontrollers that have .NET runs, more precisely .NET micro framework or NETMF short. To program these boards exclusively in C #. Now I have added to it and get me a FEZ Domino board. It costs € 75.-, but also has a quite generous feature set with USB host and microSD card. Let's see if this is good for a robot.
FEZ Domino


Ok, what is one of them holding a Microsoft operating system on a relatively underpowered microcontroller. Can it work?

Hardware

Features

First of all the technical data:
  • Microsoft's .NET Micro Framework 4.1
  • NXP LPC2388 ARM7 Processor 72Mhz
  • Arduino pin compatible
  • Arduino shield compatible
  • Debugging and programming via USB with Visual Studio 2010 (VS2010 with Express)
  • 21 digital IOs, 6 analog inputs
  • 3xUART, 1xI2C, 2xSPI, 1xCAN
  • 3.3V IO, 5V tolerant
The processor comes from NXP. It is an LPC2388 ARM7 core.512kB 96kB FLASH and RAM. It is already the .NETMF ofelectronic GHI . With .NETMF the chip is then called USBizi and can also be purchased as of GHI and tinyCLR for your own designs. The you can program microcontrollers with .NET and C#

Arduino compatible

The keyword Arduino compatible needs further explanation. The FEZ Domino board is identical to the dimensions and the pinout for Arduino. Most Arduino Shields even run, provided that the appropriate drivers. The special features of the Arduino PWM and IOs such as SPI, UART, and are almost identical on all pins. The analog inputs are 6 available. Lediglcih the I2C interface is connected to the digital pins 2 and 3 (analog 4 and 5 at the Arduino). Although the ARM7 processor running at 3.3V 5V tolerant pins are the DIgital. But when they deliver only 3.3V output level. The permissible output current is only 4mA (20mA at Arduino).

USB interface

The USB host interface is brought out to a standard USB A male connector and supports standard devices such as keyboard, mouse, mass storage. Also USB devices with virtual serial port (such as the Arduino) can be addressed Furthermore readily.
Wi-Fi dongle and Bluwetooth be allerdimgs not supported.
The USB host port operates independently from the USB client interface that is brought out to a microUSB connector. This interface is used to transmit the ausschlieslich programs and debug. However, can be used as a normal USB HID interface via the mode Jumper The debug interface. Then you have to be debugged on the first serial port.

Micro SD Card

The microSD card interface is addressed in the "real" SD Card mode, ie 4 data bits and niocht as usual in 1-bit SPI mnode. This results in very hohge data rates can be achieved both in writing as in reading. As a SD card format is expected to FAT32. It supports all popular SD cards including SDHC and any size.

Network

Although on the LPC2388 an Ethernet interface is integrated, this is not supported. With the current beta GHI SDK but Ethernet modules are supported with the WIZnet W5100 chipset. This include the SparkFun Arduino Ethernet Shield . In this case, a complete TCP / IP stack is implemented, UDP is supported.

I2C, SPI, UART, CAN, PWM

The usual standard interfaces are naturally present on the FEZ Domino. There is an I2C interface to the digital pins 2 and 3. There are also 2 SPI interfaces and 3 UART interfaces. COM1 is on the digital pins 0 and 1 as the Arduino. Likewise SPI1 on the digital pins 11,12,13 (like the Arduino). COM2 and SPI2 lie on an additional 10-pin connector. A CAN bus interface is located on the pin 7 and 4. Digital COM4 than 3. UART interface can be in addition activated, but at the expense of 2 A / D converters (At 2 and 3). The Digital PWM pins 5,6,8,9,10 have an additional feature (pin 3 and pin 11 as the Arduino, however, not). On all pins but can be generated by using timer output compare PWM additional functionality.

Software

The software installs quickly and seamlessly integrates into Visual Studio 2010, including smart completion and debugger. You click on Run and the program is transferred to the hardware via USB and can be executed there or debugged. Very comfortable. To create custom projects are templates. There, you simply select only the destination device receives an executable program from scaffolding.

What is needed

  • Visual Studio 2010 C # Express
  • .NET Micro framework 4.1 SDK
  • GHI SDK 4.1
  • TeraTerm - To update the firmware
On the tinyCLR page you can click through the components and finds drivers to the most common sensors, actuators, and Shields.Plus, there's a wiki with user projects with source codes to download.

Multithreading

A great feature of .NETMF is multithreaded. Although not a real time operating system .NETMF can shew Mehere threads and run almost parallel.

Hello world in .NETMF

Here is a simple program did shows a blinking LED in .NETMF.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System ;
using System . Threading ;
using Microsoft . SPOT ;
using Microsoft . SPOT . Hardware ;
using GHIElectronics . NETMF . FEZ ;
namespace FEZ_Domino_Application1
{
  public class Program
  {
    public static void Main ( )
    {
      // Blink board LED
      bool ledState = false ;
      OutputPort led = new OutputPort ( ( Cpu . Pin ) FEZ_Pin . Digital . LED , ledState ) ;
      while ( true )
      {
        // Sleep for 500 milliseconds
        Thread . Sleep ( 500 ) ;
        // toggle LED state
        ledState = ! ledState ;
        led . Write ( ledState ) ;
      }
    }
  }
}

Disadvantages

Despite all the advantages the NETMF and offer the FEZ Domino board, also a few disadvantages should be mentioned:
  • Use of many parallel pins. An LCD module in 4-bit mode to connect is already extremely complex. Since all the pins will individually considered as separate objects, there are no groups (arrays, nibbles or bytes) of pins
  • Only 3.3V output. Can cause problems especially in FET, which still operate at 5V but not at 3.3 V
  • Only 4 mA output current. LEDs should require 20mA always connect via transistors, or use LowCurrent LEDs.
  • No micro delay. Exact timing delays the need in the us range, are hardly feasible
  • Pin Toggle times. Toggling pins by software takes several microseconds. In addition cyclically (all 18,2ms) nor the Garbadge Collection to which can lead to delays of a few ms.

Alternatives

Beside the FEZ Domino, there are some other boards in the Arduino form factor, including:
  • FEZ Panda. Much cheaper than the FEZ Domino, but with 69 IOs but without USB host and optional microSD Card for $ 35.
  • FEZ Mini board. Compatible on the occupancy Parallax BS2 or Arduino Mini pin.
  • The manufacturer Secret Labs there is the series with the Netduino Netduino and the
  • Netduino + with Ethernet and microSD card. Priced certainly very interesting, more experience, I have not done so, because the boards are hardly available in Europe.
Also worth mentioning is the EPZ Open .NETMF project as open source project. Sounds interesting but still in beta. Let's see what happens. Currently running on the FEZ Panda and the FEZ Hacker platform.

Conclusion

Once grabbed the .NET fever. It is also great fun to program it. It is hard to be back to work with the Arduino, if one has dared only once in the .NET world. But there are bound to be, for the Arduino is the better choice and remains applications.
Via robotfreak.de
Note: If you get any problem with this, feel free to comment below :)

Comments

Popular posts from this blog

N-Channel MOSFET High-Side Drive: When, Why and How?

Using the high-low side driver IR2110 - explanation and plenty of example circuits

Using the SG3525 PWM Controller - Explanation and Example: Circuit Diagram / Schematic of Push-Pull Converter