Netduino home hardware projects downloads community

Jump to content


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.
Photo

Strange Analog Output

Analog

  • Please log in to reply
1 reply to this topic

#1 rseedle

rseedle

    New Member

  • Members
  • Pip
  • 1 posts

Posted 08 July 2015 - 04:09 AM

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



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

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





Also tagged with one or more of these keywords: Analog

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.