1 / 0

Giving Robots Life with the .NET Micro Framework

004. Rob Miles. University of Hull rob@robmiles.com 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?

nicola
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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 004 Rob Miles University of Hull rob@robmiles.com twitter.com/RobMiles robmiles.com

    Giving Robots Life with the .NET Micro Framework

  2. 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
  3. .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
  4. 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
  5. The Windows PC Tablet PC Notebook PC Windows
  6. Embedded Windows Thin Clients ATMS & Kiosks Tablet PC Industrial Automation Point of Sale Notebook PC Machine Control Medical Devices Windows
  7. 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
  8. .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
  9. Platforms and Hardware
  10. Platforms and Hardware
  11. Platforms and Hardware
  12. .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
  13. .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
  14. .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
  15. 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
  16. 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
  17. 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
  18. 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
  19. Tiny Micro Framework Platform TinyClr Fez Mini It is pin compatible with the Basic Stamp board It costs less than $50 www.tinyclr.com
  20. Larger Micro Framework Platform Device Solutions Tahoe II Touch screen SD card slot Network connection www.devicesolutions.net/
  21. Fully Loaded Micro Framework Platform ChipworkX Development System Touch screen SD card slot Network connection USB hosting MP3 playback www.ghilectronics.com
  22. 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
  23. 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
  24. 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
  25. 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
  26. 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
  27. Sensor Interfacting
  28. 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
  29. 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
  30. Making a Cowardly Robot
  31. 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
  32. 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
  33. 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
  34. Making a Cowardly Robot With Lights
  35. 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
  36. 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
  37. Controlling a Robot with Windows Phone
  38. System Architecture This the architecture for our Windows Phone controlled Micro Framework robot http Xbee WindowsPhone Robot Control Web Server Fez Mini Robot
  39. .NET Micro Framework Hosting The phone talks http to the robot web server http Xbee WindowsPhone Robot Control Web Server Fez Mini Robot
  40. 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
  41. Micro Framework Display Library The graphics display is based on WPF You use the StackPanel class to automatically layout content
  42. .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
  43. 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
  44. .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
  45. 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
  46. 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
  47. .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
  48. 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
  49. 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
More Related