I am still having troubles with my custom PCB for EMX. When reading the ADCO and ADC1 , I see unpredictable values.
Instanciation of analogin are made with:
AnalogIn an1=new AnalogIn(AnalogIn.Pin.Ain0);
AnalogIn an2=new AnalogIn(AnalogIn.Pin.Ain1);
I have a doubt about how to use them. I have tried (without any success) to deactivate touch screen support using:
GHIElectronics.NETMF.Hardware.Configuration.Touch.UseDefaultInterface(false);
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.FEZ;
namespace TESTANALOG
{
public class Program
{
public static void Main()
{
// Blink board LED
GHIElectronics.NETMF.Hardware.Configuration.Touch.UseDefaultInterface(false);
OutputPort buzzer = new OutputPort(EMX.Pin.IO13, false);
AnalogIn an1=new AnalogIn(AnalogIn.Pin.Ain0);
AnalogIn an2=new AnalogIn(AnalogIn.Pin.Ain1);
AnalogIn an5=new AnalogIn(AnalogIn.Pin.Ain5);
AnalogIn an6=new AnalogIn(AnalogIn.Pin.Ain6);
AnalogIn an7=new AnalogIn(AnalogIn.Pin.Ain7);
while(true)
{ int van1=an1.Read(); int van2=an2.Read();int van5=an5.Read();int van6=an6.Read();int van7=an7.Read();
Debug.Print("Value AN1="+ (van1*10/1000).ToString()+"."+((van1*10)%1000).ToString());
Debug.Print("Value AN2="+ (van2*10/1000).ToString()+"."+((van2*10)%1000).ToString());
Debug.Print("Value AN5="+ (van5*10/1000).ToString()+"."+((van5*10)%1000).ToString());
Debug.Print("Value AN6="+ (van6*10/1000).ToString()+"."+((van6*10)%1000).ToString());
Debug.Print("Value AN7="+ (van7*10/1000).ToString()+"."+((van7*10)%1000).ToString());
Thread.Sleep(1000);
// Sleep for 1000 milliseconds
}
}
}
}
And here is a bunch of results with the five pins connected to GND.
Value AN1=0.0
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.40
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.20
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.30
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.120
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.10
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.320
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.30
Value AN2=0.320
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.20
Value AN2=0.130
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.30
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.40
Value AN2=0.10
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.80
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.80
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.780
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.20
Value AN1=0.40
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.30
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.0
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.20
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Value AN1=0.280
Value AN2=0.0
Value AN5=0.0
Value AN6=0.0
Value AN7=0.0
Results look normal. Noise on built in ADC is expected.
For super accuracy on analog inputs, there has to be a complete isolation between digital and analog circuitry. (external ADC with separate power source).
You say that these values are normal. This is not exactly what I am used to see and the fact that only ADC0 and ADC1 are affected seems to be an error on my board (EMC ???)
Without formatting values into Voltage (i.e. printing raw data) I observed that ADC0 goes from 0 to 58. This is really far from what we can expect with 10 bit resolution and an abosolute error of +/- 4LSB conbined with an offset error of +/-3LSB as described in the NXP datasheet. Therefore I think I have something wrong on my custom board, probably EMC.
If someone can perform the same test it would be great…
There are many factors that jump in play with analog designs. Starting from separating power sources and having more spread out layout on PCB. EMX is a very compact 8 layer board so there isn’t much room for separating noise. Maybe use a digital filter to enhance the results.
I am not sure that the problem comes from EMX, It may be due to bad routing of my custom PCB. I go on my investigations about that and will let you know. My main doubt was about disabling or not the touch controller. if the parameter has to be set to false or true.
One thing you can do to improve (not sure how much it will thought) is by filtering the power source going to EMX, using capacitor/coils/ferrite-beads…you know, the usual.
I have nearly the same problem, I use ADC 2 and 3 and the values are very floaty, I have testes with connecting to ground or to vcc and it floats periodicly.
I think its a problem with the power supply of my board, if I use the usb port to power the cobra, its not so bad, but with a external psu its very floaty.