Dan T - Viewing Profile: Likes - 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.

Dan T

Member Since 12 Jan 2011
Offline Last Active May 06 2017 01:34 PM
*****

#50938 Simple sine table

Posted by Dan T on 29 June 2013 - 06:13 PM

I found an impurity that I could not let stand.

 

The mirroring duplicates samples that shouldn't be duplicated.  It is most egregious at the zero crossing -- a double sample of zero right where the sine should be most linear.

 

The fix is elegant.  I just extended the dataset by 1 sample to be endpoint INCLUSIVE, then handled the mirroring asymmetrically to avoid duplicates.  It actually cleans up the mirroring code, I think:

    // Below, endpoint asymmetry assures non-overlapping quadrants    if (index < quadLen) return _sin[index]; // 1st quadrant     index -= quadLen;    if (index < quadLen) return _sin[quadLen - index]; // 2nd quadrant    index -= quadLen;    if (index < quadLen) return -_sin[index]; // 3rd quadrant     index -= quadLen;    return -_sin[quadLen - index]; // 4th quadrant 

I also made these changes:

1) Added two public constructors, one for default sine wave and one for arbitrary phase (in radians).

2) Replaced your bitwise AND with more general modulo (%, aka "remainder"), required for next item.

3) Refactored the byte array length to be arbitrary. Just change variable quadLen to any integer and the sine data will be stored in quadLen+1 bytes.  I'm using quadLen=32 for my tiny AGENT screen.

using System;using Microsoft.SPOT;namespace AgentWatchSineWaves{    // Simple 8-bit sine table    // Adapted From http://forums.netduino.com/index.php?/topic/9115-simple-sine-table/    //    public class SineTable    {        const double Tau = 2.0 * System.Math.PI; // http://tauday.com/tau-manifesto 6.283185307179586476925286766559 ...        const int quadLen = 32; // A quandrant is one quarter length of a full period        const double amplitude = Byte.MaxValue; // Maximum byte value is 255 (byte is unsigned)        public static readonly SineTable Sin = new SineTable();        public static readonly SineTable Cos = new SineTable(Tau / 4.0);        private static byte[] _sin;        private int _offset;        public SineTable()        {            if (_sin == null) // one-time initialization            {                _sin = new byte[quadLen + 1]; // From 0 to quadLen INCLUSIVE                double a = 0; // Angle in radians                // Tau (one period) = 4 quadrants                double da = Tau / (4.0 * quadLen); // 1st quadrant (0...Tau/4)                 for (int i = 0; i < _sin.Length; i++, a += da)                    _sin[i] = (byte)(amplitude * System.Math.Sin(a));            }        }        public SineTable(double phaseInRadians) : this()        {            phaseInRadians %= Tau; // Normalize to ±1 cycle            if (phaseInRadians < 0.0) phaseInRadians += Tau; // Equivalent positive angle            _offset = (int)(phaseInRadians/Tau * 4 * quadLen);        }        public int this[int index]        {            get            {                index += _offset;                index %= 4 * quadLen; // Modulo limits index to 4 quadrants                // Below, endpoint asymmetry assures non-overlapping quadrants                if (index < quadLen) return _sin[index]; // 1st quadrant                 index -= quadLen;                if (index < quadLen) return _sin[quadLen - index]; // 2nd quadrant                index -= quadLen;                if (index < quadLen) return -_sin[index]; // 3rd quadrant                 index -= quadLen;                return -_sin[quadLen - index]; // 4th quadrant             }        }    }}



#47668 Does the .NETMF really need 600k of space, or am I reading the datasheet inco...

Posted by Dan T on 28 March 2013 - 02:50 AM

And from another perspective...

 

Can .NET really fit into only 600k?  (Or 256k!)

 

The .NET 4.5 Framework takes 38.8MB on my PC. :rolleyes:




#43636 Service note: updates to forums

Posted by Dan T on 18 January 2013 - 02:26 AM

We will be adding the standard netduino.com header and footer within the next week.  We wanted to make sure that the update went well first.  With the exception of a few browser issues (which should be fixed through browser updates or forums software updates by Invision Power) and one or two permission issues, it seems to be working well so far.  Crossing fingers :)

 

Chris

 

While this isn't the highest priority for you guys <*cough* go *cough* ethernet *cough* module>, it would be nice to know I'm on a Netduino Forum when I'm on the Netduino Forum.  I'm easily confused, you know.




#19671 Netduino Plus Software Architecture and Tools

Posted by Dan T on 24 October 2011 - 01:52 AM

After loading new firmware, you must use MFDeploy's Network Config window to reprogram the MAC address.


Note: Chris Walker says he's going to fix that. :) But he's been saying that for a long time. :angry: Maybe he can't figure out how? :blink:


#19669 Netduino Plus Software Architecture and Tools

Posted by Dan T on 24 October 2011 - 01:39 AM

I'll take a stab at this. It's a good way to learn. I'll correct/update as I learn more:

I want to understand what is the software technology stack of Netduino Plus?

At the bottom of the stack, you can program the ARM7 microprocessor with C++. This is called "native" programming because it works on the native hardware without an abstraction layer, aka "bare metal".
The bootloader is an example of native code. It performs the basic communication tasks with the outside world so programming the Flash memory with additional new firmware is easier.
NetduinoPlus firmware is also native code. It is the software that implements .NET MF on the Arm7 and also implements the NetduinoPlus-specific features, like the networking stack, SD card access, LED, etc.
Once this firmware is loaded, you can finally add the top layer: Application code written in .NET (C# or VB.NET).

I would also like to know how does my .NET Application actually run on this device?

I'm a little fuzzy on this one. I know .NET code is NOT compiled down to machine language. (Native code is, btw.) Instead, it compiles down to Common Language Runtime code. On the desktop "full" version of .NET, I think this CLR stuff is JIT-compiled. But with .NETMF, this CLR stuff is interpreted -- part of the .NETMF firmware is interpreting the intermediate byte codes on the fly. I think the intermediate code is placed in a file with a .pe extension.

What is the role of components like ER_FLASH, TinyBooterDecompressor etc.?

See above. The ER_FLASH file *is* the firmware load file. TinyBooter is the resident program that helps load firmware.

What is the address range of various things in memory for each such component?

Don't know.

What is the use of MFDeploy?

MFDeploy is a application that runs on the PC and knows how to talk to the Netduino. It includes lots of diagnostic stuff like "Device Configuration" and memory maps. It is the tool you use to load new firmware. After loading new firmware, you must use MFDeploy's Network Config window to reprogram the MAC address. (See the sticker on the bottom of your Netduino.) Basically, MFDeploy does EVERYTHING except load/debug your user code. (Actually, it can do some debugging. It's a super-tool!)

Why do we need Porting Kit?

You don't need the Porting Kit. Unless you want to be a hotshot and compile your own custom firmware. Then you do. The Porting Kit is the [native] source code for .NETMF and some extra stuff to help the hotshots craft a custom implementation. It's called a porting "kit" because it is NOT ready-to-go on Netduino or even on ARM7. It is the stuff you'd need to do-it-yourself. Netduino firmware is built on the foundation provided by the Porting Kit. 99.9% of us do not need to know about anything about it.

Who owns TinyBooterDecompressor and from where we can get its updates and archives?

Secretlabs writes it and we all "own" it because it's open source. The latest firmware release also includes TinyBooterDecompressor.bin in the .zip file. The source code for all the pieces is including further down in the firmware thread as (See SourceCode_Netduino_AllEditions_4.2.0.0_RC3.zip)

How can I know what version of TinyBooterDecompressor is thereon my Netduino Plus?

Good question. This wiki page tells you how to check AFTER you've loaded it. :( (But before you've loaded the firmware.)


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.