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.

Ravenheart's Content

There have been 18 items by Ravenheart (Search limited from 09-July 19)


By content type

See this member's

Sort by                Order  

#14019 Why so slow processing time?

Posted by Ravenheart on 07 June 2011 - 02:49 PM in General Discussion

By the looks of your code you seem to be trying to pause the thread for some time in order to "blink", if what you are doing is that then the way you do it totally wrong and you should instead look at the Thread.Sleep() method.



#10989 netduino/MF performance

Posted by Ravenheart on 16 March 2011 - 03:31 PM in General Discussion

Hi Daman.
I did not understand well what is your problem.

What I am tell you, is that the CLR is a very complex layer. Once you have written your C# code, the compiler creates an intermediate-language which is "portable". This is compiled again to native opcodes and sent to the Netduino.
The "overhead" of the CLR stands essentially in the memory management, which is garbage-collected automatically. This process gives you an huge simplicity to develop applications, a really safer way to play with objects, but it has a cost in terms of performance.

Just for have an idea of the timings, the only port read/write tight-loop is able to run at about 8.5KHz. That's is really "disappointing" for a 48MHz chip, but if you were just toggling an output, it's probably easier to write in assembler of C. Instead C#+Micro Framework has huge advantages when you want to embed very complex blocks: e.g. sockets, displays, threading, etc.

Hope it helps.
Cheers
Mario

The .NET Micro Framework is an interpreter, once you get your assembly stripped out that gets sent to the Netduino and that is interpreted when it runs. At no point does your C# project get compiled to native code.

EDIT: And I was slower to answer :)



#10305 Chris the star!

Posted by Ravenheart on 27 February 2011 - 11:42 AM in General Discussion

I can't find any video there.



#8008 Graphical LCD

Posted by Ravenheart on 20 January 2011 - 05:59 PM in Netduino 2 (and Netduino 1)

TinyCLR has such a display for the FEZ line, perhaps you could take a look at their drivers and see if they can be ported.



#7485 Use of Static Keyword

Posted by Ravenheart on 12 January 2011 - 12:45 AM in General Discussion

Although its better to use instances on the full framework, this is MICRO Framework so every little bit of memory saved is worth having static :rolleyes:



#4357 Netduino at PDC 2010 (or watch online)...

Posted by Ravenheart on 29 October 2010 - 11:43 PM in General Discussion

http://bit.ly/aWRwQX For those of you(me) who have missed it.



#4353 Netduino at PDC 2010 (or watch online)...

Posted by Ravenheart on 29 October 2010 - 08:02 PM in General Discussion

A countdown timer would be helpful :)



#3353 MS ARM Compiler support

Posted by Ravenheart on 01 October 2010 - 01:14 PM in General Discussion

"Download Windows Embedded Compact 7 Public Community Technology Preview (Public CTP) by......" its just a CTP, that may be the reason.



#2478 Live webcam and sound.

Posted by Ravenheart on 19 September 2010 - 03:09 PM in General Discussion

640x480 equals 307 200 pixels, 16 bits per pixel equals 614 400 bytes, or 600KB 320x240 equals 76 800 pixels, 16 bits per pixel equals 153 600 bytes, or 150KB You get the message :P



#2463 What is need to get started with Netduino?

Posted by Ravenheart on 19 September 2010 - 07:48 AM in General Discussion

I'd also recommend a soldering iron and a multimeter.



#2432 Controlling a LED Intensity

Posted by Ravenheart on 18 September 2010 - 07:36 PM in General Discussion

NegativeOne Chris?



#2425 Controlling a LED Intensity

Posted by Ravenheart on 18 September 2010 - 03:35 PM in General Discussion

PWM is best yes, you CAN do it with a DigitalIO and loop and Thread.Sleep() :rolleyes: but thats wasteful and its easier with PWM



#2400 Application always in running

Posted by Ravenheart on 17 September 2010 - 08:20 PM in General Discussion

What I do is write all my code in separate classes out of Program.cs with one class being the central unit, then I declare a static variable in Program.cs of the type of my central unit class, instantiate the variable in Main() and at that point the central unit class will handle everything and I use Thread.Sleep(-1); at the end. Its wasteful to lock the Main() method in an endless loop, even if it does nothing.



#2082 BitConverter

Posted by Ravenheart on 10 September 2010 - 11:58 AM in Project Showcase

I was in need of the BitConverter class in one of my projects, but alas NETMF does not have it :rolleyes: so here is my implementation, despite all references you CAN USE unsafe code in NETMF, just not the "fixed" keyword.
In order to use this open your project's Properties and tick the "Allow unsafe code" checkbox under the Build tab.

You are free to use the code in any type of project(commercial, open-source etc.), you can modify and distribute the code as you wish.

Note that using unsafe code is not documented, so even though it works fine under test conditions, we can't be sure just yet that it doesn't have side effects.

public static class BitConverter
    {
        public static unsafe long DoubleToInt64Bits(double value)
        {
            return *(((long*)&value));
        }
        public static unsafe double Int64BitsToDouble(long value)
        {
            return *(((double*)&value));
        }

        public static byte[] GetBytes(bool value)
        {
            return new byte[] { (value ? ((byte)1) : ((byte)0)) };
        }
        public static byte[] GetBytes(char value)
        {
            return new byte[2] { (byte)(value & 0xFF), (byte)((value >> 8) & 0xFF) };
        }
        public static byte[] GetBytes(short value)
        {
            return new byte[2] { (byte)(value & 0xFF), (byte)((value >> 8) & 0xFF) };
        }
        public static byte[] GetBytes(ushort value)
        {
            return new byte[2] { (byte)(value & 0xFF), (byte)((value >> 8) & 0xFF) };
        }
        public static byte[] GetBytes(int value)
        {
            return new byte[4] { 
                    (byte)(value & 0xFF), 
                    (byte)((value >> 8) & 0xFF), 
                    (byte)((value >> 16) & 0xFF), 
                    (byte)((value >> 24) & 0xFF) };
        }
        public static byte[] GetBytes(uint value)
        {
            return new byte[4] { 
                    (byte)(value & 0xFF), 
                    (byte)((value >> 8) & 0xFF), 
                    (byte)((value >> 16) & 0xFF), 
                    (byte)((value >> 24) & 0xFF) };
        }
        public static byte[] GetBytes(long value)
        {
            return new byte[8] { 
                    (byte)(value & 0xFF), 
                    (byte)((value >> 8) & 0xFF), 
                    (byte)((value >> 16) & 0xFF), 
                    (byte)((value >> 24) & 0xFF),
                    (byte)((value >> 32) & 0xFF),
                    (byte)((value >> 40) & 0xFF),
                    (byte)((value >> 48) & 0xFF),
                    (byte)((value >> 56) & 0xFF)};
        }
        public static byte[] GetBytes(ulong value)
        {
            return new byte[8] { 
                    (byte)(value & 0xFF), 
                    (byte)((value >> 8) & 0xFF), 
                    (byte)((value >> 16) & 0xFF), 
                    (byte)((value >> 24) & 0xFF),
                    (byte)((value >> 32) & 0xFF),
                    (byte)((value >> 40) & 0xFF),
                    (byte)((value >> 48) & 0xFF),
                    (byte)((value >> 56) & 0xFF)};
        }
        public static unsafe byte[] GetBytes(float value)
        {
            int val =*((int*)&value);
            return GetBytes(val);
        }
        public static unsafe byte[] GetBytes(double value)
        {
            long val = *((long*)&value);
            return GetBytes(val);
        }

        public static bool ToBoolean(byte[] value, int index = 0)
        {
            return value[index] != 0;
        }
        public static char ToChar(byte[] value, int index = 0)
        {
            return (char)(value[0 + index] << 0 | value[1 + index] << 8);
        }
        public static short ToInt16(byte[] value, int index = 0)
        {
            return (short)(
                value[0 + index] << 0 |
                value[1 + index] << 8);
        }
        public static int ToInt32(byte[] value, int index = 0)
        {
            return (
                value[0 + index] << 0 |
                value[1 + index] << 8 |
                value[2 + index] << 16 |
                value[3 + index] << 24);
        }
        public static long ToInt64(byte[] value, int index = 0)
        {
            return (
                value[0 + index] << 0 |
                value[1 + index] << 8 |
                value[2 + index] << 16 |
                value[3 + index] << 24 |
                value[4 + index] << 32 |
                value[5 + index] << 40 |
                value[6 + index] << 48 |
                value[7 + index] << 56);
        }
        public static ushort ToUInt16(byte[] value, int index = 0)
        {
            return (ushort)(
                value[0 + index] << 0 |
                value[1 + index] << 8);
        }
        public static uint ToUInt32(byte[] value, int index = 0)
        {
            return (uint)(
                value[0 + index] << 0 |
                value[1 + index] << 8 |
                value[2 + index] << 16 |
                value[3 + index] << 24);
        }
        public static ulong ToUInt64(byte[] value, int index = 0)
        {
            return (ulong)(
                value[0 + index] << 0 |
                value[1 + index] << 8 |
                value[2 + index] << 16 |
                value[3 + index] << 24 |
                value[4 + index] << 32 |
                value[5 + index] << 40 |
                value[6 + index] << 48 |
                value[7 + index] << 56);
        }

        public static unsafe float ToSingle(byte[] value, int index = 0)
        {
            int i = ToInt32(value);
            return *(((float*)&i));
        }
        public static unsafe double ToDouble(byte[] value, int index = 0)
        {
            long l = ToInt64(value);
            return *(((double*)&l));
        }

        public static string ToString(byte[] value, int index = 0)
        {
            return ToString(value, index, value.Length - index);
        }
        public static string ToString(byte[] value, int index, int length)
        {
            char[] c = new char[length * 3];
            byte b;

            for (int y = 0, x = 0; y < length; ++y, ++x)
            {
                b = (byte)(value[index + y] >> 4);
                c[x] = (char)(b > 9 ? b + 0x37 : b + 0x30);
                b = (byte)(value[index + y] & 0xF);
                c[++x] = (char)(b > 9 ? b + 0x37 : b + 0x30);
                c[++x] = '-';
            }
            return new string(c, 0, c.Length - 1);
        }
    }



#2076 SchmartBoard

Posted by Ravenheart on 10 September 2010 - 01:36 AM in General Discussion

Never heard of them, but considering I've never soldered either its understandable that it looks like a great product to me :)



#1968 FEZ Panda

Posted by Ravenheart on 08 September 2010 - 10:30 PM in General Discussion

You can flash it with whatever firmware you want, you can even use it as an ARM7 devboard. Do note that once you remove the GHI BootLoader(if you want to use your own NETMF firmware or native ARM7 code) you will not be able to flash back on the GHI firmware.



#1959 FEZ Panda

Posted by Ravenheart on 08 September 2010 - 07:55 PM in General Discussion

The nice thing is GHI allow you to make it into an ARM7 devboard or you can flash it with your own NETMF firmware. Oh and its killer at its current 20 USD price :)



#1945 Arduino or Netduino

Posted by Ravenheart on 08 September 2010 - 05:10 PM in General Discussion

The way you should look at it is this, if you want to flash LEDs super fast get an Arduino, if you want to more easily develop your applications then get a NETMF device. The only really big disadvantage that NETMF has is that its not real-time and because its interpreted its slower than native code. On the plus side, NETMF uses VisualStudio for its IDE, debugging is a breeze and if you have no experience with embedded devices, NETMF is MUCH more user friendly(and we get meaningful error descriptions when compiling). Personally I have a FEZ Domino and a FEZ Panda(Arduino layout compatible with 60 pins) on the way from TinyCLR.com




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.