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.

Arron Chapman's Content

There have been 1 items by Arron Chapman (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#69339 analog input with GL5528 photoresistor

Posted by Arron Chapman on 14 June 2017 - 02:33 AM in Netduino 3

Alex,

 

This is a common situation with analog devices and there may be several factors involved.

 

For example, if there is any ripple in your light source this will be reflected in the output of your sensor.  In the US it's quite common to find 60hz (50hz in most of EU/AU) noise in just about everything because this is the frequency the AC in our houses runs at.  In many cases, one will find a 60hz oscillation in optical sensors because the lights will flicker at this frequency.  Additionally, it's possible that there are fluctuations in the power supply of your Netduino, which can be induced by the same AC signal.

 

I'm going to assume your circuit looks a bit like this;

Kd5SiyS.png

 

There are 2 realistic ways of solving this problem; First is the electrical solution!  You can add some capacitance to the output line to help filter out the noise. What type and size of capacitor won't matter a huge amount for this purpose, I'd pick something in the 100pf range, though you might just experiment a bit to see what gets you the best results. Wiring it up is rather easy, you'll just put it in between your sensor's output and GND.

xze73hN.png

 

The second option is the less fun option but you can fix this in software as well!  The easiest way to do this would be to just keep a local average of the input, using that instead of the raw value.

for (int i = 0; i < 100; i++)
{
	localTotal += sensorInput.ReadRaw();
	Thread.Sleep(10);
}
localAvg = localTotal / 100;

This will give you an average over the last ~1 second.

 

 

Both of the solutions have 1 major consequence which is that they reduce the responsiveness of your sensor, as each solution increases the amount of time required to output the new value.  The exact extent of this delay depends on how you choose your capacitor, or how tightly you run the averaging loop.





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.