NET Microframework
Download
Report
Transcript NET Microframework
.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
.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émoire Flash/ROM
.NET compatibility
• Different Versioning
• Selections from all desktop
releases
• Specific Embedded support
added
.NET Microframework for
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, …
Namespaces
System.Windows
Partial implementation
Same as .NET Fx
System.Windows.Controls
Window
Border
ListView
System.Windows.Input
Button
RadioButton
Keyboard/GPIO
CheckBox
ScrollViewer
Mouse
Panel
StackPanel
System.XML
Stylus
Image
TextBox
Reader
ListBox
UIElement
Writer
System.Forms
System.Drawing
System.Service.Model
DPWS Discovery
DPWS Eventing
System.Data
System
Collections
Globalization
Diagnostics
Security
Reflection
Threading
IO
Runtime
Remoting
Serialization
Resources
NET/HTTP
Compiler Svcs
DPWS Addressing
DPWS Transfer
Proxy Discovery
SerialPort
USB
Managed Drivers
I2C/SPI
A/D
GPIO
PWM
Power Mgmt
Watchdog
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
My first project : Hello Led
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
My first Web Server
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
Managing my sprinklers
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
Lighting my Lego city
How it works
Web Server with
ASP.NET pages
http
Netduino
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 Microframework sources: http://netmf.codeplex.com/
Visual Studio Express: http://www.microsoft.com/visualstudio/enus/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%20g
uide%20to%20NETMF.pdf
http://www.ghielectronics.com/catalog/category/265/
http://blogs.msdn.com/laurelle
QUESTIONS
Laurent Ellerbach
[email protected]
http://blogs.msdn.com/laurelle