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.

jrlyman3

Member Since 09 Mar 2013
Offline Last Active Aug 17 2014 11:47 PM
-----

Posts I've Made

In Topic: Powering the Netduino model 1

12 August 2014 - 02:29 AM

The specifications (http://www.netduino....duino/specs.htm) say 7.5 - 12 volts on the power connector (as opposed to the USB connector).

 

I usually run them at 9 volts.

 

3.7 * 2 = 7.4 which is a little short but it might work.


In Topic: Trying to recreate Arduino Code for Netduino, running into issues.

11 August 2014 - 02:31 AM

I took a quick look and I think that you're missing:

        

IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, port);

 

before listener.Bind(localEndPoint);

 

Also, you should use listener.RecieveFrom() which will receive the data and tell you who it came from.  This works best with UDP since you can receive data from multiple hosts on the same socket (no connection).

 

John


In Topic: Setting DHCP client ID on Netduino Plus 2

04 August 2014 - 02:15 AM

I believe the the Client ID (DUID) is an option and not part of the main DHCP header.  My guess is that you're right and it's not being send by the .NETMF client.  I couldn't find any documentation that says whether it is supported or not.  Let us know what you find out with WireShark.

 

John


In Topic: LiquidCrystal for netduino

29 July 2014 - 03:07 AM

I haven't wired up my 20x2 display yet, but as near as I can tell your wiring looks good.  When I started with my 20x4 display I didn't get anything because I didn't know that I needed to hook up the contrast, it looks like you've got that covered.

 

Looking at your code it looks good too.  One thing that I do differently is to call Clear() and SetCursorPosition(0, 0) after the Begin() call.  It shouldn't matter since Begin() calls Clear() itself, but I can't see any other issues.

 

Check that all of your connections are good.  Maybe it's a bad display ... it happens.  Try hooking up the back light I'm using a 39 ohm resistor between pin15 and +5, pin16 to ground.

 

John


In Topic: NETMF SerialPort and "BreakState"

20 July 2014 - 03:14 PM

I thought that I ported this, but it wasn't me.  This code uses interrupts and seems to be fairly accurate if I remember correctly.   One thing that I changed was the SecretLabs.NETFM.Hardware.Netduino using statement since I'm using a Netduino Plus.  Enjoy.

 

John

 

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

namespace HC_SR04
{
    /// <summary>
    /// Class for controlling the HC-SR04 Ultrasonic Range detector
    /// Written by John E. Wilson
    /// Version 1.1 - 2012/04/03 - Corrected constructor pin documentation
    /// Free to use, please attribute credit
    /// </summary>
    public class HC_SR04
    {
        private OutputPort portOut;
        private InterruptPort interIn;
        private long beginTick;
        private long endTick;
        private long minTicks;  // System latency, subtracted off ticks to find actual sound travel time
        private double inchConversion;
        private double version;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="pinTrig">Netduino pin connected to the HC-SR04 Trig pin</param>
        /// <param name="pinEcho">Netduino pin connected to the HC-SR04 Echo pin</param>
        public HC_SR04(Cpu.Pin pinTrig, Cpu.Pin pinEcho)
        {
            portOut = new OutputPort(pinTrig, false);
            interIn = new InterruptPort(pinEcho, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);
            interIn.OnInterrupt += new NativeEventHandler(interIn_OnInterrupt);
            minTicks = 6200L;
            inchConversion = 1440.0;
            version = 1.1;
        }

        /// <summary>
        /// Returns the library version number
        /// </summary>
        public double Version
        {
            get
            {
                return version;
            }
        }

        /// <summary>
        /// Trigger a sensor reading
        /// Convert ticks to distance using TicksToInches below
        /// </summary>
        /// <returns>Number of ticks it takes to get back sonic pulse</returns>
        public long Ping()
        {
            // Reset Sensor
            portOut.Write(true);
            Thread.Sleep(1);

            // Start Clock
            endTick = 0L;
            beginTick = System.DateTime.Now.Ticks;
            // Trigger Sonic Pulse
            portOut.Write(false);

            // Wait 1/20 second (this could be set as a variable instead of constant)
            Thread.Sleep(50);

            if (endTick > 0L)
            {
                // Calculate Difference
                long elapsed = endTick - beginTick;

                // Subtract out fixed overhead (interrupt lag, etc.)
                elapsed -= minTicks;
                if (elapsed < 0L)
                {
                    elapsed = 0L;
                }

                // Return elapsed ticks
                return elapsed;
            }

            // Sonic pulse wasn't detected within 1/20 second
            return -1L;
        }

        /// <summary>
        /// This interrupt will trigger when detector receives back reflected sonic pulse      
        /// </summary>
        /// <param name="data1">Not used</param>
        /// <param name="data2">Not used</param>
        /// <param name="time">Transfer to endTick to calculated sound pulse travel time</param>
        void interIn_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            // Save the ticks when pulse was received back
            endTick = time.Ticks;
        }

        /// <summary>
        /// Convert ticks to inches
        /// </summary>
        /// <param name="ticks"></param>
        /// <returns></returns>
        public double TicksToInches(long ticks)
        {
            return (double)ticks / inchConversion;
        }

        /// <summary>
        /// The ticks to inches conversion factor
        /// </summary>
        public double InchCoversionFactor
        {
            get
            {
                return inchConversion;
            }
            set
            {
                inchConversion = value;
            }
        }

        /// <summary>
        /// The system latency (minimum number of ticks)
        /// This number will be subtracted off to find actual sound travel time
        /// </summary>
        public long LatencyTicks
        {
            get
            {
                return minTicks;
            }
            set
            {
                minTicks = value;
            }
        }
    }

    public class Program
    {
        public static void Main()
        {
            HC_SR04 sensor = new HC_SR04(Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D7);

            while (true)
            {
                long ticks = sensor.Ping();
                if (ticks > 0L)
                {
                    double inches = sensor.TicksToInches(ticks);
                }
            }
        }
    }
}


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.