I am wondering if anyone ekse has a problem reading the analog pins and getting good accuracy. I am using a sensor that I have used brilliantly with other microcontrollers. The sensors outputs 0-5v to the Fez but the readings from the FEZ Panda II to the Debugger are all wrong. I expect a steady number between 0 and 1023…byt they are all over the place. It is a three axis accelerometer by the way. Normally the numbers are the same when not sitting still but here they are reading (for example):
This is actually made for the lilypad and it is made to work at 5v.
In any event the same thing happens at 3 volts. It is all over th place. Just to check I plugged it into an Arduino and it was flatlined at 510 which is the correct value according to a lot of other user (508-512 for a level plane). It should not matter what microcontroller I use it as it just feeds a voltage…
I am new to this NETMF but maybe I am referencing the wrong machine? Fez Panda II…
using System;
using System.Threading;
using Microsoft.SPOT;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware;
namespace MFConsoleApplication1
{
public class Program
{
public static void Main()
{
Debug.Print(
Resources.GetString(Resources.StringResources.String1));
AnalogIn lightSensor = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);
int lightSensorReading = 0;
while (true)
{
lightSensorReading = lightSensor.Read();
Debug.Print(lightSensorReading.ToString());
}
}
@ rgm - please use code tags. The Panda II is 3.3V only. Most pins are 5V tolerant, but that only means you (hopefully) won’t fry the board hooking it up to 5V.
Thanks for the replies. I guess I was just comparing it to my Arduino which was flatlined and it was troubling. If the sensor is not moving I would assume it would have a flatline.
I am a mech engineer and this is new to me so thanks for the paitence!
@ rgm You will find in the NXP datasheet corresponding to your device, the definition of all the noise (in term of SNR or lsb due to quantification steps…)
Just to make distinction between error of sensor and error of analog to digital conversion. Why don’t you connect a 1.5V battery to the analog input. If the ADC is perfect you shouldn’t see variation, but you will probably see noise (due to quantification, EMI…)
To eliminate this you can filter EMI (better quality cable, no parallel long line, add capacitor…) and if it is not enough you can then compute average on some sample…
Another thing to keep in mind is the resolution/type of the A2D converter that is built into the microcontroller. The microcontroller the small FEZ boards use has an A2D converter 10bit resolution. If you compare the reading to a microcontroller with an 8bit A2D converter the 10bit resolution will allow yo to see smaller changes in the signal.
So an update that may help others. I drilled the board to a wooden plank and the numbers are very steady now. It is like night and day. Perhaps the desk was causing noise