5 years, 7 months ago.

A/D conversion

Hi Im trying to do a voltage sampling by inputting the analog signal to pin20. I just want 64 samples of a 50Hz sine signal for my application. Again, I have used a level shifting circuit to shift the whole sine wave to obtain a completely shifted positive signal. I have calculated the time required between the samples and used the function read() to read the analog input after this calculated time. But I always end up getting either 1 or 0 only. I strongly feel I am missing up on something very crucial regarding an ADC. Please help me with this. Code AnalogIn voltage(p20);

int main() { int iadc=1; while(1) { xadc[iadc]=voltage.read(); printf(" %3.4f ", xadc[iadc]); wait(0.0003125); iadc=iadc+1; } } end of code

How did you define xadc? Also use <<code>> and <</code>> around your code.

posted by Erik Olieman 26 Mar 2014

I have just declared a static float xadc[N] where N=64. the samples are required to be stored in xadc[].

posted by sneha jay 27 Mar 2014
Comment on this question
Be the first to answer this question.

You need to log in to post a question