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

Goodbye .NET MF?


  • Please log in to reply
9 replies to this topic

#1 franks

franks

    New Member

  • Members
  • Pip
  • 3 posts

Posted 18 December 2011 - 12:34 PM

Hello Netduino-Community!

Sad to say, am I going to get in trouble with a two channel 200 ppr code wheel rotary encoder. At the beginning everything works fine for me. But increasing the rotation speed the GC seems to be too slow for freeing memory.

I made a little sample program with these two functions (phase A and B with both edges):

private static int _steps = 0;
private void OnInputPhaseAInterrupt(uint data1, uint data2, DateTime time)
{
	_steps++;
}
private void OnInputPhaseBInterrupt(uint data1, uint data2, DateTime time)
{
	_steps++;
}

Turning the wheel slowly (about one rotation per second) works. Doubling the speed and the runtime will crash after about five rotations. :(

I changed the trigger to edge high to decrease the interrupts with the same effect. All tests are handmade, so I can't give you an accurate border.

With the .NET MF and SDK 4.1 I got an OuOfMemoryException. Upgrading to .NET MF and SDK 4.2 it changed to Failed allocation for 5 blocks, 60 bytes message.

With two interrupts on both edges we get 800 (2 x 400) interrupts per second. So we talking about 800 Hz. Increasing the speed to five rotations per second we obtain 4 kHz.

Is this really to fast for the .NET MF on a 48 MHz ARM7? And what are the options? Going back to c-compiled code and JTAG debugger?

Catastrophe! :blink:

Hope for a helping hand.


Best regards,

Frank

#2 franks

franks

    New Member

  • Members
  • Pip
  • 3 posts

Posted 18 December 2011 - 04:07 PM

I found this High resolution light measurement thread with the same issue.

Running the sample code from site two I get the following output:

F = 400.84 Hz
F = 148.31 Hz
F = 862.31 Hz
F = 5264.22 Hz
F = 3.87 Hz
F = 1628.00 Hz
F = 1701.96 Hz
F = 1993.20 Hz
F = 6225.64 Hz
F = 5300.70 Hz
F = 1182.43 Hz
Failed allocation for 5 blocks, 60 bytes
Failed allocation for 5 blocks, 60 bytes

It goes up to 6 kHz with one InterruptPort on both edges. Will the measurement work, if I put the ISR in native code and call it via Interop?

Btw. Is the cpu speed set to maximum?

Best regards,

Frank

#3 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 18 December 2011 - 06:39 PM

Hello Frank, and welcome here. Well, believe or not, but the Netduino MCU is really powerful. I tried certain tasks on a simple Arduino, but there's a magnitude of difference. You should bear in mind that the languages are not the same: the C# is fully managed, and the C/C++ is fully "manual". If you dig in this forum, you'd find several posts of mine, blaming the "slowness" of the Netduino/Micro Framework, just as you are doing. The problem is the perspective from where solving a problem. IMHO, Netduino is *NOT* targeted for very low level stuffs, nor to write your own native level drivers (despite to many users are able to do). A device like Netduino is targeting a layer above the Arduino typical one. Until you perform calculations using C# (i.e. managed code) you'll have lot of pain without any concrete result. As soon you'll "think smarter" how to create/connect hardware around the board, then the Netduino will surprise you, indeed. What's unbelievable (for me, for example), is why don't use an Arduino and a Netduino together. The Arduino is good for low-level yet "stupid" tasks, but the Netduino performs much better complex tasks. When you buy a shield and connect it to a *duino, what's the difference? Hope it helps. Cheers
Biggest fault of Netduino? It runs by electricity.

#4 franks

franks

    New Member

  • Members
  • Pip
  • 3 posts

Posted 19 December 2011 - 09:05 PM

Hello Mario! At first let me say thanks for presenting your clear view of the netduino. I'm conform with resolving complex requirements in managed code and sourcing the simple stuff out. But I'm not really sure, if this is an economic way. Before adding a second unit for counting the pulses, I will try to write a driver. I found some tutorials in the net and I understand the technic. Just one question left. Why adding a driver to the firmware for doing this work is not the recommend way? Are there technical problems or is it 'just' against the philosophy of netduino? Best regards, Frank

#5 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 20 December 2011 - 12:42 AM

Hello Mario!

At first let me say thanks for presenting your clear view of the netduino. I'm conform with resolving complex requirements in managed code and sourcing the simple stuff out.

But I'm not really sure, if this is an economic way. Before adding a second unit for counting the pulses, I will try to write a driver. I found some tutorials in the net and I understand the technic.


Unless you are going for a large number of units, adding a chip is the economic way. You don't need an original/full arduino, for this an attiny should suffice, those cost you $2 with circuitry or something. Now, I don't know what your time is worth to you, but you'll need way more time changing the netduino firmware ...



Just one question left. Why adding a driver to the firmware for doing this work is not the recommend way? Are there technical problems or is it 'just' against the philosophy of netduino?


Best regards,

Frank


The above is the reason :)
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#6 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 20 December 2011 - 05:09 AM

Stefan pointed out perfectly my considerations. I'd add a thing about writing a native driver in the firmware. As myself, I don't like (at all) C/C++, and I find much more comfortable wiring up a small circuit, instead of messing up my life with pre-historical *.h and *.cpp modules. However, that's for me... If you write a native driver useful for the whole community, then maybe Chris Walker will embed it into the official firmware. But this is much like the "dreamin' California" point of view...the truth is that you should spin off a "Frank-version-of-the-4.2-firmware-of-the-Netduino". Even it is a possibility, that would not supported by anyone than you. Chris Walker had a wonderful idea by creating Netduino: that's for sure. However, he had to squeeze all the "impossible" into a single 512K-flash MCU. The result is that is not easy to make modifications to the firmware, because the available flash is very limited: you must know very well how to move with native code, and also have the right tools to compress the code enough. Well, maybe sometime a new board will allow an easier implementation of native code. Cheers
Biggest fault of Netduino? It runs by electricity.

#7 gimpsterLee

gimpsterLee

    New Member

  • Members
  • Pip
  • 4 posts

Posted 23 December 2011 - 05:15 PM

franks, Just a cheap thought: You could add a simple quadrature encoder chip on a protoboard to count the pulses from the encoder, then wire the counter bits to the digital inputs of the netduino and the clock and reset pins to netduino digital outputs. You could then program the netduino to poll the counter as quickly as possible. This wouldn't be a viable idea though if: - You need to stop movement instantaneously on a particular encoder count - or if you don't have 8 free digital inputs and a couple of free digital outputs

#8 mr_sargent

mr_sargent

    New Member

  • Members
  • Pip
  • 4 posts

Posted 23 March 2012 - 08:56 PM

I am fairly new to the netduino and am currently working on my first project with it. I am bringing in a 2 channel encoder as Frank did and am having problems with the encoder count at higher speeds. There was a suggestion about using the Netduino in conjunction with a Arduino mini, where the arduino would manage the task of counting encoder pulses while the netduino could do everything else. My question is, what would be the best way to interface the netduino with an arduino? Serial? Any suggestions would be helpful. Thanks Ryan

#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 23 March 2012 - 09:25 PM

My question is, what would be the best way to interface the netduino with an arduino? Serial? Any suggestions would be helpful.

Serial is the easiest and most straightforward method to connect a Netduino and Arduino together.

Chris

#10 Ryan Mick

Ryan Mick

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts
  • LocationSacramento, CA

Posted 09 April 2012 - 02:13 PM

@Franks,
I encountered this problem when trying to interface a HH10D humidity sensor to the Netduino. I got around the problem by using PCF8583 RTC. This real time clock has an event counter mode and an I2C interface. The wiki has the code to interface with it here.Hope that helps.




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.