Main Site Documentation

(Fez Spider with extender module) don't know how to define pins? Thx for your help


#1

I have a FEZ Spider and want to use an analog input with an extender plugged in Port 9 but i don’t know how to define these pins i want to use. Do you have any idea?

Greetings Niklas


#2

Keep this in your back pocket :slight_smile:
http://wiki.tinyclr.com/index.php?title=Gadgeteer_Sockets

Welcome to the community!


#3

Thank you for your quick help:-)
My Problem is that i don’t know to define Socket 9 as A and than the pins to Analoginput and digital IN/OUT


#4

I believe that you can define it as an extender modulem, then link to the pins.

The way I have been using pins is so:


GT.Socket mySocket = GT.Socket.GetSocket(9, true, null, null); 

GT.Interfaces.AnalogInput myAnalogueInput = new GT.Interfaces.AnalogInput(mySocket,GT.Socket.Pin.Three,null);

you can then call myAnalogueInput.ReadVoltage etc.


#5

@ Molando, please use “code” tags. That should do it for you coxxxer.


#6

Thank you Molando
thats exactly what i wanted to know:-)
but "(9, true, null, null); "
9 = Port 9 , but the true and null , null i don’t know why?


#7

For digital input/output on a single pin you have two options that I know of.

You can define the pin as a tristate pin. They say to be careful about this. With a tristate you can send to the pin, and read the state of the pin.

The other option is to define the pin as an output, then when you need it as an input, you can dispose the pin. This was a little fiddly, as needed to modify the source so that the object can be freed, and also add the ability to remove the pin from the pin array that is used to stop it being used twice.
This works quite well.

If you need to be able to tell when the state changes, then you can use a InterruptInput.
You could just use a basic input, and then repeatedly check, but if you need more accuracy then the Interupt is probably better.

I have a device that need to be sent a pulse, then have to read the length of the pulse that comes back.
Swapping between the two pin types works well, but with the interuptInput, if I set it to detect both edges I only see it when it goes high, neve rget the interupt when it has a falling edge.

Strangly if I ask it just to detect falling edges it captures it then.

Taken a day of work tomorrow to work on this and bluetooth, will let you know what solution I find, and post the modifications to the source if it is any use to you.


#8

http://www.netmf.com/gadgeteer/docs/gadgeteercore/index.html


#9

the first true is if to throw an exception if the socket is not valid. Thought it can not harm setting this to true.

Have just read through the code, the other two parameters do not seem to do much. The first changes the error message you see if the socket is not valid or it can not find the socket in an array of the valid sockets.

The second parameter does not appear to be used.


#10

ok, well to know, I’am new by programming with c# .Before i used arduino :wink:
But i have another question: Can i only use “.ReadProportion” by using “GT.Interfaces”? and what kind of dataTyp do I need to work with?


#11

readProportion is just doing a:

ReadVoltage() / 3.3;


#12

Do you have an example code where you read the analogpin?


#13

I forgot to use the “()” after ReadVoltage >:(
;D
Thanks for your help