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
- Netduino Forums
- → Viewing Profile: Topics: rseedle
The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Community Stats
- Group Members
- Active Posts 1
- Profile Views 3638
- Member Title New Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
0
Neutral
User Tools
Friends
rseedle hasn't added any friends yet.
Latest Visitors
No latest visitors to show
Topics I've Started
Strange Analog Output
08 July 2015 - 04:09 AM
- Netduino Forums
- → Viewing Profile: Topics: rseedle
- Privacy Policy