Questions about Netduino+2, realtime and netmf - Netduino Plus 2 (and Netduino Plus 1) - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Questions about Netduino+2, realtime and netmf


  • Please log in to reply
10 replies to this topic

#1 ElleNearMello

ElleNearMello

    New Member

  • Members
  • Pip
  • 3 posts

Posted 26 November 2012 - 09:51 AM

Hello, I am a new user. I have the following general questions: 1. Where is the advantage of using netmf over C for microcontrollers? Given that micro-controllers are very small and "simple", it's not so hard to develop firmware with various IDE (keil and eclipse are my favourite). I think visual studio is superior, some IDE are really obsolete (expecially in the 8-bit microcontroller's world), but overall I can see that developing in C is not that hard-for-nerds-only, even on bare-metal with "superloop" architecture (that is "while(1) + interrupts") or with small real time OS (freeRtos). People are often frightened by struct, enum, bit-aritmetic, but it is really easy. So where are the advantages of netmf? considered that netfm eats up significant resources (ram + flash space + cpu cicles) off an alreay limited device. 2. What is the impact of not being realtime? Even is the system is not real time, I see it is capable of responding to ethernet frames, while controlling led and buttons, etc... The problem arise in scenarios like "priorities": if a device is responsible for 3 "tasks" (display, buttons, and ethernet replies), and ethernet reply is the most important (=has the max priority and has the right to interrupt everything else when a frame arrives), how can I cope this with netmf?? 3. Software architecture: is superloop my only choice with netmf? Is it possibile to have a "task layer" that switches task, even if no realtime will be garantied? The superloop is easy for simple programs, but is a failure for more complex projects. Don't you think it's better to organize code in "tasks" (each of which is a while(1)) that netmf switches automatically every 20ms? 4. Last question is: is netmf installable only on netduino series? If I have a Cortex M4 without FPU, will it work? Or a cortex M3? Cortex M0 should be too low I think (no ram/flash) and my only choice would be plain C over the metal + superloop thanks

#2 Cuno

Cuno

    Advanced Member

  • Members
  • PipPipPip
  • 144 posts
  • LocationZürich / Switzerland

Posted 26 November 2012 - 03:41 PM

Is it possibile to have a "task layer" that switches task, even if no realtime will be garantied?
The superloop is easy for simple programs, but is a failure for more complex projects.
Don't you think it's better to organize code in "tasks" (each of which is a while(1)) that netmf switches automatically every 20ms?
...
If I have a Cortex M4 without FPU, will it work? Or a cortex M3?

Hi ElleNearMello

Welcome to the Netduino forum!

As a partial answer to your questions:

NETMF supports multithreading, and NETMF threads are in fact relatively inexpensive. Incidentally, the NETMF scheduler switches threads every 20 ms. So I guess the task layer that you mention is already built in. See http://blogs.msdn.co...s-in-netmf.aspx for an introduction to NETMF threads.

There is Cortex-M3 / M4 support for NETMF, in our NETMF for STM32 port (http://netmf4stm32.codeplex.com/). From a NETMF porting perspective, M3 and M4 are the same, modulo compiler switches in the ARM tool chain (e.g., to use the single-precision FPU in the STM32F4). You can also work with MCUs that have no hardware floating-point support. Here some more information: http://www.codeplex....wnloadId=390434

Best regards

Cuno

#3 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 26 November 2012 - 04:16 PM


1. Where is the advantage of using netmf over C for microcontrollers?
Given that micro-controllers are very small and "simple", it's not so hard to develop firmware with various IDE (keil and eclipse are my favourite).
I think visual studio is superior, some IDE are really obsolete (expecially in the 8-bit microcontroller's world), but overall I can see that developing in C is not that hard-for-nerds-only, even on bare-metal with "superloop" architecture (that is "while(1) + interrupts") or with small real time OS (freeRtos).
People are often frightened by struct, enum, bit-aritmetic, but it is really easy.

So where are the advantages of netmf? considered that netfm eats up significant resources (ram + flash space + cpu cicles) off an alreay limited device.


Also welcome in the Netduino world.
This question could be answered thinking how long (i.e. expensive) takes writing a relatively complex application. Of course, if you just wanna blink a led the NetMF is an overkill, but what if you want to create a small app collecting data and exposing a simple web-service/page?

If you don't like this answer, I'll make this one for you: if you were creating a desktop Windows application, would you use C/C++ or C#?

Cheers
Biggest fault of Netduino? It runs by electricity.

#4 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 26 November 2012 - 04:21 PM

Hello and Welcome, 1) Some advantages: As you mentioned, Microsoft's Visual C# Express is Free and a high-end IDE. Also the .NET Micro Framework is open-source and free. The Same code will run on most NETMF devices with little or no change. The IDE provides full debugging capabilities including breakpoints, step through code, checking variables, etc. It's also used in many commercial products therefor its tested. Includes many drivers for buses like SPI, UART, I2C, etc. Supports Multi-Threading and Event Driven Code. Is configured to work well with low power consumption models. These are just to name a few. 2) As far as realtime issues... multi-threading is the answer. NETMF can handle these tasks with equal priority. If your application is so resource intensive that it needs to interrupt other functions strictly for the Ethernet Functions the Netduino may not be the proper hardware for your needs. In most cases there shouldn't be an issue. 3) With the ability to use Multi-Threading, Events and Full Object Oriented Code you don't need a Superloop. In most of my projects the loop is small or nearly non-existent since there are threads handing the timed or repeating tasks and Event Handlers taking care of the as needed or as it happens code. For example, I can build a simple application that uses a thread and checks a light sensor every say 30 seconds. I also have a PIR motion sensor that when triggered fires off an event. Finally I have a Solid State Relay connected to a light bulb. The purpose is to turn on the light when either motion is detected or the light level reaches a certain darkness level. My main loop consists of nothing more than definitions and thread starters and event handler definitions. Separate methods handle the light sensor thread and the PIR motion event. Both of these will call another method in the event the conditions are satisfied and this methods turns on the light. It's clean, small loop and uses the power of NETMF. 4) The NETMF currently runs on many pieces of hardware as long as it has been ported to that platform. GHI Electronics as well as Secret Labs have hardware out for NETMF already. There is a porting kit available if you are up to the task of designing your own board or porting to another Microcontroller. More about the Porting kit can be found here - http://www.microsoft...s.aspx?id=22113 I hope this information helps a bit. I'm sure other forum users can add to my benefits.

#5 ElleNearMello

ElleNearMello

    New Member

  • Members
  • Pip
  • 3 posts

Posted 26 November 2012 - 08:51 PM

Thanks everybody for the answers, now I have a clearer view. How is the market situation of the so called "shields"? I think I would need an LCD display, some leds and relais, and a wireless module (wifi/bluetooth/zigbee , but I bet more on wifi). Do you have successful experiences with these? If I use wifi do I use the same stack of ethernet or something is different?

#6 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 26 November 2012 - 10:05 PM

There are many to choose from on the market and if you search these forums there are many class libraries already written for many of the shields or other hardware

#7 ElleNearMello

ElleNearMello

    New Member

  • Members
  • Pip
  • 3 posts

Posted 27 November 2012 - 08:07 AM

So for example if I am interested in this: STM32F051R8T6 ARM Cortex-M0 32-bit microcontroller with 64KB of Flash memory 1) it is not enought to run netmf 2) if I want to develop on that cortex-m0 my only option is to buy expensive compiler suite + ide, for example Keil has the free limited to only 32kb. The first option is the "basic" @ 2000euros :blink: correct? so with netmf I spend a little more on CPU (Cortex M4 is 7$ for 1000pcs), but I save huge on IDE+tools?

#8 Geancarlo2

Geancarlo2

    Advanced Member

  • Members
  • PipPipPip
  • 70 posts

Posted 27 November 2012 - 08:26 AM

So for example if I am interested in this:
STM32F051R8T6 ARM Cortex-M0 32-bit microcontroller with 64KB of Flash memory

1) it is not enought to run netmf

2) if I want to develop on that cortex-m0 my only option is to buy expensive compiler suite + ide, for example Keil has the free limited to only 32kb. The first option is the "basic" @ 2000euros :blink:

correct?

so with netmf I spend a little more on CPU (Cortex M4 is 7$ for 1000pcs), but I save huge on IDE+tools?

1) correct

2) wrong. You can go with the free and open alternative: gcc toolchain for arm + openocd + eclipse cdt. Just takes a little more work and knowledge to get things up and running. There are also other free "bundles", such as CoIDE(http://coocox.org/)

#9 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 27 November 2012 - 08:42 AM

ad 2) There are many ARM toolchains, free GCC-based like Yagarto, Sourcery, GNU Tools for ARM, free trial/evaluation/size limited IAR EWARM, Keil MDK-ARM, affordable CrossWorks for ARM, then Atollic TrueStudio, ARM RVDS and others. Some of them are quite expensive, but there is huge difference in output code size (mostly C/C++ runtime), optimization quality, debugging support, libraries etc. Basically, you get what you pay for.

Free size-limited toolchains are fine for most of the hobby development, especially when you work with a microcontroller that has less flash than the limit. Beware of the license though, usually it does not allow commercial development.

You can use free Visual C#/VB.NET 2010 Express or any higher Visual Studio 2010 edition to develop .NET Micro Framework applications, Visual Studio 2012 will be supported in .NET MF 4.3. There is also experimental Mono support. But in case you want to modify the firmware, you'd need one of the ARM toolchains mentioned above, most likely very expensive one for Netduino/Mini/Plus (due to limited flash size), the firmware for STM32Fx can be developed using GCC-based toolchains.

#10 apokryphus

apokryphus

    Member

  • Members
  • PipPip
  • 12 posts

Posted 08 March 2013 - 09:24 PM

Hey, i now stumbled around for at least an our to find some information about freertos and how to install it on the net+2 - maybe someone could post a link or even a tutorial for this? i would like to learn c/c++ on that platform combination and really need some help. regards

#11 ziggurat29

ziggurat29

    Advanced Member

  • Members
  • PipPipPip
  • 244 posts

Posted 12 March 2013 - 02:42 AM

...i now stumbled around for at least an our to find some information about freertos and how to install it on the net+2 - maybe someone could...

you may be the one!  Its certainly doable (dumping the netmf and going native), though I think most folks stick with the netmf because thats why they're here to begin with -- for the dotnet.  but the netduino is a perfectly lovely hardware platform in its own right irrespective of netmf, and certainly deserves some lower-level love.

 

I have used FreeRTOS, but not on the ST32F4 (I used it on a PIC32, with way less resources than the st32fx). Its quite serviceable for many applicaitons and the price is right, and I really enjoyed having tasks and not having to write yet another timer isr task manager myself. A lot.

 

That being said -- and I am not a dotnet fanboy by trade -- event more so I really really really like having the high level constructs of threads, synchronization objects, exceptions, string manipulation routines (its the little things in life), regexes (gasp!) at my disposal in an embedded environment. Its so luxurious I feel ashamed at times.

 

both have their merit; but if you can afford the time to try some new things, I do recommend you try the netmf way.  and this is coming from a sceptic!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.