SignalCapture in .NETMF 4.2 with FEZ Spider

Dear GHI Community,

I want to do something “simple”. I have a sensor that outputs a PWM signal and I want to read it with my FEZ Spider, I am using .NETMF 4.2. There are a few posts saying the best way to read a PWM signal is to use PinCapture. First of all, there is no PinCapture in 4.2 but it is called SignalCapture, am I right?

I am a little bit confused how to use the SignalCapture class. In the PinCapture tutorial the code is as follows:

static PinCapture cap = new PinCapture((Cpu.Pin)FEZ_Pin.Digital.Di2, Port.ResistorMode.Disabled);

Using .NETMF 4.2 and my FEZ Spider I can create a digital output on a pin by setting the socket and then the corresponding pin as you can see here:

GTI.DigitalOutput pin3Socket11 = new GTI.DigitalOutput(GT.Socket.GetSocket(11, true, null, null), GT.Socket.Pin.Three, false, null); // Motor 1 DIRECTION

So, I say that I want to use socket 11 and then pin 3 from this same socket. It is very straightforward and easy to understand!

How do I use the SignalCapture class? The class wants the code to look like this, so that there are no errors:

SignalCapture DIScapture = new SignalCapture(Cpu.Pin.GPIO_Pin11, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);

But what is this Cpu.Pin.GPIO_Pin11? To which socket does this pin belong? I just used Pin11, there were many other pins available. Can you help me figure out how to set up pin capturing on any pin on FEZ Spider?

Then, how do I figure out the correct duty cycle?

Thank you in advance!

You probably need to use an interrupt pin to read the PWM signal. First identify a socket that has and interrupt pin on it. This page will help you do that:

http://gadgeteer.codeplex.com/wikipage?title=.NET%20Gadgeteer%20Socket%20Types

Many of the sockets support interrupts on Pin 3.

Now to find how the Pin3 of the socket that you chose relates to the CPU pin number, you will need to consult the circuit diagram which is available under resources in the catalog. Here is a shortcut to that:

http://www.ghielectronics.com/downloads/schematic/FEZ_Spider_Mainboard_SCH.PDF

Hope that helped a bit and that I was not perhaps just telling you things you know already.

PS: This page below, although not directly related may also be interesting reading for you to help figure out how to find the right pins:
https://www.ghielectronics.com/docs/196/gadgeteering-with-non-gadgeteer-mainboards

Im afraid that interrupt is to slow to capture other PWM. So I guess SignalCapture is right choice.
If you are using Gadgeteer project, you can get cpu pins on socket using Socket class, like that (for pin 3 on socket 11):

Cpu.Pin capturePin = Socket.GetSocket(11, true, null, null).CpuPins[3];

Use it when creating SignalCapture object.

Thank you so much. This is what I wanted to know!