--micro_out=._.NET Micro Framework-适用于软件人员的硬件

--micro_out=.

--micro_out=.

I'm definitely a software person. I took EE in school and made an LED class, then a small computer like everyone else, and I know my volts and my amps for the most part, but that's about it. The limits of my skills are somewhere around adding an LED and some resistors to leech power off a USB adapter (which I recently did while working on the Hanselcade retro arcade build).

我绝对是软件人。 我在学校上了EE,并开了LED课,然后像其他所有人一样参加了一台小型计算机,我基本上了解我的伏特和安培,但是仅此而已。 我的技能极限是在添加LED和一些电阻器以关闭USB适配器的电源方面(我最近在进行Hanselcade复古街机构建时做了此操作)。

I look at hardware guys like Clint Rutkas in awe. I mean, seriously, who builds a T-shirt cannon from scratch for fun? Amazing.

敬畏地看着像Clint Rutkas这样的硬件专家。 我的意思是说,认真地说,谁从头开始建造T恤大炮是为了娱乐? 惊人。

Clint sent me a "Netduino" board today. It's similar to an Arduino board, except it uses the .NET Micro Framework. Micro you say? That's techie-speak for "tiny ass framework." I spoke to Colin Miller about this earlier in the year on video at Channel 9.

克林特今天给我寄了一个“ Netduino”板。 除了使用.NET Micro Framework之外,它类似于Arduino板。 微你说? 那是“小屁股框架”的技术代表。 我在今年早些时候通过第9频道的视频Colin Miller进行了交谈。

Remember my SPOT watch from 2004? That's Smart Personal Objects Technology, which is marketing-speak for "tiny ass framework." That watch is six years old (and still running nicely, sitting on my desk, in fact) and ran .NET.

还记得2004年的SPOT手表吗? 那就是Smart Personal Objects Technology,它在市场上被称为“小屁股框架”。 那只手表已经六岁了(实际上仍然很好地运行,坐在我的桌子上),并且运行.NET

Fast forward to today and I find myself plugging in this Netduino board to my computer and following Pete's Hello World Tutorial and I'm looking at this namespace.

快进到今天,我发现自己将这个Netduino板插入到我的计算机中,并遵循Pete的Hello World Tutorial ,我正在寻找这个名称空间。

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

使用Microsoft.SPOT; 使用Microsoft.SPOT.Hardware;

It's back!

回来了!

Ok, putting it all together in context. The Netduino is a board that's mostly Arduino compatible and has a published schematic (PDF here) so you could make one yourself, if you wanted. The .NET Micro Framework (or TinyCLR as some folks have called it) is literally that - it's a tiny CLR that runs .NET byte code. You can write C# and it'll run on tiny CPUs with tiny amounts of memory (like 64k or something similarly smallish.) It's been with us all this time, and there is an enthusiastic community built around it.

好的,将它们放在上下文中。 Netduino是一个与Arduino基本兼容的电路板,并具有已发布的原理图(此处为PDF ),因此您可以根据需要自己制作。 .NET Micro Framework(或某些人称为TinyCLR)的字面意义是-它是运行.NET字节码的微型CLR。 您可以编写C#,它将在具有少量内存(例如64k或类似的较小内存)的微型CPU上运行。这一直伴随着我们,并且围绕它建立了一个热情的社区。

The .NET Micro Framework 4.1 source is available, it's Open Source under the Apache 2.0 License. (Ya, the new Microsoft is freaking me out also. There's a lot of source that's quietly making its way out under increasingly liberal licenses.) There's lots of great details at Pete's blog.

可以使用.NET Micro Framework 4.1源,根据Apache 2.0许可,它是开放源。 (是的,新的Microsoft也在吓我一跳。在越来越自由的许可下,有很多消息来源悄悄地将其淘汰。) Pete的博客中有很多重要细节

Here's what a Netduino looks like:

Netduino的外观如下:

I'm going to think of some hardware ideas that I can build with this. I also have a more capable and fancy Tahoe II with a touch-screen, accelerometer, buttons and more. If you're looking to prototype something quick, or even build a complete system with an off-the-shelf board, do check it out! Here's what a Tahoe II looks like. Remember, all these boards use C# and .NET. It's amazing writing something for hardware using a language and framework I already know how to use. It literally gets me 80% of the way there from a learning curve perspective.

我将考虑一些可以以此为基础的硬件思想。 我还拥有功能更强大,更漂亮的Tahoe II ,配备触摸屏,加速度计,按钮等。 如果您希望快速制作原型,或者甚至使用现成的板构建完整的系统,请进行检查! 这就是Tahoe II的外观。 请记住,所有这些开发板都使用C#和.NET。 使用我已经知道如何使用的语言和框架为硬件编写一些东西真是太神奇了。 从学习曲线的角度来看,从字面上看,它可以让我80%地达到目标。

There's also the GHI Electronics EMX Development system, so there's a lot of choices.

还有GHI Electronics EMX开发系统,因此有很多选择。

With each of these boards (and others) you just need to get the Micro Framework 4.1, then the SDK for that specific board. It integrates into Visual Studio 2010. If you want to change the product, they are taking proposals in the .NETMF Forums.

对于这些板(和其他板),您只需要获取Micro Framework 4.1 ,然后获取该特定板的SDK。 它已集成到Visual Studio 2010中。如果要更改产品,他们将在.NETMF论坛中提出建议

Directly from Pete's blog:

直接来自Pete的博客

入门 (Getting Started)

What you'll need:

您需要什么:

  • Netduino (Scott: or some other .NET Micro Framework board)

    Netduino (斯科特:或其他一些.NET Micro Framework板)

  • USB Cable (early Netduino units come with the USB cable) (Scott: Usually a micro- or mini-USB)

    USB电缆(早期Netduino设备随附USB电缆) (斯科特:通常为微型USB或微型USB)

  • Visual Studio 2010 and the .NET Micro Framework 4.1 SDK  (you can use C# Express 2010 if you don't have Visual Studio)

    Visual Studio 2010和.NET Micro Framework 4.1 SDK (如果没有Visual Studio,则可以使用C#Express 2010)

  • Netduino SDK in 32 bit or 64 bit, depending on your host OS.

    Netduino SDK( 32位64位) ,具体取决于您的主机操作系统。

  • Optional: shields and starter kits to do cool things with netduino. Existing Arduino shields are compatible. A shield is just an add-on card that fits the pins on the board.

    可选:防护罩和入门套件,用于使用netduino进行散热。 现有的Arduino防护板兼容。 屏蔽层只是适合主板上引脚的附加卡。

The SDK installs a device driver for talking to the Netduino. Make sure you select the one with the appropriate bitness, and that you install it before connecting the Netduino to the PC. I installed the VS2010 bits before the SDK, but it shouldn't matter.

SDK安装了用于与Netduino对话的设备驱动程序。 将Netduino连接到PC之前,请确保选择具有适当位数的适配器,并进行安装。 我在SDK之前安装了VS2010,但没关系。

Once you plug in the Netduino, using the USB cable, you should see the device driver get installed, and the power LED on the board light up.

使用USB电缆插入Netduino后,应该会看到设备驱动程序已安装,并且板上的电源LED点亮。

莫尔斯电码的Hello World (Hello World with Morse Code)

Now I just have the Netduino for now, so I haven't got any attachments. If I was a hardware guy, I'm sure I'd go try to take apart a toaster or remote control and declare something like "this toaster just needs a one OHM resister on pin-out 5A so I can invert the voltage and it'll toast bread over Bluetooth" but I have no idea what that means. All I can do with the Netduino out of the box to flash its LED, as Pete points out:

现在我现在只有Netduino,所以没有任何附件。 如果我是硬件人员,我敢肯定,我会尝试拆开烤面包机或遥控器,并声明类似“此烤面包机只需要在引脚5A上安装一个OHM电阻器,这样我就可以反转电压了“将通过蓝牙烤面包”,但我不知道那是什么意思。 正如Pete所指出的,我可以使用Netduino开箱即用的所有功能来闪烁其LED。

public static void Main() 
{
OutputPort onboardLed = new OutputPort(Pins.ONBOARD_LED, false);

while (true)
{
onboardLed.Write(true);
Thread.Sleep(500);

onboardLed.Write(false);
Thread.Sleep(500);
}
}

Let's make it fancier. How about outputting string using Morse Code? Wikipedia says a dot is 100ms long and a dash is 300ms. How hard can it be?

让我们变得更奇特。 使用摩尔斯电码输出字符串怎么样? 维基百科说一个点长100毫秒,一个破折号长300毫秒。 它能有多难?

I could go to StackOverflow as they had a contest to see who could make the SMALLEST implementation that would take a string and output Morse Code. They have an extremely optimized (for lines of code) solution. But it's extremely silly. Certainly no more silly than me making an LED blink Morse Code as well, but I'd like to be able to actually read my code. ;)

我可以去StackOverflow,因为他们有一个竞赛,看谁可以做一个最小的实现,该实现需要一个字符串并输出莫尔斯电码。 他们有一个非常优化的(针对代码行)解决方案。 但这非常愚蠢。 当然,也比让我让LED闪烁摩尔斯电码更傻,但是我希望能够真正读取我的代码。 ;)

So, here's a naive 10 minutes solution using this guys' two arrays because I'm too lazy to type up the Morse myself. I could have use a Hashtable also, but two parallel arrays was fine too. The .NET Micro Framework, being micro, doesn't have everything the full framework has. However, being open source, it has taken contributions and version 4.1 includes a Hashtable implementation.

因此,这是一个使用这两个人的数组的10天幼稚解决方案,因为我太懒了,无法自己输入摩尔斯电报。 我也可以使用Hashtable,但是两个并行数组也可以。 微型的.NET Micro Framework并不具备完整框架的所有功能。 但是,它是开源的,它已经做出了贡献,并且4.1版包含一个Hashtable实现。

I can even debug directly connected to the board!

我什至可以直接将调试连接到板上!

Here's my sad little program (it was very easy!)

这是我悲伤的小程序(非常简单!)

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using System.Text;
using System.Collections;

namespace NetduinoApplication1
{
public class Program
{
public static void Main()
{
OutputPort onboardLed = new OutputPort(Pins.ONBOARD_LED, false);

while (true)
{
onboardLed.Write(false);

foreach (char c in " hello scott hanselman ")
{
string morse = ConvertTextToMorse(c);
Debug.Print(c + " = " + morse);
TransmitDotOrDash(onboardLed, morse);
}

}
}

private static Char[] Letters = new Char[] {'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', ' '};

private static String[] MorseCode = new String[] {".-", "-...", "-.-.",
"-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..",
"--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-",
"...-", ".--", "-..-", "-.--", "--..", "-----", ".----", "..---",
"...--", "....-", ".....", "-....", "--...", "---..", "----.", " "};

public static String ConvertTextToMorse(char c)
{
int index = -1;
index = Array.IndexOf(Letters, c);
if (index != -1)
return MorseCode[index];
return string.Empty;
}


public static void TransmitDotOrDash(OutputPort port, string dotordash)
{
foreach (char c in dotordash)
{
TransmitDotOrDash(port, c);
}
Thread.Sleep(300); //gap between letters
}

public static void TransmitDotOrDash(OutputPort port, char dotordash)
{
if (dotordash == ' ')
{
port.Write(false);
Thread.Sleep(700); //gap between words
}
else //it's something
{
port.Write(true);
if (dotordash == '.')
Thread.Sleep(100); //dot
else
Thread.Sleep(300); //dash
port.Write(false);
}
}
}
}

Here's the debug output as I flash "hello scott hanselman" from the board.

这是我从板上刷新“ hello scott hanselman”时的调试输出。

Debug Output from the Netduino Board

All it all, it really couldn't be much easier. Next I'll try to get the Tahoe II working and maybe make a game for the boys. Perhaps hook up a speaker and a proximity sensor and see if they can sneak up on it.

所有这一切,真的很容易。 接下来,我将尝试使Tahoe II正常工作,并可能为男孩们制作游戏。 也许挂上扬声器和接近传感器,看看它们是否可以潜入其上。

Related Links

相关链接

翻译自: https://www.hanselman.com/blog/the-net-micro-framework-hardware-for-software-people

--micro_out=.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值