10
\$\begingroup\$

I've been messing around with Arduino for a while now, and I'm in the process of moving from beginner to intermediate. I'd like some opinions on the .NET Micro Framework, in terms of performance and hardware availability.

I'm a .NET programmer, but I've found Processing for Arduino to be pretty much zero friction... It's so close to C# that anything I want to do doesn't even require a trip to the documentation.

Anyhow, which is better?

\$\endgroup\$
17
\$\begingroup\$

If you want to move from beginner to intermediate, the language you need to learn is C. Even if you put the whole Windows lock-in debate aside, you need to be very good at programming in C before you can do quality work on a microcontroller in a higher level language like .NET Micro or C++.

Embedded systems are composed of a pyramid of knowledge, and you really need to know at least some of each step to be a good designer:
^User code
^^Operating systems
^^^The C language
^^^^Assembly language
^^^^^Microcontroller architecture
^^^^^^Digital design
^^^^^^^Semiconductors
^^^^^^^^Basic electronics (Ohm's law)

The Arduino framework provides a convenient hook for hobbyists into the pyramid somewhere between the C language and an operating system.

Specific to your the .NET Micro Framework question, the About says:

The typical .NET Micro Framework device has a 32 bit processor with no external memory management unit (MMU) and could have as little as 64K of random-access memory (RAM).

Also, the brochure differentiates it from Windows Mobile, Windows Embedded, CE 6.0, and the .NET Compact Framework, and compares it to Linux, Real-Time, Java, and custom operating systems. This is a huge jump from the Arduino/Processing framework.

Your Arduino has an 8-bit processor with 1k of RAM. In addition to the 8-bit vs. 32-bit power loss, it also runs less than half as fast as most of the listed processors. While I wouldn't discourage you from moving to a 32-bit processor, I would recommend it as an intermediate-to-advanced move.

It's really easy to use up a lot of time and memory with a few lines in C# or C++, which are insignificant on a dual core processor running at a couple gigahertz with gigabytes of RAM, but which can make a huge difference on an embedded device. Until you are good in assembly language and/or C, or a guru in C# or C++, I wouldn't recommend using it for embedded programming.

So, I'd start with downloading WinAVR, and program a simple LED blink routine in C. If C is totally confusing to you, do a little bit of native code ("Hello World") on your PC, and then move to the microcontroller, but that shouldn't be necessary. Next, move up to communication over the UART, start using interrupts, and redo some of your Arduino projects in C. Then, find (or make!) a new development board with a different microcontroller, maybe a PIC or an ARM, and some goodies like an LCD screen, Ethernet, SD card, or whatever you want, and try to learn a new system. Once you get there, you'll know better where you want to go.

We'll be here to help you along the way!

\$\endgroup\$
  • 6
    \$\begingroup\$ I disagree that knowledge of assembler and C are essential. It is critical to understand how microcontrollers work. Learning assembler (c, less so) is certainly one route to this understanding, but its not the only one. \$\endgroup\$ – Connor Wolf Jul 29 '10 at 7:11
  • 4
    \$\begingroup\$ @Fake Name: Sure, that's why I said "at least some of each." Following a simple program from C to assembly to hex, and understanding each step, will make you a far better programmer. You can later let the magic do its thing if you want to, but you need to understand the capabilities of the machine you're working with. \$\endgroup\$ – Kevin Vermeer Jul 29 '10 at 12:13
  • \$\begingroup\$ Whoops, sorry. Missed the "Some of". \$\endgroup\$ – Connor Wolf Aug 3 '10 at 1:35
7
\$\begingroup\$

I have no experience with the ".NET Micro Framework", but I am highly suspicious of anything that involves running a virtual machine on low powered embedded platforms. It just seems like a waste to me. You need more power processors, more memory, more power consumption, to achieve the same effect as running a more dedicated platform that compiles down to native machine code. Possibly why my 528MHz Android phone running a virtual machine (similar to JVM) often feels slower than my previous several year old 312MHz Palm Treo which runs applications compiled for native machine code.

From a quick look, .NET MF requires an ARM processor, which is a step above in power & complexity from the 8-bit ATMega chips used in Arduino.

My suggestion is that if Arduino does what you want it to, stick with that. If not, you can look to the more powerful ATMega or ATXmega chips, and above that work with ARM directly in C/C++, without the extra .NET translation layer on top of it.

\$\endgroup\$
  • 2
    \$\begingroup\$ I heartily agree, but I don't think that's what's happening. I think the IL gets translated into machine specific code when it's deployed. Here's a link that undergirds that assumption: microsoft.com/downloads/… I AM pretty happy with Arduino so far...I think the only thing possibly persuading me is that I have found a pretty impressive shield selection on tinyclr.com...I haven't seen that extensive a shield selection for Arduino. \$\endgroup\$ – Chris B. Behrens Jul 27 '10 at 17:41
  • 1
    \$\begingroup\$ The power-to-programmer effort tradeoff is also why our desktop PCs take just as long to boot and launch programs as the computers we used 5 or 10 years ago. \$\endgroup\$ – Kevin Vermeer Jul 27 '10 at 17:43
  • \$\begingroup\$ @Chris - The problem is not that it doesn't run machine code, it's that it runs it through a bunch of abstractions. Abstraction, objects, generic libraries, modularity, etc. are all good in that they simplify programming, but they take time and space. \$\endgroup\$ – Kevin Vermeer Jul 27 '10 at 17:46
  • \$\begingroup\$ Yeah, but I think the abstraction layers exist only (or at least mostly only) on the development machine. But of course, this is just the kind of information I need. \$\endgroup\$ – Chris B. Behrens Jul 27 '10 at 21:57
  • 2
    \$\begingroup\$ @Chris - The abstractions are propagated all the way down to the machine code. In the end, the machine performs operations on addresses: Load, store, add, conditional branch, etc. Assembly is a one-to-one translation of machine code, and C maps comparatively closely to it. However, higher-level languages have a lot of work to do, because there's no, say, try/catch instruction in any processor's instruction set. The machine code required to implement an exception handler is not trivial. \$\endgroup\$ – Kevin Vermeer Jul 28 '10 at 18:08
4
\$\begingroup\$

If you want to move to intermediate you should try a platform outside Arduino enviroment. There are a lot of them to choose, you can stay at 8 bits, even with an Atmel MCU or move to one from another vendor. Use an IDE, write code C language, understand how a MCU works, write your own bootloader code or use an in-circuit programmer and keep moving.

But if you really want to try write in C# for microcontrollers, try this: http://www.trygtech.com/products/sh7619_evb.php

It uses a much bigger MCU, the typical .NET footprint is about 512K of flash memory and 256k of RAM.

\$\endgroup\$
  • 2
    \$\begingroup\$ That system uses the .NET Micro framework. It is precisely the kind of system that Chris was looking for opinions on. \$\endgroup\$ – Kevin Vermeer Jul 28 '10 at 12:34
4
\$\begingroup\$

I just saw the Netduino which may be an interesting compromise for you. I have no idea of the system specs or details but it does appear to use .NET Micro so it sounds like a good way to at least try out that framework.

\$\endgroup\$
3
\$\begingroup\$

The biggest single issue for me with Processing/Arduino is the lack of a decent debugger. I have an AVR dragon, but this doesn't help much because either (a) AVR Studio's debugger is slow and buggy, or (b) debugging in Eclipse is just plain slow and, while less so, still buggy. I haven't had a chance to try it in WinAVR, but that's next on the list.

There of course is no debugger in the Arduino IDE.

Once you step outside of simple applications and start building apps that have to do involved stuff at the wired and wireless network level, it's quite frustrating. This is mainly why I'm taking a serious look at the .NET MF - have been playing with the SDK, and have some hardware turning up soon.

\$\endgroup\$
  • \$\begingroup\$ Oops... lapse in concentration! I'm using the WinAVR toochain with eclipse ;-) \$\endgroup\$ – user3247 Mar 4 '11 at 22:07
  • 1
    \$\begingroup\$ I will confess...it never occurred to me that in either system that there would be a debugger, aside from pin 13. That definitely necessitates a second look at Netduino... \$\endgroup\$ – Chris B. Behrens Mar 4 '11 at 23:18
  • \$\begingroup\$ Yep; you can use DebugWire on the smaller ATMegas, and JTAG on the larger chips (1280 and above I think) to do on-chip debigging of Arduino apps via the two environments mentioned above. You have to have hardware to do this, though, and for me the Dragon at around $50USD was a good buy \$\endgroup\$ – user3247 Mar 5 '11 at 1:35
  • \$\begingroup\$ But, as I mentioned both options seemed to be average at best experiences. I'm looking forward to doing the debugging comparison with the netduino i have coming. \$\endgroup\$ – user3247 Mar 5 '11 at 1:38
  • 1
    \$\begingroup\$ An update on this - received a netduino plus a couple of days ago and have been playing with it. I have to say the out of the box experience is amazing compared to the current state of play in Arduino. Nothing fancy required - just visual studio (you can use the free 'express' version) and a usb cable and you're up and running with on-board debugging in a jiffy. All the intellisense stuff works in the IDE, and I have to say - even though I've done a bunch of c/c++ work on other platforms, using .NET makes buildnig embedded code criminally easy ;-) \$\endgroup\$ – user3247 Mar 9 '11 at 15:53
2
\$\begingroup\$

You might want to check out the Netduino. It is built to be compatible with the arduino layout and pins, and runs the .NET Micro Framework. So you can code in C# and even debug inside Visual Studio!

So far I have found it to be very good and easy to work with. While I haven't found a lot of tutorials, I think that you can just port a lot of the Arduino stuff. Me being a newb, I was able to easily port a photoresistor/photocell setup and code from an Arduino tutorial.

\$\endgroup\$
1
\$\begingroup\$

You could consider doing Arduino-style C development on an STM32 (ARM M3), via one of several open source projects. LeafLabs and xduino both have working hardware and Arduino based toolchains. I've been using the Leaflabs Maple board when I need a 32bit microcontroller, over regular Atmega chips

\$\endgroup\$
1
\$\begingroup\$

You could look at http://www.hpinfotech.ro/html/cvavr.htm which is a nice easy to use IDE for the Atmel and write some C I have used this professionally and its very good, more like the level of convenience you get from IDE's like Visual Studio. I have Eclipse to be a bit clunky for Android development not as slick as a bought one.

I have Netduino which I have implemented a Tricopter control system for fun, which is very much real-time and it works reliably, written in C# with Visual Studio 2010. The debugging on the device is generally excellent, I have it auto syncing data via wifi and I have a tiny HTTP server on the aircraft.

\$\endgroup\$
0
\$\begingroup\$

We use .NET Micro Framework in production applications (precision measurement devices). It works fine.

Today's microprocessors have reached the state when you can use the 'create-see-profile-change-see...' paradigm. Memory amounts are quite big and cheap now, so most probably you won't stack with out-of-memory conditions.

And as a C# developer, you know that adequate profiling to reach a desired condition is a better way to live than guessing what else and more complicated you should do while creating your code to make your code (and maybe not) a bit faster.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.