Giving robots life with the net micro framework
This presentation is the property of its rightful owner.
Sponsored Links
1 / 53

Giving Robots Life with the .NET Micro Framework PowerPoint PPT Presentation


  • 127 Views
  • Uploaded on
  • Presentation posted in: General

004. Rob Miles. University of Hull [email protected] twitter.com/RobMiles robmiles.com. Giving Robots Life with the .NET Micro Framework. Agenda. What is the .NET Micro Framework? What can I do with it ? How do I connect Sensors and Interfaces?

Download Presentation

Giving Robots Life with the .NET Micro Framework

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Giving robots life with the net micro framework

004

Rob Miles

University of Hull

[email protected]

twitter.com/RobMiles

robmiles.com

Giving Robots Life with the .NET Micro Framework


Agenda

Agenda

  • What is the .NET Micro Framework?

  • What can I do with it?

  • How do I connect Sensors and Interfaces?

  • How can I control a robot with the .NET Micro Framework?

  • Grand Finale


Net for multiple device types

.NET for Multiple Device types

  • You might think of C#, Visual Studio and .NET as tools that you use to create PC applications

    • Compile and run your programs and run them on your desktop or laptop

  • However, there is more to .NET than this

    • You are probably aware that you can write .NET applications for your Windows Mobile device

  • But now you can also target all kinds of devices


The net micro framework

The .NET Micro Framework

  • A version of .NET for tiny devices

    • Runs a .NET program held in the device itself

  • Designed for embedded applications

    • Lets you create embedded code in C#

  • The cheapest platforms are now very affordable


The windows pc

The Windows PC

Tablet PC

Notebook PC

Windows


Embedded windows

Embedded Windows

Thin Clients

ATMS & Kiosks

Tablet PC

Industrial Automation

Point of Sale

Notebook PC

Machine Control

Medical Devices

Windows


Windows embedded ce

Windows Embedded CE

Thin Clients

Windows Mobile

Smartphone

ATMS & Kiosks

Windows Mobile

Pocket PC Phone

Tablet PC

Industrial Automation

Point of Sale

Windows Automotive

Zune

Mobile

Handhelds

Notebook PC

VoIP Phones

Machine Control

Medical Devices

Set-top Boxes

Windows


Net micro framework

.NET Micro Framework

Sensor Networks

Thin Clients

Windows Mobile

Smartphone

ATMS & Kiosks

Windows Mobile

Pocket PC Phone

Tablet PC

AuxiliaryDisplays

Industrial Automation

Point of Sale

Windows Automotive

Zune

Remote Controls

Mobile

Handhelds

Notebook PC

VoIP Phones

Machine Control

Medical Devices

WearableDevices

Set-top Boxes

Windows


Platforms and hardware

Platforms and Hardware


Platforms and hardware1

Platforms and Hardware


Platforms and hardware2

Platforms and Hardware


Net framework on windows

.NET Framework on Windows

System.Web

System.Windows.Forms

  • UI Controls

    • HTML

    • Web

  • Services

    • Description

    • Discovery

    • Protocols

Design

Component model

System.Drawing

Drawing 2D

Printing

Cache

Security

Imaging

Text

Configuration

Session state

System.Data

System.XML

XML Document

Serialization

ADO.NET

SQL Client

Xslt/XPath

Reader/writers

Design

SQL ServerCE

System

Collections

IO

Configuration

  • Runtime

    • Interop

    • Remoting

    • Serialization

Security

Net

Service process

Text

Reflection

Diagnostics

Globalization

Resources

Threading


Net compact framework

.NET Compact Framework

System.Web

System.Windows.Forms

  • UI Controls

    • HTML

    • Web

  • Services

    • Description

    • Discovery

    • Protocols

Design

Component model

System.Drawing

Drawing 2D

Printing

Cache

Security

Imaging

Text

Configuration

Session state

System.Data

System.XML

XML Document

Serialization

ADO.NET

SQL Client

Xslt/XPath

Reader/writers

Design

SQL ServerCE

System

Collections

IO

Configuration

  • Runtime

    • Interop

    • Remoting

    • Serialization

Security

Net

Service process

Text

Reflection

Diagnostics

Globalization

Resources

Threading


Net micro framework1

.NET Micro Framework

System.Web

System.Windows.Forms

  • UI Controls

    • HTML

    • Web

  • Services

    • Description

    • Discovery

    • Protocols

Design

Component model

System.Drawing

Drawing 2D

Printing

Cache

Security

Imaging

Text

Configuration

Session state

System.Data

System.XML

XML Document

Serialization

ADO.NET

SQL Client

Xslt/XPath

Reader/writers

Design

SQL ServerCE

System

Collections

IO

Configuration

Runtime

Security

Net

Service process

Interop

Text

Reflection

Diagnostics

Remoting

Globalization

Resources

Threading

Serialization


The missing operating system

The Missing Operating System

  • A device powered by the .NET Micro Framework does not have/need an operating system

  • Programs execute directly on the hardware using a "Bootable Run Time System"

    • Simplifies deployment

    • Reduces the demands on the target platform

  • Programs still have access to many parts of the .NET API

    • Provided by the run-time system rather than an operating system


How it works

How it works

  • C# source is compiled to Intermediate Language (MSIL)

  • The MSIL is downloaded in a compressed form and interpreted in the Micro Framework device

  • As far as the code is concerned it is running inside a standard .NET Assembly

  • The program runs as soon as the device is powered up


The net framework scope

The .NET Framework Scope

  • Not all .NET devices support all the components of the full .NET Framework

    • This is quite sensible given the limitations of the platforms and the needs of the solutions

  • However, all the fundamentals of .NET are present on all of the platforms

    • And they are used in exactly the same way in your applications

    • And there are special purpose libraries


Hardware platforms

Hardware Platforms

  • There are many different hardware platforms available

  • Some are designed as processor boards that can be incorporated into your own hardware

  • Some also have custom libraries for additional hardware abilities


Tiny micro framework platform

Tiny Micro Framework Platform

  • TinyClr Fez Mini

  • It is pin compatible with the Basic Stamp board

  • It costs less than $50

    www.tinyclr.com


Larger micro framework platform

Larger Micro Framework Platform

  • Device Solutions Tahoe II

  • Touch screen

  • SD card slot

  • Network connection www.devicesolutions.net/


Fully loaded micro framework platform

Fully Loaded Micro Framework Platform

  • ChipworkX Development System

  • Touch screen

  • SD card slot

  • Network connection

  • USB hosting

  • MP3 playback

    www.ghilectronics.com


Pretend micro framework platform

Pretend Micro Framework Platform

  • You also get a highly flexible emulator

  • You can configure this to match any hardware platform

  • You can also create emulations of hardware devices connected to the platform


Making a product

Making a Product

  • The development boards look rather expensive

  • You would not base a product on these

  • Instead you use them to create a prototype and then just use the processor component in a custom board


Platform abilities

Platform Abilities

  • Object based implementation of hardware

    • Single pins, I2C, Spi, serial, USB (host and client)

  • Powerful graphics library with touch and gestures

  • Fully networkable, provides DPWS, web server and web client support

  • Can be used as the processing component in a custom made hardware solution


What can the micro framework do

What can the Micro Framework Do?

  • Anything from simple embedded controllers to connected data terminals

  • If you have an idea for a clever embedded device you now have the perfect platform

  • You don’t have to learn another programming language or toolchain


How do i write programs

How do I write programs?

  • Write programs in C# using Visual Studio 2008

  • Full debugging support, even inside the device

  • Run your program on the real device or the emulator


Giving robots life with the net micro framework

Sensor Interfacting


The fez micro lab board

The FEZ Micro Lab Board

  • The lab board lets you connect sensors to the processor

  • Each port can be configured in software and its behaviours are exposed via C# objects


A micro framework robot

A Micro Framework Robot

  • The Fez Mini Robot kit puts the Micro Framework device in control of a robot

  • The controller board has hard wired connections to the motor

  • You can connect other devices as required

Fez Mini

Robot


Giving robots life with the net micro framework

Making a Cowardly Robot


Robot sensors

Robot Sensors

FEZ_Pin.AnalogInDistancePin = FEZ_Pin.AnalogIn.An1;

FEZ_Components.DistanceDetectordistanceDetector;

distanceDetector= new FEZ_Components.DistanceDetector(DistancePin,FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);

  • The sensors are implemented as objects which expose properties and methods

  • When an sensor instance is created it is bound to a particular input pin


Cowardly code

Cowardly Code

while (true)

{

float distance = distanceDetector.GetDistance_cm();

Debug.Print(distance.ToString());

if (distance < 4)

{

FEZMini_Robot.MoveRamp(-100, -100, 1);

System.Threading.Thread.Sleep(300);

FEZMini_Robot.Move(0, 0);

}

System.Threading.Thread.Sleep(200);

}

  • The program repeatedly looks for objects

  • When it finds one it moves backwards


Driving devices

Driving Devices

if (distance > 10)

greenLed.TurnOn();

else

greenLed.ShutOff();

if (distance < 10)

redLed.TurnOn();

else

redLed.ShutOff();

  • Devices are all implemented via objects, just like “ordinary” C# programs


Giving robots life with the net micro framework

Making a Cowardly Robot With Lights


Hardware events

Hardware Events

killSwitch.ButtonPressEvent +=

newFEZ_Components.Button.ButtonPressEventHandler(killSwitch_ButtonPressEvent);

...

static void killSwitch_ButtonPressEvent( FEZ_Pin.Interrupt pin,

FEZ_Components.Button.ButtonState state)

{

if (state == FEZ_Components.Button.ButtonState.Pressed)

{

shutDown();

}

}

  • Components can also generate events which are handled using delegates


Threading

Threading

  • It would be useful for the robot to be able to send diagnostic information back to the host

  • We can use a thread to do this, as the Micro Framework has full thread support

  • This includes support for synchronisation


Giving robots life with the net micro framework

Controlling a Robot with Windows Phone


System architecture

System Architecture

  • This the architecture for our Windows Phone controlled Micro Framework robot

http

Xbee

WindowsPhone

Robot Control

Web Server

Fez Mini

Robot


Net micro framework hosting

.NET Micro Framework Hosting

  • The phone talks http to the robot web server

http

Xbee

WindowsPhone

Robot Control

Web Server

Fez Mini

Robot


Micro framework web support

Micro Framework Web Support

  • Micro Framework devices can host websites and also implement Web Services

  • This includes support for secure sockets

  • You already know how to do this, since it is based on the .NET Libraries


Micro framework display library

Micro Framework Display Library

  • The graphics display is based on WPF

  • You use the StackPanel class to automatically layout content


Net micro framework interface

.NET Micro Framework Interface

  • The Robot Controller uses a serial port to talk to a wireless modem and send commands to the robot

http

Xbee

WindowsPhone

Robot Control

Web Server

Fez Mini

Robot


Serial data support

Serial Data Support

  • You can create and manage serial data connections exactly as for the desktop versions of .NET

  • You can bind events to data arrival

  • You can also create emulated serial devices for your test harnesses


Net micro framework control

.NET Micro Framework Control

  • The robot receives commands and acts on them

  • It could also return sensor data to the server

http

Xbee

WindowsPhone

Robot Control

Web Server

Fez Mini

Robot


A distributed sensor network

A Distributed Sensor Network

  • This shows how we can use Micro Framework devices at a variety of levels in an installation:

    • Small, headless embedded devices

    • Rich user interface for controllers

    • Connected using standard protocols


Changing the business rules

Changing the Business Rules

  • .NET Developers can now target embedded systems

  • Where it was previously too expensive to think about an embedded solution, you can now begin to build one

  • The tools are inexpensive

  • You don’t need special skills


Net micro framework 4 0 devices

.NET Micro Framework 4.0 Devices

  • The .NET Framework is now shared source

  • You can get obtain a porting kit and put the framework onto any hardware platform you like – for free

  • This has huge potential for new platforms


Getting started

Getting Started

  • You can get started for free

  • Download Visual Studio 2008 Express

    • You can use other versions of Visual Studio if you wish

  • Download the Micro Framework

    • Then you can create projects and the emulator


Resources

Resources

  • .NET Micro Framework site: http://www.microsoft.com/netmf

  • .NET Micro Framework Team Blog: http://blogs.msdn.com/netmfteam/

  • Blog with all kinds of stuff: http://www.robmiles.com

  • Books: Embedded Programming with the Microsoft® .NET Micro FrameworkDonald Thompson & Rob Miles, Microsoft Press 2007Expert .NET Micro Framework, Jens Kühner, Apress 2009


  • Login