I have been working on the VoltageReader example from the book
"Getting Started with the internet of things. I get it to build
and run but the output is kind of odd. It seems to cover about
90 percent of 1023 scale when left at one setting of the
potentiometer. Like the adc is just going up and down the scale
in a incremental manner. Anybody seen anything like that ?
The output is at the bottom.
Randy
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using AnalogInput = SecretLabs.NETMF.Hardware.AnalogInput;
public class VoltageReader
{
public static void Main()
{
// write your code here
const double maxvoltage = 3.3;
const double maxAdcValue = 1023;
AnalogInput voltagePort = new AnalogInput(Pins.GPIO_PIN_A1);
//var voltagePort = new AnalogInput(Cpu.AnalogChannel.ANALOG_1);
var lowPort = new OutputPort(Cpu.Pin.GPIO_Pin0, false);
var highPort = new OutputPort(Cpu.Pin.GPIO_Pin2, true);
voltagePort.SetRange(0, 1023);
double rawValue = voltagePort.Read();
double value = 0;
while (true)
{
Debug.Print(rawValue + " " + value.ToString("f"));
Thread.Sleep(3000);
rawValue = voltagePort.Read();
value = ((double)rawValue * maxvoltage) / maxAdcValue;
}
}
}
Here is the output.
9 0.03
28 0.09
42 0.14
57 0.18
128 0.41
515 1.66
964 3.11
958 3.09
927 2.99
674 2.17
362 1.17
131 0.42
26 0.08
118 0.38
37 0.12
26 0.08
22 0.07
26 0.08
54 0.17
24 0.08
26 0.08
27 0.09
26 0.08
1 reply to this topic
#1
Posted 08 July 2015 - 04:09 AM
#2
Posted 08 July 2015 - 05:05 AM
Hi rseedle,
Which Netduino mainboard are you using? What version of firmware?
And...do you have anything plugged into the other analog pins? [If not...can you try connecting them all to GND really quickly to see if that affects your results?]
Welcome to the Netduino community,
Chris
Which Netduino mainboard are you using? What version of firmware?
And...do you have anything plugged into the other analog pins? [If not...can you try connecting them all to GND really quickly to see if that affects your results?]
Welcome to the Netduino community,
Chris
Also tagged with one or more of these keywords: Analog
General →
General Discussion →
Netduino Pin GuideStarted by tridy, 11 Sep 2015 pins, analog, digital, uart, rx and 2 more... |
|
|||
Hardware →
Netduino Plus 2 (and Netduino Plus 1) →
Netduino Analog PortsStarted by sfx, 31 Aug 2014 Analog |
|
|||
Hardware →
Netduino Plus 2 (and Netduino Plus 1) →
Netduino Plus AnalogInput error.Started by desup, 16 Nov 2013 Analog, Input, Plus, Netduino and 2 more... |
|
|||
Hardware →
Netduino 2 (and Netduino 1) →
Connect Push-Button to Analog-PinsStarted by nhale, 10 Sep 2013 button, analog |
|
|||
Hardware →
Netduino Plus 2 (and Netduino Plus 1) →
Analog.ReadRaw unhandled exception in SecretLabs.NETFMStarted by nicualex33, 31 May 2013 Analog |
|
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users