ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: MAX197 ADC interfacing

To:
Subject: Re: [ts-7000] Re: MAX197 ADC interfacing
From: anand bhavnani <>
Date: Thu, 9 Feb 2006 22:26:01 -0800 (PST)
hello jim,

you have mentioned about a driver that worked for u at
5.3k, please mail it.

also i have attatched the code of the driver that i am
trying to use, but as i have already mentioned its not
working.

you also said that MAX 197 is not reliable, why
exactly are u saying so...any technical issues with
it...

waiting for ur reply,

//anand

--- Jim Jackson <> wrote:

> 
> 
> 
> On Thu, 9 Feb 2006, Phil wrote:
> 
> >
> > Using one of the spare EP930x timers, I am
> actually getting quite
> > reliable and accurate timing for sampling signals
> at a rate of
> > ~5.3kS/s. Also, although I haven't had a chance to
> test, I am hoping
> > that I will be able to do this across multiple
> channels (up to 6
> > channels, giving ~32kS/s total).
> >
> > Which reminds me, I was going to see if anyone was
> interested in the
> > drivers that I have written for ADC sampling?
> Probably not terribly
> > robust yet, since I only have the one board to
> play with at the
> > moment, but could be useful nonetheless. Let me
> know if you are and
> > I will post them.
> 
> I'd be very interested.
> 
> Jim
> 
> > --- In  Jim Jackson
> <> wrote:
> > >
> > >
> > > On Wed, 8 Feb 2006, Phil wrote:
> > > > --- In  "ajbanand"
> <ajbanand@> wrote:
> > > > >
> > > > > Hi all,
> > > > >
> > > > > i have TS-7250 with MAX197 ADC.
> > > > > i am trying to provide voice support to my
> board using the ADC.
> > > > > i have configured my ADC for single channel
> usage..
> > > > > its not giving proper digital values for the
> analog input, i am
> > > > getting
> > > > > value like 0,5,17 etc all less than 100. for
> bipolar -5 tp +5
> > range
> > > > > these values all seem to be noise..
> > > > > can anyone please explain what could be
> wrong in my approach...
> > > >
> > > > If you reply with the code that you are using,
> you will get a
> > better
> > > > response from the members of this group.
> Without it, we can't
> > really
> > > > help.
> > > >
> > >
> > > Also it would be of use to know the circuit
> schematic for the
> > electronics
> > > feeding the input.
> > >
> > > However having said that, I can't see how you
> can reliably use the
> > MAX197
> > > for sampling voice or anyother signal > half the
> the Kernel HZ
> > value.
> > > Timing for the sampes will not be accurate
> enough, even though
> > sampling
> > > one input only, one can get sampling rates of
> upto 50K samples/sec
> > (If my
> > > memory if correct).
> > >
> > > Jim
> > >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> 

"Stay HUNGRY. Stay FOOLISH." Steve Jobs

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

 
Yahoo! Groups Links

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

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

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 
/***************************************
*This program assumes a test fixture is 
*attached to the A/D header with 2.35 VDC
*on all even channels and 1.18 VDC on all
*odd channels. This test uses a 0-10V unipolar.
*Therefore even channels are nominally
*22% (21.5-22.5 => good) and odd channels are
*nominally 11% (10.5-11.5 => good).
***************************************/

#include<unistd.h>
#include<sys/types.h>
#include<sys/mman.h>
#include<stdio.h>
#include<fcntl.h>
#include<assert.h>
#include<time.h>
#include<stdlib.h>

#define PLD_ATOD_SET     0x01           //bit0 at OPTIONS
#define OPTIONS          0x22400000             
#define CTRL_BYTE        0x10f00000
#define BUSY             0x10800000
#define CHANNEL_0        0x50
#define CHANNEL_7        0x57
#define BUSYBIT          0x80

int main(int argc, char **argv) 
{
        volatile unsigned char *options, *controlByte, *busy;
        unsigned char *registerValue;
        unsigned short *results;
        double percentage;
        int ctrlByte, n;
        int fd = open("/dev/mem", O_RDWR|O_SYNC);
        assert(fd != -1);
                
        setvbuf(stdout, NULL, _IONBF, 0);

        /* Lets intialize our pointers */
        options = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
          OPTIONS);
        assert(options != MAP_FAILED);
        controlByte = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED,
          fd, CTRL_BYTE);
        assert(controlByte != MAP_FAILED);
        busy = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 
          BUSY);
        assert(busy != MAP_FAILED);

        printf("checking if MAX197-ADC option is set...");
        registerValue = (unsigned char *)options;
        if( *registerValue & PLD_ATOD_SET ) {
                printf("ok\n"); 
        } else {
                printf("FAIL, not set\n");
                return 1;
        }

        /* Lets go do the conversions */
        for( ctrlByte = CHANNEL_0; ctrlByte <= CHANNEL_7; ctrlByte++)
        {
                //lets write out our control byte       
                *controlByte = ctrlByte;

                printf("waiting for ADC to respond on channel %d...",
                  ctrlByte - CHANNEL_0);
                //lets poll the busy bit to determine when the conversion is 
done
                registerValue = (unsigned char *)busy;

                n = 0; 
                while(n < 14 && (*registerValue & BUSYBIT) != 0x0) {
                        usleep(1 << n);
                        n++;
                }
                if (n == 14) {
                        printf("FAIL, timed out\n");
                        return 4;
                } else {
                        printf("ok\n");
                }
        
                printf("reading result...");
                results = (unsigned short *) controlByte;       
                percentage = (((double) *results) * 100) / 4096;
        
                if( (ctrlByte - 0x10) % 2 ==0 ) //even number channel
                {
                        if(percentage < 21.5 || percentage > 22.5) {
                                printf("FAIL, got %3.1f%% "
                                  "(should be 20%% - 24%%)\n", percentage);
                                return 2;
                        } else {
                                printf("ok\n");
                        }
                } else { //odd number channel
                        if(percentage < 10.5 || percentage > 11.5) {
                                printf("FAIL, got %3.1f%% "
                                  "(should be 9%% - 13%%)\n", percentage);
                                return 3;
                        } else {
                                printf("ok\n");
                        }
                }
        }
        return 0;
}
<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