Hi,
I’m trying to read the voltage of analog inputs wired on socket 9. I use all 3 analog inputs of socket 9, on pin 3,4 and 5. I built the following code based on existing examples. The problem I have is that the 3 analog inputs seem linked ! On PIN 3, if the voltage varies, the 2 other analog inputs remain unmodified, but that is not the same when I apply the voltage on the other PINs :
The voltage on PIN 4 is also read at 3/4 of its value on PINs 3 and 5
The voltage on PIN 5 is also read at the same value on PIN 3.
Any hint or advice on what is hapenning ? How can I correct the code ?
I use NETMF 4.1 as 4.2 is still a beta code and I need WIFI.
Thanks a lot for your help !
Stephan.
Here is the code I wrote :
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace TestAnalogSpider
{
public partial class Program
{
protected Gadgeteer.Socket Socket9; // Socket 9
protected Gadgeteer.Interfaces.AnalogInput IN_pHCaptor; // Socket 9 // Pin 3
protected Gadgeteer.Interfaces.AnalogInput IN_TempCaptor; // Socket 9 // Pin 4
protected Gadgeteer.Interfaces.AnalogInput IN_DensityCaptor; // Socket 9 // Pin 5
protected GT.Timer _timer;
protected double pHValue;
protected double tempValue;
protected double densityValue;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
Socket9 = Gadgeteer.Socket.GetSocket(9, true, null, null);
IN_pHCaptor = new GT.Interfaces.AnalogInput(Socket9, GT.Socket.Pin.Three, null);
IN_TempCaptor = new GT.Interfaces.AnalogInput(Socket9, GT.Socket.Pin.Four, null);
IN_DensityCaptor = new GT.Interfaces.AnalogInput(Socket9, GT.Socket.Pin.Five, null);
_timer = new GT.Timer(2000);
_timer.Tick += new GT.Timer.TickEventHandler(TimerTick);
_timer.Start();
Debug.Print("Program Started");
}
void TimerTick(GT.Timer timer)
{
pHValue = IN_pHCaptor.ReadVoltage();
tempValue = IN_TempCaptor.ReadVoltage();
densityValue = IN_DensityCaptor.ReadVoltage();
Debug.Print("pH = " + pHValue.ToString());
Debug.Print("temp = " + tempValue.ToString());
Debug.Print("density = " + densityValue.ToString());
}
}
}