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.

CarTech

Member Since 18 Jun 2011
Offline Last Active Jul 07 2012 06:05 PM
-----

Topics I've Started

Native code lighter on memory?

06 March 2012 - 10:00 PM

I'm using a netduino in a data logging application. I've integrated a GS1011 wifi board, GPS, accelerometer, Gyroscope, Compass, and OBDII/CAN to talk to my car. With all of these devices logging data to an SD buffer, memory is tight. If I try to post via the wifi connection, I run out of memory. I think I've optimized about as much as I can within reason. I understand that native code will run much faster and is useful for time-sensitive applications. This might be a dumb questions, but can I expect to see significantly less memory use if implement some drivers for the these devices in native and then call them from managed code?

Reference for System.Uri?

29 November 2011 - 04:40 PM

I can't figure out which reference I need to use the System.Uri class. Opening a fresh project, I get this error message: type or namespace name "Uri" could not be found (are you missing an assembly reference?) error when I try something like the following.

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace TestingUri
{
    public class Program
    {
        public static void Main()
        {
            // write your code here
            Uri myUri = new Uri("http:\\www.google.com");
            
        }

    }
}


Timer only executes five times?

25 October 2011 - 02:14 AM

Please be kind as I'm a mechanical engineer during the day learning both C# and the netduino as a hobby. :D

I'm using an ADXL345 accelerometer connected to the netduino via I2C. I've attached the class for the accelerometer which I got almost directly from LoveElectronics ADXL345 Library & Tutorial. This code works very nicely.

Unfortunately the sensor stick from SparkFun, which I have, doesn't have the interrupts on the ADXL345 broken out. Thus, I've resorted to polling the ADXL345 with a timer.

The problem I'm having is that the timer only executes five times. If I change the time interval (tried 8ms and 800ms), it still only runs five times. Here's the problematic code:

using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace Testing9DOF
{
    public class BufferFileManager
    {
        // Constructor
        public BufferFileManager()
        {
            Debug.Print("Created a new BufferFileMananger instance");
        }

        // Public methods
        public void StartDAQ()
        {
            // Start up sensor class
            ADXL345 myAccel = new ADXL345();
            myAccel.CheckConnection();
            myAccel.FullResolution = true;
            myAccel.EnableMeasurements();
            myAccel.SetDataRate(0x08);

            // Start collecting data to file
            Timer timer = new Timer(delegate(object o)
                {
                    myAccel.ReadAllAxes();
                    string data = myAccel.ScaledXAxisG + "\t" + myAccel.ScaledYAxisG + "\t" + myAccel.ScaledZAxisG;
                    Debug.Print(data);
                }, null, 0, 80);
        }
    }

    public class Program
    {         
        public static void Main()
        {
            BufferFileManager fm = new BufferFileManager();
            fm.StartDAQ();

            Thread.Sleep(Timeout.Infinite);
        }
    }
}

Now, if put everything in the Main class, it works fine:

using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace Testing9DOF
{
    public class Program
    {         
        public static void Main()
        {
            ADXL345 myAccel = new ADXL345();
            myAccel.CheckConnection();
            myAccel.FullResolution = true;
            myAccel.EnableMeasurements();
            myAccel.SetDataRate(0x08);

            // Start collecting data to file
            Timer timer = new Timer(delegate(object o)
            {
                myAccel.ReadAllAxes();
                string data = myAccel.ScaledXAxisG + "\t" + myAccel.ScaledYAxisG + "\t" + myAccel.ScaledZAxisG;
                Debug.Print(data);
            }, null, 0, 80);

            Thread.Sleep(Timeout.Infinite);
        }
    }
}

Not really sure what's going on. I'm guessing it's something to do with how I've attempted to put it in a second class? Any ideas?

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.