ts-7000
[Top] [All Lists]

[ts-7000] Re: Problem polling A/D's once per second

To:
Subject: [ts-7000] Re: Problem polling A/D's once per second
From: "charliem_1216" <>
Date: Fri, 20 Jul 2007 04:03:42 -0000
Hi Kevin --

I haven't used the built-int A/D myself, but here are a few 
questions:

(Stupid question first :)
* Is your 'myapp' program calling EEPROM_Init() and ADC_Init()?

[Referring to code you linked to earlier] 

        //read NUM_OF_SAMPLES more samples
        for (j = 0; j<NUM_OF_SAMPLES; j++)
        {
            usleep(2000);
            adc_result[i][j] = ADC_ReadChannel(cur_ch);
        }
* You changed the original usleep(10000) to usleep(2000).  Why?  
Maybe more settling time is needed?

for (j = 0; j < NUM_OF_SAMPLES; j++)
            avg = adc_result[i][j] + avg;

        avg = avg / NUM_OF_SAMPLES;

        if (avg < 0x7000)
            avg = avg + 0x10000;
* What's this check doing, an underflow or overflow check? Original 
example code was hardcoded to average 10 samples.  Maybe the 0x7000 
is related (or should be) to NUM_OF_SAMPLES.  What happens if you 
change NUM_OF_SAMPLES from 1 back to 10?

* In your ADC_ReadChannel, you do:
      val = PEEK32(adc_page + DATA_OFFSET);
and then loop with:
      while (((val = PEEK32(adc_page + ADCRESULT_OFFSET)) & 
SDR_MASK) == SDR_MASK)
        ;
* How do you get the new data after your loop ends?  The example 
code does it the other way around: loop until the SDR bit is set in 
ADCResult, _then_ read the data:
 //read result from data regisyyter
        val = PEEK32(adc_page + DATA_OFFSET) ;
I think you need that extra read!

Still no idea why your code works when TEST_PROGRAM is defined 
though, unless you are missing the init code.

--- In  Kevin Cozens <> wrote:
>
> Greetings, all.
> 
> Four more days have passed and I'm still no closer to figuring out 
what is 
> wrong with the routines which are reading the A/D converters. I've 
minimized 
> the differences between use of the routines as a test program vs. 
use in my 
> application.
> 
> When the test program polls once per second the voltages are 
stable. When my 
> application runs, I get about 1 good reading out of every 5 (the 
0.382 0.382 
> readings). See sample runs of the test program and my application 
below. ALl 
> readings are printed from inside the routines which read the A/D 
inputs so I 
> don't see it as a case of memory getting inadvertently over 
written.
> 
> With the client hoping I can deliver the product at the end of the 
month and 
> my being stuck on this problem for the last week and having no 
idea what is 
> going wrong here, all I can do now is to cheat.
> 
> I'll have to modify my application to read the first two channels 
about 10 
> times per second, throw out any negative readings, readings 
greater than 3.3V, 
> and any readings where the two channels differ by more than 10mV. 
It isn't 
> something I really want to do but it seems I have no other option 
unles 
> someone has any explanation as to what's going on.
> 
> 
> 
> $ ./adc_7250 |grep readings
> A/D readings: -0.242V -0.241V 0.185V 0.105V 0.104V
> A/D readings: -0.243V -0.242V 0.185V 0.105V 0.103V
> A/D readings: -0.241V -0.241V 0.185V 0.105V 0.104V
> A/D readings: -0.239V -0.238V 0.186V 0.105V 0.103V
> A/D readings: -0.242V -0.240V 0.185V 0.105V 0.103V
> A/D readings: -0.242V -0.242V 0.185V 0.105V 0.103V
> A/D readings: -0.242V -0.242V 0.185V 0.105V 0.103V
> A/D readings: -0.240V -0.242V 0.185V 0.105V 0.103V
> A/D readings: -0.240V -0.239V 0.186V 0.105V 0.103V
> A/D readings: -0.242V -0.242V 0.185V 0.105V 0.103V

What voltage is applied here to inputs 0 and 1?  Should the reading 
be the same as below (around 0.383)?
> 
> $ ./myapp |grep readings
> A/D readings: 0.382 0.382 0.185 0.105 0.103
> A/D readings: 0.382 0.382 0.186 0.105 0.103
> A/D readings: -0.108 -0.167 0.185 0.105 0.103
> A/D readings: -0.244 -0.244 0.185 0.105 0.103
> A/D readings: -0.244 -0.244 0.185 0.105 0.103
> A/D readings: 0.002 0.130 0.185 0.105 0.103
> A/D readings: 0.383 0.382 0.186 0.105 0.103
> A/D readings: 0.117 -0.028 0.185 0.105 0.099
> A/D readings: -0.243 -0.243 0.185 0.105 0.103
> A/D readings: -0.244 -0.244 0.185 0.105 0.103
> A/D readings: 0.001 0.129 0.185 0.105 0.103
> A/D readings: 0.383 0.382 0.186 0.105 0.103
> A/D readings: 0.116 -0.028 0.185 0.105 0.103
> A/D readings: -0.244 -0.244 0.185 0.105 0.103
> A/D readings: -0.244 -0.244 0.185 0.105 0.103
> 
> -- 
> Cheers!
> 
> Kevin.
> 
> http://www.ve3syb.ca/           |"What are we going to do today, 
Borg?"
> Owner of Elecraft K2 #2172      |"Same thing we always do, 
Pinkutus:
>                                  |  Try to assimilate the world!"
> #include <disclaimer/favourite> |              -Pinkutus & the 
Borg
>


Regards, ....... Charlie



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU