200 likes | 415 Views
.NET Microframework. 2010-03-27 Laurent Ellerbach Audience Marketing Director Microsoft Central and Eastern Europe. Agena. .NET Microframework Demo Hello Led Demo My first HTTP Server Demo managing my sprinklers Demo Lighting my Lego city. .NET Micro Framework.
E N D
.NET Microframework 2010-03-27Laurent EllerbachAudience Marketing Director Microsoft Central and Eastern Europe
Agena • .NET Microframework • Demo Hello Led • DemoMy first HTTP Server • Demomanagingmy sprinklers • DemoLightingmy Lego city
.NET Micro Framework .NET Microframework for • .NET for inexpensive processors • Directly on the metal, No MMU • Small, configurable footprint • ARM7 @ 20-40 Mhz • ARM9 @ 200 Mhz • ~ 300 Ko de RAM • 1 Mo de mémoireFlash/ROM • .NET compatibility • Different Versioning • Selections from all desktop releases • Specific Embedded support added
NETMF Open Source Model • Collaborative Open Source • Release History • V. 4.0 (Nov 2009) all Microsoft • V. 4.1 (June 2010) minor community contributions • V 4.2 (Summer 2011) > 30% community contributions • Non-Microsoft domain site – netmf.com • Partner communities • tinyclr.com, netduino.com • Ports from Atmel, NXP, Renasas, TI, ST Micro, …
Partial implementation Namespaces Same as .NET Fx System.Windows System.Windows.Controls Window Border ListView Button RadioButton System.Data CheckBox ScrollViewer System.Windows.Input System.XML Panel StackPanel Keyboard/GPIO Image TextBox Reader Mouse ListBox UIElement Writer Stylus System.Forms System.Drawing System Collections Globalization Diagnostics System.Service.Model Runtime Remoting Serialization Security Reflection DPWS Discovery Threading IO DPWS Eventing Resources NET/HTTP Compiler Svcs DPWS Addressing Managed Drivers DPWS Transfer I2C/SPI Power Mgmt SerialPort A/D Proxy Discovery USB GPIO Watchdog PWM
What do you need to start? • 1 board like the Netduino one • Get the Netduino Plus version with network support and SD for 50€ • The SDK • Free download • Visual Studio Express (C#) • Free download …and a good idea to build something Processor and memory Atmel 32-bit microcontroller Speed: 48MHz, ARM7 Code Storage: 64 KB without networking: 128 KB RAM: 28 KB without networking: 60 KB
Some Hard • All what you have to know : U = RxI • Want to use a led on an output pin (3,3V on Netduino) • 1 led = 2 V average, current 0,02A • R = (3,3 – 2)/0,02 = 65 Ohms
More Hard • Reuse an old sensor from a 15 years old hard drive used to count turns • Will blink a Led when the light sensor is obstructed 2V (red) Digital IO (yellow) Ground (black)
Analogic input example • Light sensor acting like a resistor 1M Ω (dark) to 100 Ω (very bright) • R = √(1M x 100) = 10K Ω • Analogic input = 3.3/(1+R/RL) • Vary from 0.0323V (very bright) to 3.23V (dark) +3.3V 10KΩ R Analogic input RL Ground
Implementing a web server • Start from the Web Server sample How it works • 1 thread per protocol = 1 for http • 1 handler to process all requests (GET and POST) • 1 function to process GET • 1 function to process POST • 1 function to return a file from storage (by chunk as limited buffer size) • 1 function to upload a file from storage (by chunk as limited buffer size) • Lots of other functions used to make it work • Excellent example implementing lots of good practices like file access
Simplifying the web server • Remove all code related to https • Remove all code related to POST if you only use GET • Remove all code related to file transfer • Remove all code related to directory listing • Add a function to read parameters in the URL • Add some code in the GET management function • Add your own code for your own pages
How it works Netduino http Client using a simple browser 2 Pages to manage the calendar programming 1 Page to switch on/of led 1 Page to manage the programming Timer to launch the sprinklers
How it works Web Server with ASP.NET pages Netduino http http Page to switch on/of led Client using a simple browser Page returning the setup
Tips and tricks • Try catch all the time… • Buffer is limited (1024 in most small ARM) • System.Threading.Thread.Sleep(100); • Compromise between nice code and efficient footprint • Security is important, think of it since the design • U=RI • if (Microsoft.SPOT.Hardware.SystemInfo.IsEmulator) strDefaultDir = "WINFS"; else strDefaultDir = "SD"; • localhost:81 used in the emulator for web serveur
Resources • SDK download: http://netmf.codeplex.com/releases/view/52341 • .NET Microframeworksources: http://netmf.codeplex.com/ • Visual Studio Express: http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express • Netduino: http://www.netduino.com/ • Blogs and useful links • http://www.netmf.com • http://blogs.msdn.com/netmf • http://blogs.msdn.com/netmfteam • http://www.tinyclr.com/ • http://nerduino.wordpress.com/ • http://www.ghielectronics.com/downloads/FEZ/Beginners%20guide%20to%20NETMF.pdf • http://www.ghielectronics.com/catalog/category/265/ • http://blogs.msdn.com/laurelle
QUESTIONS Laurent Ellerbachlaurelle@microsoft.comhttp://blogs.msdn.com/laurelle