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.

drischar

Member Since 17 Mar 2012
Offline Last Active Apr 05 2012 09:51 PM
-----

Topics I've Started

AnalogInput Repeatability

30 March 2012 - 05:16 AM

By how much should I expect an analog input value to change over multiple reads due to innacuracy on the Netduino itself?

I'm using a number of analog sensors with the Netduino and I'm running into an issue with accuracy.

To remove the possibility that the sensor isn't stable, I've hooked a trimpot up to the analog input between gnd and 3.3V. I also have the netduino hooked up to a 9V wall wart (from Sparkfun, they say it's very stable, my multimeter agrees but I don't think it samples fast enough to really tell).

My code is incredibly simple:
public class Program
    {
        public static void Main()
        {
            AnalogInput trimpot = new AnalogInput(Pins.GPIO_PIN_A0);
            int lastValue = 0;
            while (true)
            {
                int reading = trimpot.Read();
                Debug.Print(reading + " (" + (reading- lastValue) + " change)"); 
                lastValue = reading;

                Thread.Sleep(1000);
            }
        }
    }
The output from this code looks like:
232 (232 change)
230 (-2 change)
233 (3 change)
232 (-1 change)
231 (-1 change)
232 (1 change)
231 (-1 change)
234 (3 change)
230 (-4 change)
226 (-4 change)
230 (4 change)
233 (3 change)
231 (-2 change)
231 (0 change)
As you can see, a difference between consecutive reads can be 4 or more steps, and this is with a guaranteed constant voltage from the trimpot. The difference between the value pf 234 and 226 2seconds later corresponds to a different of nearly 26mV which I would imagine is way outside of tolerance for a usable ADC.

Am I doing something wrong here? I could fix this by using an external ADC over SPI, but before I go down that route (ordering parts, etc) I'd like to know if I can change something to get better results or whether the external ADC (which is also 10 bits) will have the same issue.

I can also always just do multiple reads and average them, but I'm still a little confused about why they vary so largely.

Connecting 5v sensors to AnalogInput

22 March 2012 - 06:11 AM

I am working on converting a project of mine over from an Arduino to a Netduino. I'm definitely a noob when it comes to this sort of stuff. From what I understand, the analog inputs on the Netduino use 3.3V rather than the 5V on the Arduino. This causes a bit of trouble as some of my sensors require 5V in order to work correctly. My temperature sensors are great at 3.3V, but I have 3 gas pressure sensors that require 5.1V +- .25V to work correctly. The output of the pressure sensor is a linear value that corresponds to a value between 0 and 250kPa. In order to get these sensors working on the Netduino, I need to figure out a way to convert the 0-5V analog signal into aa 0-3.3V analog signal. I *might* be able to get by without doing this, as I should never exceed ~110kPa and therefore won't break the 3.3V limit, but that's playing a bit more dangerous than I would like. Is there a decent method to drop the voltage down to 3.3 while keeping the accuracy. From what I understand, this is where I would use a voltage divider, but I also don't understand how I can make that accurate enough that I still get the full range of my sensor since the values of resistors are not exact. I ssuppose I could give it a try (15k to 10k?), but I'd like to know if there are better options. Thanks.

Sharing code between projects

20 March 2012 - 06:47 AM

I'm working on a project that requires the Netduino to send data over a serial bluetooth connection (using Sparkfun's bluesmirf module). I've got the hardware working fine, but I am having a little trouble on the software side of things. The data I send over the serial connection is a specifically formatted packet, I have code that reads and writes these packets (basically a poor man's serialization since .net micro doesn't support it). I'd like for my solution to have two projects, one build using the .net framework (normal) and the other being the netduino project. I'd like to share one "class library" between the two that describes the packet protocol. Of course, if I create either a .net or .net micro class library, the other project will not let me reference it, and I can't add the files to the projects directly as Visual Studio will make copies of them. Is there a way to produce shared code files? Sort of like I could have some shared headers for a c++ project, without having to build something like a DLL first?

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.