Giving Robots Life with the .NET Micro Framework
description
Transcript of Giving Robots Life with the .NET Micro Framework
![Page 1: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/1.jpg)
Giving Robots Life with the .NET Micro Framework
004
Rob MilesUniversity of [email protected]/RobMilesrobmiles.com
![Page 2: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/2.jpg)
• 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
Agenda
![Page 3: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/3.jpg)
• 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
.NET for Multiple Device types
![Page 4: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/4.jpg)
• 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 .NET Micro Framework
![Page 5: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/5.jpg)
Windows
Tablet PC
Notebook PC
The Windows PC
![Page 6: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/6.jpg)
Windows
Tablet PC
Notebook PC
Point of Sale
Medical Devices
ATMS & Kiosks
Machine Control
Industrial Automatio
n
Thin Clients
Embedded Windows
![Page 7: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/7.jpg)
Windows
Tablet PC
Notebook PC
Point of Sale
Medical Devices
ATMS & Kiosks
Machine Control
Industrial Automatio
n
Thin ClientsWindows Mobile
Smartphone Windows MobilePocket PC Phone
Windows Automotive
Zune
VoIP Phones
MobileHandhelds
Set-top Boxes
Windows Embedded CE
![Page 8: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/8.jpg)
Windows
Tablet PC
Notebook PC
WearableDevices
AuxiliaryDisplays
Remote Controls
Sensor Networks
Point of Sale
Medical Devices
ATMS & Kiosks
Machine Control
Industrial Automatio
n
Thin ClientsWindows Mobile
Smartphone Windows MobilePocket PC Phone
Windows Automotive
Zune
VoIP Phones
MobileHandhelds
Set-top Boxes
.NET Micro Framework
![Page 9: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/9.jpg)
Platforms and HardwareWindows Vista Windows XP
EmbeddedWindows CE .NET Micro
FrameworkDevice Features
Connected,PC Class Performance, Accelerated Graphics
Connected,PC Class Performance
Connected, Graphical UI, Server, Browser, RAS DirectX
Connected, Small, Wearable, Graphical UI
Development Visual Studio + C#.NET Framework
Visual Studio + C#.NET Framework
Visual Studio + C#.NET Compact Framework
Visual Studio + C#.NET Micro Framework
Footprint X86 Dual Core, 64 Bit, Multi Processor
X86 X86, MIPS, SH4, ARM, with MMU, 12 MB,Managed Code
ARM 7, ARM 9, No MMU, 250-500KB, Managed Code
Power Mains Mains Low Power Very Low Power
![Page 10: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/10.jpg)
Platforms and HardwareWindows Vista Windows XP
EmbeddedWindows CE .NET Micro
FrameworkDevice Features
Connected,PC Class Performance, Accelerated Graphics
Connected,PC Class Performance
Connected, Graphical UI, Server, Browser, RAS DirectX
Connected, Small, Wearable, Graphical UI
Development Visual Studio + C#.NET Framework
Visual Studio + C#.NET Framework
Visual Studio + C#.NET Compact Framework
Visual Studio + C#.NET Micro Framework
Footprint X86 Dual Core, 64 Bit, Multi Processor
X86 X86, MIPS, SH4, ARM, with MMU, 12 MB,Managed Code
ARM 7, ARM 9, No MMU, 250-500KB, Managed Code
Power Mains Mains Low Power Very Low Power
![Page 11: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/11.jpg)
Platforms and HardwareWindows Vista Windows XP
EmbeddedWindows CE .NET Micro
FrameworkDevice Features
Connected,PC Class Performance, Accelerated Graphics
Connected,PC Class Performance
Connected, Graphical UI, Server, Browser, RAS DirectX
Connected, Small, Wearable, Graphical UI
Development Visual Studio + C#.NET Framework
Visual Studio + C#.NET Framework
Visual Studio + C#.NET Compact Framework
Visual Studio + C#.NET Micro Framework
Footprint X86 Dual Core, 64 Bit, Multi Processor
X86 X86, MIPS, SH4, ARM, with MMU, 12 MB,Managed Code
ARM 7, ARM 9, No MMU, 250-500KB, Managed Code
Power Mains Mains Low Power Very Low Power
![Page 12: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/12.jpg)
.NET Framework on Windows
Services•Description•Discovery•Protocols
UI Controls•HTML•Web
Runtime•Interop•Remoting•Serialization
Design
ConfigurationCache
Session stateSecurity
ImagingDrawing 2D
TextPrinting
DesignADO.NET
SQL ServerCESQL Client
Xslt/XPathXML Document
Reader/writersSerialization
Service processConfiguration
ThreadingDiagnostics
NetIO
ResourcesReflection
SecurityCollections
GlobalizationText
Component model
System.Drawing
System.Windows.FormsSystem.Web
System.Data System.XML
System
![Page 13: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/13.jpg)
.NET Compact Framework
Services•Description•Discovery•Protocols
UI Controls• HTML• Web
Runtime• Interop• Remoting• Serialization
Design
ConfigurationCache
Session stateSecurity
ImagingDrawing 2D
TextPrinting
DesignADO.NET
SQL ServerCESQL Client
Xslt/XPathXML Document
Reader/writersSerialization
Service processConfiguration
ThreadingDiagnostics
NetIO
ResourcesReflection
SecurityCollections
GlobalizationText
Component model
System.Drawing
System.Windows.FormsSystem.Web
System.Data System.XML
System
![Page 14: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/14.jpg)
.NET Micro Framework Services• Description• Discovery• Protocols
UI Controls• HTML• Web
Design
ConfigurationCache
Session stateSecurity
ImagingDrawing 2D
TextPrinting
DesignADO.NET
SQL ServerCESQL Client
Xslt/XPathXML Document
Reader/writersSerialization
Service processConfiguration
ThreadingDiagnostics
NetIO
ResourcesReflection
SecurityCollections
GlobalizationText
Component model
System.Drawing
System.Windows.FormsSystem.Web
System.Data System.XML
System
InteropRuntime
SerializationRemoting
![Page 15: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/15.jpg)
• 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
The Missing Operating System
![Page 16: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/16.jpg)
• 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
How it works
![Page 17: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/17.jpg)
• 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
The .NET Framework Scope
![Page 18: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/18.jpg)
• 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
Hardware Platforms
![Page 19: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/19.jpg)
• TinyClr Fez Mini• It is pin compatible
with the Basic Stamp board
• It costs less than $50www.tinyclr.com
Tiny Micro Framework Platform
![Page 20: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/20.jpg)
• Device Solutions Tahoe II • Touch screen• SD card slot• Network connection
www.devicesolutions.net/
Larger Micro Framework Platform
![Page 21: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/21.jpg)
• ChipworkX Development System
• Touch screen• SD card slot• Network connection • USB hosting• MP3 playback www.ghilectronics.com
Fully Loaded Micro Framework Platform
![Page 22: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/22.jpg)
• 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
Pretend Micro Framework Platform
![Page 23: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/23.jpg)
• 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
Making a Product
![Page 24: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/24.jpg)
• 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
Platform Abilities
![Page 25: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/25.jpg)
• 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
What can the Micro Framework Do?
![Page 26: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/26.jpg)
• 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
How do I write programs?
![Page 27: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/27.jpg)
DemoSensor Interfacting
![Page 28: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/28.jpg)
• 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
The FEZ Micro Lab Board
![Page 29: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/29.jpg)
• 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
A Micro Framework Robot
Fez MiniRobot
![Page 30: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/30.jpg)
DemoMaking a Cowardly Robot
![Page 31: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/31.jpg)
• 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
Robot SensorsFEZ_Pin.AnalogIn DistancePin = FEZ_Pin.AnalogIn.An1;FEZ_Components.DistanceDetector distanceDetector;
distanceDetector = new FEZ_Components.DistanceDetector(DistancePin, FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);
![Page 32: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/32.jpg)
• The program repeatedly looks for objects• When it finds one it moves backwards
Cowardly Codewhile (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);}
![Page 33: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/33.jpg)
• Devices are all implemented via objects, just like “ordinary” C# programs
Driving Devicesif (distance > 10) greenLed.TurnOn();else greenLed.ShutOff();
if (distance < 10) redLed.TurnOn();else redLed.ShutOff();
![Page 34: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/34.jpg)
DemoMaking a Cowardly Robot With Lights
![Page 35: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/35.jpg)
• Components can also generate events which are handled using delegates
Hardware EventskillSwitch.ButtonPressEvent += new FEZ_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(); }}
![Page 36: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/36.jpg)
• 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
Threading
![Page 37: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/37.jpg)
DemoControlling a Robot with Windows Phone
![Page 38: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/38.jpg)
• This the architecture for our Windows Phone controlled Micro Framework robot
System Architecture
WindowsPhone
Robot ControlWeb Server
Fez MiniRobot
http Xbee
![Page 39: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/39.jpg)
• The phone talks http to the robot web server
.NET Micro Framework Hosting
WindowsPhone
Robot ControlWeb Server
Fez MiniRobot
http Xbee
![Page 40: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/40.jpg)
• 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 Web Support
![Page 41: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/41.jpg)
• The graphics display is based on WPF
• You use the StackPanel class to automatically layout content
Micro Framework Display Library
![Page 42: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/42.jpg)
• The Robot Controller uses a serial port to talk to a wireless modem and send commands to the robot
.NET Micro Framework Interface
WindowsPhone
Robot ControlWeb Server
Fez MiniRobot
http Xbee
![Page 43: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/43.jpg)
• 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
Serial Data Support
![Page 44: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/44.jpg)
• The robot receives commands and acts on them• It could also return sensor data to the server
.NET Micro Framework Control
WindowsPhone
Robot ControlWeb Server
Fez MiniRobot
http Xbee
![Page 45: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/45.jpg)
• 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
A Distributed Sensor Network
![Page 46: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/46.jpg)
• .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
Changing the Business Rules
![Page 47: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/47.jpg)
• 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
.NET Micro Framework 4.0 Devices
![Page 48: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/48.jpg)
• 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
Getting Started
![Page 49: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/49.jpg)
• .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 Framework
Donald Thompson & Rob Miles, Microsoft Press 2007Expert .NET Micro Framework,
Jens Kühner, Apress 2009
Resources
![Page 50: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/50.jpg)
Q & A
![Page 51: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/51.jpg)
A sua opinião é importante!Complete o questionário de avaliação e devolva-o à saida.
![Page 52: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/52.jpg)
![Page 53: Giving Robots Life with the .NET Micro Framework](https://reader031.fdocuments.in/reader031/viewer/2022020210/56816968550346895de12e16/html5/thumbnails/53.jpg)