Dear Gadgeteer guys,
I have an exception due to AnalogInput.ReadVoltage() Methode.
Please, help me, thanks in advance.
Here is my code :
private void SetupAnalogIn(Extender extender)
{
if (m_pinSocket < 3 || m_pinSocket > 5)
throw new Exception("Out of range Analog Input");
Thread.Sleep(1000);
switch (m_pinSocket)
{
case (int)GT.Socket.Pin.Three:
m_AnalogInput = extender.SetupAnalogInput(GT.Socket.Pin.Three);
break;
case (int)GT.Socket.Pin.Four:
m_AnalogInput = extender.SetupAnalogInput(GT.Socket.Pin.Four);
break;
case (int)GT.Socket.Pin.Five:
m_AnalogInput = extender.SetupAnalogInput(GT.Socket.Pin.Five);
break;
default:
break;
}
}
Although i make a catch of exception but it still throws :((
public double GetSensorValue()
{
Thread.Sleep(200);
double _value;
//convert the reading to voltage
try
{
double miniVoltage = m_AnalogInput.ReadVoltage() * 1000;
//calculate Celsius from voltage
_value = m_Pente * miniVoltage + m_Offset;
m_AnalogInput.Dispose();
return _value;
}
catch (InvalidOperationException)
{
return -1;
}
catch (Exception)
{
return -1;
}
}
Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1)
#### Message:
#### Microsoft.SPOT.Hardware.Port::ReservePin [IP: 0000] ####
#### Microsoft.SPOT.Hardware.AnalogInput::.ctor [IP: 008b] ####
#### Gadgeteer.Interfaces.NativeAnalogInput::set_IsActive [IP: 002e] ####
#### Gadgeteer.Interfaces.NativeAnalogInput::ReadVoltage [IP: 0005] ####
#### TechonovalWebApp.Models.SensorAnalogIn::GetSensorValue [IP: 000f] ####
#### Technosvalg.Tools::GetSignalSensor [IP: 003a] ####
#### Technosvalg.Managers.GloalReactorManager::__AutoPilotActions [IP: 0019] ####
#### Technosvalg.Managers.GloalReactorManager::__RegulationReactorTimer_Tick [IP: 00ef] ####
#### Gadgeteer.Timer::dt_Tick [IP: 0018] ####
#### Microsoft.SPOT.DispatcherTimer::FireTick [IP: 0010] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 0020] ####