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.

afulki's Content

There have been 13 items by afulki (Search limited from 20-April 23)


By content type

See this member's

Sort by                Order  

#14200 OK this is not Netduino, but it could be!

Posted by afulki on 10 June 2011 - 01:09 PM in Project Showcase

Very cute..



#14076 40% discount on Netduino Plus e-book (O'Reilly / MAKE)

Posted by afulki on 08 June 2011 - 10:31 AM in Netduino Plus 2 (and Netduino Plus 1)

To celebrate the release of the new "Getting Started with the Internet of Things" (using Netduino Plus)...

Here's an exclusive coupon for 40% off the e-book ($11.99 instead of $19.99)!

http://oreilly.com/c...g/0636920013037
Coupon code: NETD4 (enter in shopping cart at checkout)

If you have a Netduino Plus, this is a good resource for all-things-Internet. IMHO, $11.99 for a DRM-free e-book (PDF, ePub, Mobi) is a pretty sweet deal.

Chris


Thanks! Bought, downloaded, reading :D



#13586 From netduino to commercial

Posted by afulki on 24 May 2011 - 01:36 PM in Netduino 2 (and Netduino 1)

How about adding an example of doing this to the Wiki? I for one would appreciate it.



#13093 RVDS Online Compiler

Posted by afulki on 10 May 2011 - 02:46 PM in General Discussion

Hello Gary,

I don't speak about managed code (C#, VS is perfect), but for native code ( C ),
For native code you have choice between GNU, RVDS, or others expensive compiler,
This is to rebuild NETMF firmware,
GNU produced firmware is to big to fit flash memory, especialy for Netduino Plus,
And RVDS cost multiple thousands of dollars !!!
So, a online compiler like mbed could be a great alternative for netduino user,

Pascal


Ah, that makes more sense :)



#13088 RVDS Online Compiler

Posted by afulki on 10 May 2011 - 02:11 PM in General Discussion

Hello,

I discover that mbed provide a online compiler compliant to RVDS 4.1 for users:
http://mbed.org/handbook/mbed-Compiler

What about this facility for Netduino users who wants to compile NETMF kit ?

rgds,


I looked at the mbed before I chose the Netduino, but why would you want to program online when you can download visual studio express for free?

While I can see the benefit for mac users (I'm one), losing the ease and ability of visual studio, especially the debugging to use an online tool would defeat the purpose of programming for the Netduino. I use parallels and win7 under OSX, works great (though I'd love the netduino to talk to processing running on OSX of course ;) )

Gary



#12793 .NET Gadgeteer availibility

Posted by afulki on 03 May 2011 - 05:28 PM in General Discussion

Consider my hand raised too! Sounds very interesting :)



#12755 Parallax Ping))) Ultrasonic Sensor

Posted by afulki on 02 May 2011 - 05:43 PM in Project Showcase

More example code using the above class, traffic lights based on distance.

    public class Program
    {
        private static OutputPort _yellow = new OutputPort(Pins.GPIO_PIN_D6, false);
        private static OutputPort _red = new OutputPort(Pins.GPIO_PIN_D5, false);
        private static OutputPort _green = new OutputPort(Pins.GPIO_PIN_D7, false);

        public static void Main()
        {
            Ping ping = new Ping(Pins.GPIO_PIN_D2, 1000, true);
            ping.RangeEvent += new Ping.RangeTakenDelegate(ping_RangeEvent);

            // Sleep forever!
            Thread.Sleep(Timeout.Infinite);
        }

        static void ping_RangeEvent(object sender, PingEventArgs e)
        {
            Debug.Print("Range: " +  e.Distance + " cm");

            _yellow.Write(e.Distance > 50 && e.Distance < 100);
            _red.Write(e.Distance < 50);
            _green.Write(e.Distance > 100);
        }
    }




#12750 Website

Posted by afulki on 02 May 2011 - 02:52 PM in General Discussion

Hi afulki,


Sorry, that's an error on our part. We'll get those synced up.


We'll add a new hardware page (with links to all three Netduinos). Thansk for bringing this up.

Chris


Thanks Chris,

hope it didn't come across as complaints, love what you are doing here and hope to be a big contributor in the future (already posted my first code, more in the works).

The lack of links in the hardware page probably were hurting sales though, as I would have bought the plus rather than the standard if it had been available (I since found it on Amazon).



#12683 Website

Posted by afulki on 30 April 2011 - 11:56 AM in General Discussion

A few questions:

  • Featured project link on the front page takes you to the projects page, but the featured project is not listed.
  • Hardware link only shows the original netduino not the mini or plus

Ok so not so much questions as comments :)



#12399 XBee/Zigbee wireless, where to start?

Posted by afulki on 22 April 2011 - 11:53 AM in Netduino 2 (and Netduino 1)

I believe there is a board that the xbee can plug into that converts the pin spacing to the default breadboard sizes, pretty sure I saw it on spark fun.

Here



#12396 Wireless sensors using netduino, ioBridge and ThingSpeak

Posted by afulki on 22 April 2011 - 11:02 AM in Project Showcase

Nice article, I've been looking at the xbees and had no idea the were so simple.



#12369 Parallax Ping))) Ultrasonic Sensor

Posted by afulki on 21 April 2011 - 08:23 PM in Project Showcase

Played around with the Ping))) sensor, came up with the following code. It uses a timer to initiate the sensor reads, and an event to report to the main application. Period and Enable / Disable are supported. I attached a zip with the project.

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace ParallaxSensors
{
    /*******************************************************************
     * Reference the following DLLs
     *  - Microsoft.SPOT.Hardware
     *  - Microsoft.SPOT.Native
     *  - SecretLabs.NETMF.Hardware
     *  - SecretLabs.NETMF.Hardware.Netduino
     ******************************************************************/

    /// <summary>
    /// Holds the distance information for the event
    /// </summary>
    public class PingEventArgs
    {
        public PingEventArgs(int distance)
        {
            Distance = distance;
        }

        public int Distance { get; set; }
    }

    /// <summary>
    /// Implements a timer based distance measurement of distance (in cm) using the
    /// parallax Ping sensor
    /// 
    /// Example usage:
    /// public static void Main()
    /// {
    ///     Ping ping = new Ping(Pins.GPIO_PIN_D2, 1000, true);
    ///     ping.RangeEvent += new Ping.RangeTakenDelegate(ping_RangeEvent);
    ///
    ///     // Sleep forever!
    ///     Thread.Sleep(Timeout.Infinite);
    /// }
    ///
    /// static void ping_RangeEvent(object sender, PingEventArgs e)
    /// {
    ///     Debug.Print("Range: " +  e.Distance + " cm");
    /// }
    /// </summary>
    public class Ping
    {
        public delegate void RangeTakenDelegate(object sender, PingEventArgs e);
        public event RangeTakenDelegate RangeEvent;

        private TristatePort _port;
        private ExtendedTimer _timer;
        private int _period;
        private bool _enabled;

        /// <summary>
        /// Constructor: initializes the Ping class
        /// </summary>
        /// <param name="pin">which pin the sensor is connected to</param>
        /// <param name="period">time between pulses in millisec, minimum of 1000</param>
        /// <param name="enabled">if true, start pinging immediately, otherwise wait for enable</param>
        public Ping(Cpu.Pin pin, int period, bool enabled)
        {
            _port = new TristatePort(pin, false, false, ResistorModes.Disabled);

            // Initially set as disabled.
            _timer = new ExtendedTimer(TakeMeasurement, null, Timeout.Infinite, period);

            // Store the current period
            Period = period;

            // Set the enabled state
            Enabled = enabled;
        }

        /// <summary>
        /// Enable or disable the timer that triggers the read.
        /// </summary>
        public bool Enabled
        {
            get { return _enabled; }
            set
            {
                _enabled = value;

                _timer.Change((_enabled) ? 0 : Timeout.Infinite, Period);
            }
        }

        /// <summary>
        /// Set the period of pings, min is 1000ms
        /// </summary>
        public int Period
        {
            get { return _period; }
            set
            {
                _period = value;
                if (_period < 1000)
                    _period = 1000;

                // Set enabled to the current value to force update
                Enabled = _enabled;
            }
        }

        /// <summary>
        /// Get distance in cm
        /// </summary>
        /// <returns>distance in cm, based on wikipedia for dry air at 20C</returns>
        private int GetDistance()
        {

            // First we need to pulse the port from high to low.
            _port.Active = true; // Put port in write mode
            _port.Write(true);   // Pulse pin
            _port.Write(false);
            _port.Active = false;// Put port in read mode;    

            bool lineState = false;

            // Wait for the line to go high, for start of pulse.
            while (lineState == false)
                lineState = _port.Read();

            long startOfPulseAt = System.DateTime.Now.Ticks;      // Save start ticks.

            // Wait for line to go low.
            while (lineState)
                lineState = _port.Read();

            long endOfPulse = System.DateTime.Now.Ticks;          // Save end ticks. 

            int ticks = (int)(endOfPulse - startOfPulseAt);

            return ticks / 580;
        }

        /// <summary>
        /// Initiates the pulse, and triggers the event
        /// </summary>
        /// <param name="stateInfo"></param>
        private void TakeMeasurement(Object stateInfo)
        {
            int distance = GetDistance();

            if (RangeEvent != null)
            {
                RangeEvent(this, new PingEventArgs(distance));
            }
        }
    }
}

Attached Files

  • Attached File  Ping.zip   3.02KB   127 downloads



#12304 Parallax RFID Reader

Posted by afulki on 21 April 2011 - 01:04 AM in Project Showcase

I'm another newbie to the netduino family, though I've been programing C# and .Net since around day 1 :)

Thanks to the author of the original post in this article it was a nice introduction to RFID, and all the comments above mine, they were most insightful.

I was playing around with the code this evening and the timeout error displayed in the debugger output window annoyed me, so I refactored the code a little and below is my version of the class. It does not use any timers to flush the receive buffer etc. and does not cause the timeout messages to be display.

public class ParalaxRFID
    {
        private int _readDelay = 1500;
        private bool _readerEnabled = false;

        public SerialPort SerialPort { get; set; }
        public OutputPort RfidControl { get; set; }

        public delegate void CardReadEventHandler(ParalaxRFID sender, string cardID);
        public event CardReadEventHandler OnCardRead;

        public delegate void StatusChangedEventHandler(ParalaxRFID sender, bool readerEnabled);
        public event StatusChangedEventHandler OnStatusChanged;

        private byte[] _messageBuffer = new byte[10];
        private int _messageCounter = -1; // -1 = waiting for start char, 0 or more means reading message

        public int ReadDelay
        {
            get { return _readDelay; }
            set { _readDelay = value; }
        }

        public bool ReaderEnabled
        {
            get { return _readerEnabled; }
            private set 
            { 
                _readerEnabled = value;
                if (OnStatusChanged != null)
                {
                    OnStatusChanged(this, value);
                }
            }
        }
        
        public ParalaxRFID(string portName, Cpu.Pin controlPin, bool autoEnable = true)
            : this(new SerialPort(portName, 2400, Parity.None, 8, StopBits.One), new OutputPort(controlPin, false), autoEnable)
        {
        }

        public ParalaxRFID(SerialPort sPort, OutputPort rfidControl, bool autoEnable = true)
        {
            this.SerialPort = sPort;
            this.RfidControl = rfidControl;

            SerialPort.WriteTimeout = 1000;

            SerialPort.Open();
            SerialPort.DataReceived += new SerialDataReceivedEventHandler(SerialPort_DataReceived);
            
            if (autoEnable) EnableReader();
        }

        public void DisableReader()
        {
            RfidControl.Write(true);
            if (SerialPort.IsOpen) SerialPort.Close();
            ReaderEnabled = false;
        }

        public void EnableReader()
        {
            if (!SerialPort.IsOpen) SerialPort.Open();
            RfidControl.Write(false);
            ReaderEnabled = true;
        }

        private void DoReadDelay()
        {
            if (ReaderEnabled)
            {
                DisableReader();
                Thread.Sleep(ReadDelay);
                EnableReader();
            }
        }


        void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort sp = (SerialPort)sender; 

            while (sp.BytesToRead > 0)
            {
                // temp buff to hold message,
                byte[] buf = new byte[1];

                // Read a single byte from the recv buffer,
                if (sp.Read(buf, 0, 1) > 0)
                {
                    // Start of Message?
                    if (buf[0] == '\n') 
                    {
                        _messageCounter = 0;
                    }
                    // End of message?
                    else if (buf[0] == '\r')
                    {
                        if (_messageCounter > 9)
                        {
                            String cardID = String.Empty;
                            for (int i = 0; i < 10; i++)
                            {
                                cardID += (char)_messageBuffer[i];
                            }

                            if (OnCardRead != null)
                            {
                                OnCardRead(this, cardID);
                            }
                        }

                        _messageCounter = -1;
                        DoReadDelay();
                    }
                    else // Store it in the global buffer, 
                    {
                        if (_messageCounter < 10)
                        {
                            _messageBuffer[_messageCounter++] = buf[0];
                        }
                        else
                            _messageCounter = -1;
                    }
                }
            }
        }
    }




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.