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.
Photo

Shield Base Digital Input


  • Please log in to reply
13 replies to this topic

#1 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 11 May 2012 - 03:11 PM

I've been playing around with the Display module and Relay module in an effort to move a project from the original netduino to the Go. I've had the sheild base sitting around but haven't played with it due to the issue with needing multiple Go ports. In anticipation of being able to use it with a single port I started converting that part of my project over. Its really simple, just using 4 digital inputs to read some sensors.

I moved my connectors over from my working netduino to the shield base but nothing worked right. I'd get random triggers or no triggers at all. I put it back on the original netduino to see if I'd broken something in the move, but it still worked correctly. I made a test cable with a header so I could just test a pin at a time in case there was something wrong with my board. It wouldn't even finish booting when I had this cable plugged in, if I kept it unplugged upon boot and waited till it was in its main loop before plugging it in, I could get results, even though it was even more random than before.

I tripple checked my cable and there were no problems, so I just grabbed another header and was going to just touch one wire to one pin. When I did this I accidentally brushed up against it with my finger and watched it trigger. I could do this over and over again. Thinking it was some odd capacitance with my skin, I grabbed some needle nose pliers and discovered I could trigger the digital input with it as well.

I had a second shield base and connected it, exact same results. Maybe I'm just missing some sort of init to make the sheild base behave like the original netduino. Here's a sample video and sample code.

Video

public static void DrawDot(VirtualCanvas Screen, int x, int y,int r,bool bRead)
        {
            BasicColor b;
            if (bRead)
                b = BasicColor.Green;
            else
                b = BasicColor.Red;
            Screen.DrawCircleFilled(x, y, r, (ushort)B);
        }

        public static void Main()
        {
            int ScreenWidth = 320;
            int ScreenHeight = 240;
            VirtualCanvas Screen = new VirtualCanvas();
            Screen.Initialize(GoSockets.Socket5);

            NetduinoGo.ShieldBase shieldBase = new NetduinoGo.ShieldBase(GoSockets.Socket1);
            InputPort D0 = new InputPort(shieldBase.Pins.GPIO_PIN_D0, true, Port.ResistorMode.Disabled);
            InputPort D1 = new InputPort(shieldBase.Pins.GPIO_PIN_D1, true, Port.ResistorMode.Disabled);
            InputPort D2 = new InputPort(shieldBase.Pins.GPIO_PIN_D2, true, Port.ResistorMode.Disabled);

            Screen.SetOrientation(Orientation.Landscape);
            Screen.DrawFill((ushort)BasicColor.Black);

            Relay R0 = new Relay();
            Relay R1 = new Relay();
            Relay R2 = new Relay();

            R0.Initialize(GoSockets.Socket6);
            R1.Initialize(GoSockets.Socket7);
            R2.Initialize(GoSockets.Socket8);

            int x = ScreenWidth / 3;
            int y = ScreenHeight / 2;
            int r = x / 4;
            bool LastReadD0 = true;
            bool LastReadD1 = true;
            bool LastReadD2 = true;

            while (true)
            {
                bool bRefresh = false;
                bool ReadD0 = D0.Read();
                bool ReadD1 = D1.Read();
                bool ReadD2 = D2.Read();

                if (ReadD0 != LastReadD0)
                {
                    DrawDot(Screen, x - x / 2, y, r, ReadD0);
                    R0.Activate(ReadD0);
                    LastReadD0 = ReadD0;
                    bRefresh = true;
                }
                if (ReadD1 != LastReadD1)
                {
                    DrawDot(Screen, x*2 - x / 2, y, r, ReadD1);
                    R1.Activate(ReadD1);
                    LastReadD1 = ReadD1;
                    bRefresh = true;
                }
                if (ReadD2 != LastReadD2)
                {
                    DrawDot(Screen, x*3 - x / 2, y, r, ReadD2);
                    R2.Activate(ReadD2);
                    LastReadD2 = ReadD2;
                    bRefresh = true;
                }
                if (bRefresh)
                    Screen.Execute();
            }

        }


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 May 2012 - 03:20 PM

Hi NXTwoThou, I'm looking at the video and the code and don't quite understand what's going on. Can you remove the hardware pieces that you're _not_ using and film it with a bit more light? Or explain the scenario in a bit more detail? What you're trying to do should work perfectly. If it's not, we'd like to fix that :) Chris P.S. When hosting diagnostics videos on YouTube, you probably want to mark them as Private. Otherwise you'll get users watching your videos who were looking for tutorials...and they'll be quite confused :)

#3 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 11 May 2012 - 05:17 PM

Unfortunately with the length of the usb cable can't really move it anywhere, there's not another light source in here. I'll change the video to private to stop people from accidentally finding it. I had planned to delete it once I figured out what was going on. I have a shield base in port 1 Display module in 5 Relay module in 6, 7, and 8 I had a 6 pin header in the digital i/o 0-5. I deploy the above sample code. It shows 3 red dots and all the relays are off. If I touch the header pin for digital i/o 0, the dot to the right turns green and relay 6 turns on. If I touch the header pin for digital i/o 1, the dot to the right turns green and relay 7 turns on. If I touch the header pin for digital i/o 2, the dot to the right turns green and relay 8 turns on. By "touch" I mean with needle nose pliers, not connected to anything else(with rubber grip so no capacitance from my body either). If I replace that header with a header that has a ribbon cable attached to it(other end of the ribbon cable has nothing on it) the dots/relays start randomly firing. If this header with the cable is attached when first powering on the netduino go it doesn't finish booting up. The behavior I expected to happen is that no dots nor relays would change until I connected one of the pins to ground.

#4 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 11 May 2012 - 05:18 PM

Er..changed to unlisted. Private means you wouldn't be able to watch it. New link if it changed

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 12 May 2012 - 11:04 PM

Hi NXTwoThou, Your InputPorts are currently configured with resistormode "disabled". This means that the value of the input will be floating. You want it to be either high or low by default. I'd recommend setting the ResistorMode to "PullUp" or "PullDown" on those inputs. Opposite of whatever you need for the relays. Please note that in addition to the PullUp resistor mode that the original Netduino, the Shield Base also supports PullDown mode. Does that fix the issue? Chirs

#6 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 14 May 2012 - 04:38 PM

No matter what mode I'm in, if my ribbon cable is attached, it won't finish booting. When I run in debug mode it takes 25 seconds for it to get past NetduinoGo.ShieldBase shieldBase = new NetduinoGo.ShieldBase(GoSockets.Socket5); When I try D0 = new InputPort(shieldBase.Pins.GPIO_PIN_D0, true, Port.ResistorMode.PullDown); it takes 8 seconds and gives me a System.Exception. The message is ""Exception was thrown: System.Exception" The StackTrace is NetduinoGo.ShieldBase::CreateInputPort System.Reflection.MethodBase::Invoke Microsoft.SPOT.Hardware.InputPort::.ctor eStack2.Program::Main If I plug it in after I boot, I can connect any of my digital pins to +5V in either PullDown or PullUp mode and cause a trigger and its consistent. I've confirmed no breaks in my ribbon cable and no shorts. If this not being able to boot problem gets fixed, am I going to get screwed with my optoisolator? That's why I had it set as disabled with the original netduino.

#7 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 14 May 2012 - 05:01 PM

Never mind about the optoisolator bit. Just wired it up in PullDown mode and it works fine. Just can't get it to boot up while connected.

#8 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 14 May 2012 - 05:08 PM

Only two problems is shieldbase taking multiple go ports and the error I get if its connected when first started. Here's my revised code

public static void DrawDot(VirtualCanvas Screen, int x, int y, int r, bool bRead)
        {
            BasicColor b;
            if (bRead)
                b = BasicColor.Green;
            else
                b = BasicColor.Red;
            Screen.DrawCircleFilled(x, y, r, (ushort)B);
        }

        public static void Main()
        {
            int ScreenWidth = 320;
            int ScreenHeight = 240;
            int x = ScreenWidth / 3;
            int y = ScreenHeight / 2;
            int r = x / 4;

            VirtualCanvas Screen = new VirtualCanvas();
            Screen.Initialize(GoSockets.Socket4);
            Screen.SetOrientation(Orientation.Landscape);
            Screen.DrawFill((ushort)BasicColor.White);
            Screen.Execute();

            NetduinoGo.ShieldBase shieldBase = new NetduinoGo.ShieldBase(GoSockets.Socket5);
            Screen.DrawFill((ushort)BasicColor.Black);
            Screen.Execute();
            InputPort D0 = null;
            InputPort D1 = null;
            InputPort D2 = null;
            bool LastReadD0 = false;
            bool LastReadD1 = false;
            bool LastReadD2 = false;

            try
            {
                D0 = new InputPort(shieldBase.Pins.GPIO_PIN_D0, true, Port.ResistorMode.PullDown);
            }
            catch (Exception ex)
            {
                string st = ex.StackTrace;
                string s = ex.Message;
            }
            if (D0 != null)
                LastReadD0 = !D0.Read();
            DrawDot(Screen, x - x / 2, y, r, LastReadD0);
            Screen.Execute();

            try
            {
                D1 = new InputPort(shieldBase.Pins.GPIO_PIN_D1, true, Port.ResistorMode.PullDown);
            }
            catch (Exception ex)
            {
                string st = ex.StackTrace;
                string s = ex.Message;
            }
            if (D1 != null)
                LastReadD1 = !D1.Read();
            DrawDot(Screen, x * 2 - x / 2, y, r, LastReadD1);
            Screen.Execute();

            try
            {
                D2 = new InputPort(shieldBase.Pins.GPIO_PIN_D2, true, Port.ResistorMode.PullDown);
            }
            catch (Exception ex)
            {
                string st = ex.StackTrace;
                string s = ex.Message;
            }
            if (D2 != null)
                LastReadD2 = !D2.Read();
            DrawDot(Screen, x * 3 - x / 2, y, r, LastReadD2);
            Screen.Execute();

            
            Relay R0 = new Relay();
            Relay R1 = new Relay();
            Relay R2 = new Relay();

            R0.Initialize(GoSockets.Socket1);
            R1.Initialize(GoSockets.Socket2);
            R2.Initialize(GoSockets.Socket3);
            

            while (true)
            {
                bool bRefresh = false;
                bool ReadD0 = false;
                if (D0 != null)
                    ReadD0 = D0.Read();
                bool ReadD1 = false;
                if (D1 != null)
                    ReadD1 = D1.Read();
                bool ReadD2 = false;
                if (D2 != null)
                    ReadD2 = D2.Read();

                if (ReadD0 != LastReadD0)
                {
                    DrawDot(Screen, x - x / 2, y, r, ReadD0);
                    R0.Activate(ReadD0);
                    LastReadD0 = ReadD0;
                    bRefresh = true;
                }
                if (ReadD1 != LastReadD1)
                {
                    DrawDot(Screen, x * 2 - x / 2, y, r, ReadD1);
                    R1.Activate(ReadD1);
                    LastReadD1 = ReadD1;
                    bRefresh = true;
                }
                if (ReadD2 != LastReadD2)
                {
                    DrawDot(Screen, x * 3 - x / 2, y, r, ReadD2);
                    R2.Activate(ReadD2);
                    LastReadD2 = ReadD2;
                    bRefresh = true;
                }
                if (bRefresh)
                    Screen.Execute();
            }

        }


#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 May 2012 - 05:18 PM

Hi NXTwoThou, Thank you for the updates. I'm not quite sure...is it working properly for you now? Are you experiencing a separate issue during boot? Chris

#10 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 14 May 2012 - 05:28 PM

The issue during boot is still present. If I undo my ribbon cable, it boots fine and I can plug in my ribbon cable and everything works as I want it to. If my ribbion cable is connected at boot, I get the 25 seconds during new NetduinoGo.ShieldBase and 8 second delay on new InputPort before it gives a System.Exception.

#11 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 15 May 2012 - 02:05 PM

This morning I was reading some other topics about the default state of digital pins and on a whim decided to move my ribbon cable. I've discovered -only- if I have anything connected to D0 does it fail to start up.

#12 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 17 May 2012 - 10:13 PM

Really wish I had an alternative to the sheildbase, its nothing but a living nightmare at this point. If I have anything connected to D0 when the board boots it waits 25 seconds new NetduinoGo.ShieldBase then 8 seconds on a new InputPort before throwing an exception. If I try and run debug mode, it gives an exception on new InputPort randomly(just a few seconds ago, it was when I created one on D4, previously when I did D2, like its more and more unstable) If I try and use one of the 30cm Go cables, I get even more random errors I have two shield bases and two Netduino Gos and a dozen Go cables. I'm pretty sure they aren't -all- bad. Do we expect this to be corrected with the new firmware?

#13 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 17 May 2012 - 11:27 PM

Hi NXTwoThou,

If I have anything connected to D0 when the board boots it waits 25 seconds new NetduinoGo.ShieldBase then 8 seconds on a new InputPort before throwing an exception.
If I try and run debug mode, it gives an exception on new InputPort randomly(just a few seconds ago, it was when I created one on D4, previously when I did D2, like its more and more unstable)
If I try and use one of the 30cm Go cables, I get even more random errors

I have two shield bases and two Netduino Gos and a dozen Go cables. I'm pretty sure they aren't -all- bad.

Do we expect this to be corrected with the new firmware?

So sorry that you're experiencing troubles with your Shield Base. Let me give you some info to help out...

1. For now, I'd recommend using a 5cm cable (or 10cm if you don't have a 5cm cable). Even though the Shield Base uses the slower UART channel, data corruption can occur on longer cables when noise is introduced in the environment.
2. The issue on D0/D1 is probably due to the NETMF debug port being on pins D0/D1. We will take a look at this and see what's going on. Do you mind if I PM you next week when we get back from MakerFaire, to diagnose?
3. If you're getting exceptions creating InputPorts randomly, that's something we haven't seen...but may be related to data corruption due to longer cable lengths.
4. All of the go!cables are tested before they ship. They're IDC cables ("in-chassis cables") so they are susceptible to noise. We have a CRC algorithm running on the other modules which we'll be carrying over to the Shield Base very soon...which is designed to protect against noise here.

We have an early reflashing app now, so we'll be able to start issuing updates to the Shield Base in the next two weeks. We can try to fix the D0/D1 issue you're seeing in the first update...and then add in CRCs shortly thereafter.

Chris

#14 NXTwoThou

NXTwoThou

    Advanced Member

  • Members
  • PipPipPip
  • 68 posts
  • LocationTulsa, OK

Posted 18 May 2012 - 01:57 PM

I barely squeezed a 5cm cable in, didn't fix my problem with being able to run in debug mode nor corrected my issue with DO/D1. I'd love a PM next week to try and get this resolved. I unfortunately have a project due in a few weeks that I had decided to upgrade from the old netduino to the Go version and I'm getting very nervous.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.