Problem with GHIElectronics.NETMF.System

Hi I have a Problem with my Hydra. I will use the MathEx Library from GHI. But When I include the library in my Project I get this Error:

“System.Exception” in Microsoft.SPOT.Hardware.dll "

the Same on my Panda2 works fine! What make I wrong so that I don´t can use this? Is there an other
math library with sin,cos,tan,asin,acos,atan…

thanks for your Help

Here my code:


       using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;


using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using GHIElectronics.OSH.NETMF.Hardware;
using GHIElectronics.NETMF.System;
using MSpot = Microsoft.SPOT.Hardware;
using Gadgeteer.Modules.GHIElectronics;

namespace GadgeteerApp3
{
    public partial class Program
    {

        
        public static MSpot.OutputPort output = new MSpot.OutputPort((MSpot.Cpu.Pin)FEZHydra.Pin.PD11,false);
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
          
            /*******************************************************************************************
            Modules added in the Program.gadgeteer designer view are used by typing 
            their name followed by a period, e.g.  button.  or  camera.
            
            Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
                button.ButtonPressed +=<tab><tab>
            
            If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
                GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
                timer.Tick +=<tab><tab>
                timer.Start();
            *******************************************************************************************/
            button.ButtonPressed += new Gadgeteer.Modules.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);

            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");
          
        }

        void button_ButtonPressed(Gadgeteer.Modules.GHIElectronics.Button sender, Gadgeteer.Modules.GHIElectronics.Button.ButtonState state)
        {
            while (button.IsPressed)
            {
                double d1 = MathEx.Sin(123.543);
                double d2 = (234.123 + MathEx.Sqrt(12342.23 - 4 * 123.123 * 123.12)) / 123.23;
                double d3 = (234.123 + MathEx.Sqrt(12342.23 - 4 * 123.123 * 123.12)) / 123.23;
                double d5 = (234.123 + MathEx.Sqrt(12342.23 - 4 * 123.123 * 123.12)) / 123.23;
  
                output.Write(false);
                output.Write(true);
                
            }
        }
    }
}

On which line are you getting the exception? When you press the button?

Please show all the exception info from the Output window.

Is not available on Hydra

You can not mix OSH and proprietary GHI libraries.

Will have to use the System.Math class for math stuff.

Is There a other Math class than System.Math?
The System.Math class don´t have cos,sin,tan,atan,acos,asin…

@ Mike the Error comes direct after the compiling when the Program starts

Check this one out:

http://code.tinyclr.com/project/152/cossin-implementation/

Checkout

http://www.microframework.nl/2009/01/15/math-library-compatible-with-full-net/

Although I heard somewhere that the next version of micro .net will include more math functions.

There is also a basic Cos and Sin methods available in the Microsoft.SPOT.Math namespace, but are very basic and inaccurate.

Cheers

John.

There is apparently an issue with the ElzeKool math lib that someone here has posted about in the past when using it with GPS calculations, so you might do a quick search here if you wanted to use it.

You may want to check out my version of Elze’s → Fabien’s → Ian’s version of MathEx here… I haven’t noticed any problems with Sin & Cos. Maybe Fabien fixed those. I did find a problem with Atan2 and fixed it.

http://netmfx.codeplex.com/SourceControl/changeset/view/11623#112181

I’m thinking of creating an RLP image to run these, do you think there would be a great performance increase in doing so?

Do you think it’ll be worth it?

I think you will see noticeable improvement in performance vs managed implementation. I’d say go for it. It would make a nice contribution on the code site.

Worth it yea. It will be interesting to see how they compare to the “native” versions that will be included in NETMF 4.2 coming soon.

Cool, ill take a look and keep you all updated.

Chris & I fixed that last year when he was working on his rover. The issue was it had a less that accurate representation of Pi which caused issues on several functions. I believe ElzeKool did update the lib with our fixes so you should be all good.

If you do find an issue just check the value of Pi first. :wink: