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.

EnergySmithe

Member Since 30 Dec 2012
Offline Last Active Aug 11 2014 04:12 PM
-----

Posts I've Made

In Topic: Multiple InterruptPorts being fired?

15 July 2014 - 07:17 AM

  Sure, here is test code I was playing with:

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.Netduino;

namespace SwitchDemo
{
    public class Program
    {
        // take care of initializing relay that is connected...
        OutputPort r0 = new OutputPort(Pins.GPIO_PIN_D0, true);
        OutputPort r1 = new OutputPort(Pins.GPIO_PIN_D1, true);
        OutputPort r2 = new OutputPort(Pins.GPIO_PIN_D2, true);
        OutputPort r3 = new OutputPort(Pins.GPIO_PIN_D3, true);
        OutputPort r4 = new OutputPort(Pins.GPIO_PIN_D4, true);
        OutputPort r5 = new OutputPort(Pins.GPIO_PIN_D5, true);
        OutputPort r6 = new OutputPort(Pins.GPIO_PIN_D6, true);
        OutputPort r7 = new OutputPort(Pins.GPIO_PIN_D7, true);
        
        static InterruptPort sensorTop = new InterruptPort(Pins.GPIO_PIN_D8, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
        static InterruptPort sensorBottom = new InterruptPort(Pins.GPIO_PIN_D11, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
        static InterruptPort switchUp = new InterruptPort(Pins.GPIO_PIN_D12, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
        static InterruptPort switchDown = new InterruptPort(Pins.GPIO_PIN_D13, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);


        public static void Main()
        {

            sensorTop.OnInterrupt += new NativeEventHandler(test_events);
            sensorBottom.OnInterrupt += new NativeEventHandler(test_events);
            switchUp.OnInterrupt += new NativeEventHandler(test_events);
            switchDown.OnInterrupt += new NativeEventHandler(test_events);

            Thread.Sleep(Timeout.Infinite);
        }

        private static void test_events(uint data1, uint data2, DateTime time)
        {
            // Debug.Print("data1=" + data1.ToString() + ", data2=" + data2.ToString() + ", time=" + time.Ticks.ToString());
            if (data1 == (uint)sensorTop.Id)
            {
                sensorTop.DisableInterrupt();
                Debug.Print("sensorTop::value=" + data2.ToString());
                sensorTop.EnableInterrupt();
            }
            else if (data1 == (uint)sensorBottom.Id)
            {
                sensorBottom.DisableInterrupt();
                Debug.Print("sensorBottom::value=" + data2.ToString());
                sensorBottom.EnableInterrupt();
            }
            else if (data1 == (uint)switchUp.Id)
            {
                switchUp.DisableInterrupt();
                Debug.Print("switchUp::value=" + data2.ToString());
                switchUp.EnableInterrupt();
            }
            else if (data1 == (uint)switchDown.Id)
            {
                switchDown.DisableInterrupt();
                Debug.Print("switchDown::value=" + data2.ToString());
                switchDown.EnableInterrupt();
            }

        }


    }

}

With a the reed switch (top sensor) when closing the circuit we get this:

 

sensorTop::value=1
sensorTop::value=0
sensorTop::value=1
sensorTop::value=0
sensorTop::value=1

When I open the circuit (pull magnet away) I get this.
sensorTop::value=0

 

So bouncing at the start...

 

But when I flip the toggle switch UP (switchUp) I get this:

switchDown::value=0
switchUp::value=1
switchUp::value=0
switchDown::value=0
switchUp::value=0
switchUp::value=0
switchDown::value=0
switchUp::value=0
switchUp::value=0
switchDown::value=0
switchUp::value=1
switchUp::value=0

 

When I let it return to home (off) I get this:

 

switchUp::value=0

Maybe I need to switch to a pull up resistor configuration with a capacitor for denouncing?

 

Thanks guys


In Topic: Multiple InterruptPorts being fired?

14 July 2014 - 09:00 PM

The wiring seems basic, but I am confused by the debugging results - I added debugging statements to the events and when the toggle is used it ends up firing the magnetic reed switches handler, etc.  But it appears like the value in data2 param of those other triggers is always false.  So could this be some type of feedback?  


In Topic: NetDuino Plus 2 + Spark.io ?

27 June 2014 - 05:04 AM

BTW, keep us in the loop on what you find out or end up doing, it looks like a fun project!


In Topic: NetDuino Plus 2 + Spark.io ?

27 June 2014 - 05:01 AM

Hi TareqGamal, after taking a quick look at the spark core I would have to agree with baxter... but I don't think thats necessarily a bad thing!  The spark core appears to essentially be a paired down arduino, so to connect the two you would have to do a bit of coding in both the Arduino framework and .NET for your N+2, but it has a hardware serial interface (RX,TX) that is voltage compatible (3.3v) with your Netduino, so hooking the two together physically will be easy enough.  I don't see why it wouldn't work, you could look for serial communication examples for both boards and just repurpose it for your needs.  Unfortunately there is probably not existing code samples unless you develop them yourself.  I am not sure where you saw that the Spark core is Netduino compatible, but if it was from their website then I would contact them directly about getting a code/wiring example...

 

Good luck TareqGamal!


In Topic: SPI Clock State Question

27 June 2014 - 04:21 AM

Sorry to post to such old topic, but since I am researching using SPI right now, for completeness of this thread I wanted to mention that according to Chris Walker's post on 4.2.2.2 this appears to be resolved:

 

1. Bug fix: SPI clock 'idle high' setting now supported
...

4. Bug fix: SPI chip select timing corrected

 

Which is awesome...  I will hopefully be testing this in the next week when parts arrive.


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.