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.

Ferocildo

Member Since 07 Mar 2012
Offline Last Active May 23 2014 12:18 PM
-----

Posts I've Made

In Topic: SD Card create directory

30 August 2012 - 09:38 AM

the following code create all directories but the last! why?

using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
//using LoveElectronics.Sensors.Accelerometers;

namespace ADXL345_test
{
    public class Program
    {
        private static StreamWriter sw;
        private static FileStream fs;

        public static void Main()
        {
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            InputPort Switch1 = new InputPort(Pins.ONBOARD_SW1, true, Port.ResistorMode.Disabled);

            while (!Switch1.Read())
            {}

            led.Write(true);

            Directory.CreateDirectory(@"SD\Netduino");

            fs = new FileStream(@"SD\Netduino\test.txt", FileMode.Create, FileAccess.Write, FileShare.None, 512);

            Directory.CreateDirectory(@"SD\Netduino1");

            sw = new StreamWriter(fs);

            Directory.CreateDirectory(@"\SD\Netduino2");
            sw.WriteLine("test");

            Directory.CreateDirectory(@"\SD\Netduino3");
            sw.Close();

            Directory.CreateDirectory(@"\SD\Netduino4");
            fs.Close();

            Directory.CreateDirectory(@"\SD\Netduino5");

        }

    }
}

In Topic: SD card write times

30 August 2012 - 09:35 AM

Well, The problem was the FAT file system ( default windows formatting ). Using FAT32 I could write thousands of file on the same directory.. however writing times degrade with increasing number of files on the same directory

In Topic: I2C and ADXL345 maxing sample rate

22 August 2012 - 05:35 PM

@Bendage

Here: https://www.loveelec...how-to-use-them

you can find anything you need to get ADXL345 working.

Anyway, to reach 1 KHz sampling rates I made some tweaks



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

namespace ADXL345_test
{
    public class Program
    {
        private const int nSamples = 2048;

        private static byte[] bufArray = new byte[nSamples * 6];
        private static byte[] buffer = new byte[6];
        private static byte[] addrbuffer = new byte[] { 0x32 };

        private static I2CDevice.I2CTransaction[] transaction = new I2CDevice.I2CTransaction[]
            {
                I2CDevice.CreateWriteTransaction(addrbuffer),
                I2CDevice.CreateReadTransaction(buffer)
            };

        public static void Main()
        {
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

            ADXL345 accel = new ADXL345();
            // Ensure that we are connected to the accel
            // (this will throw an exception if the accel does not respond).
            if (accel.EnsureConnected())
            {
                Debug.Print("ADXL345 was found!");
            }

            // Tell the accel we are interested in a range of +/- 2g.
            accel.Range = 2;
            // Tell the accel we want it to use full resolution.
            accel.FullResolution = true;
            // Enable the measurements on the device.
            accel.EnableMeasurements();
            // Set the data rate to output at 3200Hz
            accel.SetDataRate(0x0F);
            
            while (true)
            {

                for (int i = 0; i < nSamples; i++)
                {
                    // Get the newest data from the accelerometer.
                    // Manually getting readings instead of accel.ReadAllAxis()
                    // bufArray contains x, y and z packed on 6 bytes

                    accel.Execute(transaction, 1000);
                    buffer.CopyTo(bufArray, i * 6);


                }
             

            }
        
        }

    }
}

In Topic: Powering through 3.3V

16 August 2012 - 02:44 PM

Hi Chris, I connect the N+ to a board that supply 24V and 3.3V so I can't give 5V or 12V ( for the Vin ) to N+. The 3.3V should be able to give 400 mA.

In Topic: SD Card create directory

26 June 2012 - 12:31 PM

I just tried the Directory.CreateDirectory(@"\SD\Netduino"); line code alone, but nothing happens. I've also tried formatting by Windows7 with FAT32 my 2GB SD card. Maybe I'll try buying another sd card, however writing of files is working, so that's strange

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.