Main Site Documentation

Sockets for Breakout Module


#1

So I’ve successfully created an Interrupt Input on Pin 3 to common using just about any Socket on the FEZ Spider. I’ve also successfully created a Digital Input using Pin 4 and the 3.3V pin on Socket 11 or 14. So I know that the code is working.

When I attempt to use other pins and sockets for the digital input I get exceptions. I’m assuming it is because of the socket types. https://www.ghielectronics.com/docs/120/gadgeteer-sockets.

I want to maximize the number of Digital Inputs and thought that hooking up the breakout module to any Y socket would achieve this. However, it seems that the breakout module is not using the Y socket type. I also have a relay board (socket 9), wifi (socket 6) and power module (socket 1) hooked up to the spider. I noticed in the vs .net designer that my relay board is using the Y socket type and will not allow me to set the Y socket type for the breakout module. So I have the following questions:

  1. I prefer to use an interrupt input but it appears that this is only available for Pin 3 on most sockets. Is this true, which means for each interrupt input I will need another breakout module to use pin 3 on the sockets?

  2. I’m assuming a work around for the above is to use a digital inputs instead. So considering the other gadgets that I’m using with the FEZ Spider, is it possible to use another Y socket in addition to the relay board Y socket? If so, how? If not, how do I know what socket type the designer is setting up for the breakout module? Again I want to maximize the number of digital inputs. I also have another breakout module in hand.

Thanks in advance.


#2

What does the exception say?
Pin3 is guaranteed to be an interrupt pin according to the standard, but there can be some exceptions when certain pins share an interrupt, so you can use only one at a time. It is mainboard/microcontroller dependent.

1.Most likely, but you can also use something like this:
https://www.ghielectronics.com/catalog/product/363


#3

breakout module is really just an easy way to get to 0.1" headers from the .05" 2-row Gadgeteer socket. Think about it purely as an easy way to get access to the raw pins. You could also do an equivalent thing by cutting a standard Gadgeteer connector cable in half - then you end up with two “breakouts” :slight_smile:

So for your scenario, you need to look at a combination of the sockets you have available and the scematic to make sure you have unique interrupt pins that you can use.

Then, I would NOT connect a breakout module on the designer surface, which means you will then need to include your own connection to the sockets and then the individual pins you want. To do that you’d create a socket object and then a pin object, something like:

// set the socket up
mySocket = Socket.GetSocket(socketNumber, true, this, null);
// define your pins on the selected socket
myPin4 = new DigitalOutput(_socket, Socket.Pin.Four, false, this);

You can create the pin objects as you need, Analog inputs or interrupts etc, that match the mainboard + socket combination that you have chosen and have available to you.


#4

Sorry, also forgot to emphasize that the socket definition states that the pin3 pin MUST be interrupt capable, but there’s no reason that a mainboard’s processor doesn’t offer more IOs that are interrupt capable and that are connected to the other GPIOs that are not required to be interrupt capable. The best way to confirm this is to pore over the schematics and look at the pin connections and the underpinning module or processor’s capabilities and optimise the socket you choose.


#5

Okay. So I used Brett’s logic and removed the breakout from the designer. Got socket 11 using the GetSocket method, setup a digital input and received the same results. Socket 11 has P, U and Y.

Using a FEZ Spider with the above logic for pins 3 through 5 works correctly. The exception below for pins 6 through 9 is thrown:
Using mainboard GHI Electronics FEZSpider version 1.0
#### Exception System.ArgumentException - 0xfd000000 (4) ####
#### Message:
#### Microsoft.SPOT.Hardware.Port::.ctor [IP: 0000] ####
#### Microsoft.SPOT.Hardware.InputPort::.ctor [IP: 0008] ####
#### Gadgeteer.Interfaces.DigitalInput::.ctor [IP: 0015] ####
#### GadgeteerApp1.Program::InputThread [IP: 0014] ####
A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll
Exception was thrown: System.ArgumentException

Interesting point is that a definition for pins 3 through 5 as a GPIO doesn’t exist in any of the socket types on socket 11 (P, U, Y)


#6

Can you please show your code?


#7

void ProgramStarted()
{
            Thread input = new Thread(InputThread);
            input.Start();
}
void InputThread()
{
            GT.Socket s = GT.Socket.GetSocket(11, true, null, null);
            DigitalInput i;
            try
            {
                i = new DigitalInput(s, GT.Socket.Pin.Nine, GlitchFilterMode.On, ResistorMode.PullDown, null);
            }
            catch (Exception e)
            {
                Debug.Print(e.Message);
                throw;
            }
            while (true)
            {
                Debug.Print("Input:" + i.Read().ToString());
                Thread.Sleep(3000);
            }
        }


#8

Try not using glitch filter, because internally it uses an interrupt


#9

@ Architect - well that was an easy solution. Am I giving up anything valuable by setting the glitch filter to off?


#10

Glad it helped! :smiley:


#11

@ Architect - Am I giving up anything valuable by setting the glitch filter to off?


#12

besides glitch filtering? No.


#13

What are you connecting that InputPort to?


#14

Connecting to A/B contacts to get the status of various circuits in existing control circuits.


#15

Should be fine without the filter.


#16

“worst” case is you implement your own quick/dirty filtering - read it X times and if it doesn’t change state in that X samples you can assume it’s good - otherwise keep reading until it settles.


#17

Thanks for the help guys. Everything is working great now and I understand the glitch filter too.