I was able to get something working with the following code however I feel I’m breaking methodology by creating a new socket.
I do get valid results reading voltage from the pin I’m just concerned that my methodology appears to be a bit off because I’m creating a socket with only one active pin, which isn’t compliant – to say nothing of the fact that the socket itself is virtual and doesn’t exist.
Here’s the code that works:
var ns = GT.Socket.SocketInterfaces.CreateNumberedSocket(21);
ns.SupportedTypes = new char[] {'A'};
ns.CpuPins[3] = G120.Pin.P1_31;
GT.Socket.SocketInterfaces.SetAnalogInputFactors(ns, 3.3, 0, 12);
ns.AnalogInput3 = Cpu.AnalogChannel.ANALOG_5;
GT.Socket.SocketInterfaces.RegisterSocket(ns);
var s1 = GT.Socket.GetSocket(21, true, null, "MULT2");
a1 = new GT.Interfaces.AnalogInput(s1, GT.Socket.Pin.Three, null);
P1.31 is Analog_5
P1.30 is Analog_4
P0.12 is Analog_5
P0.13 is Analog_7
Here’s how I tested it…
Microsoft.SPOT.Hardware.AnalogInput ain;
ain = new Microsoft.SPOT.Hardware.AnalogInput (Cpu.AnalogChannel.ANALOG_5,3.3,0,12);
for (int i=0;i<100;i++)
Debug.Print("val=" + ain.ReadRaw().ToString());
Each time I used a different analog channel, I could see the value change as I varied a variable resistor.