| ??? 06/11/01 12:10 Read: times |
#12382 - problem with 10bit serial adc ad7812 |
Hello!
I use multichannel 10bit ADC(ad7812) with serial interface. Channels rfs and tfs tied in singlechannel. SCLK, DIN, DOUT, come on separate pins. I do not use standard spi interface and generate SCLK signal manually. On idea firstly it is necessary to write 10bit word, where we choose channel of measurement. Next rfs-tfs is swiched in reading mode and we read 10bit word with result of the measurement. But i have found a strange bug: ACP return result of previus measurement. So, if we continouslly measure 4 channels in the first we will have result of forth in the second result of first and so on. Now i forced to request each channel two times and this is takes a lot of time. May be you know how avoid this problem? Unfotrunally i have not found any information about this problem at Analog Devices website. Early i used one channel ADC and all was OK. ADC functions you can see below. unsigned int read_adc(unsigned int channel) { unsigned char charray[3]={0,0,0}; unsigned char i; //control word unsigned char adc_wseq[10]={ 0, //A0 1, //PD1 1, //PD0 0, //Vin 0, //DIFF 0, //CH2 0, //CH1 0, //CH0 1, //CONVST 1 //EXTREF }; unsigned int buf=0; //conversion decimal channel to binary for(i=2;channel!=0;i--) { charray[i]=channel % 2; channel/=2; } //insertion channel number to control word adc_wseq[5]=charray[0]; adc_wseq[6]=charray[1]; adc_wseq[7]=charray[2]; //transmitting control word rtfs=FALSE; //rfs-tfs in transmit mode for(i=0;i<10;i++) //transmit a control word { SCLK=TRUE; DIN=adc_wseq[i]; SCLK=FALSE; } CONVST=FALSE; // adc in hold mode CONVST=TRUE; rtfs=TRUE;//rfs-tfs in receive mode for(i=0;i<10;i++) //reading a result { SCLK=TRUE; if (DOUT==TRUE) buf=buf+pow(2,9-i); SCLK=FALSE; } return buf; }//READ_ADC unsigned int radc(unsigned int channel) // this func. reads each channel two times to avoid a bug { read_new_adc(channel); return read_new_adc(channel); } As you can see radc function read request channel two times. It allow to avoid bug but this is not best way. Thanks for any assistance! Igor |
| Topic | Author | Date |
| problem with 10bit serial adc ad7812 | 01/01/70 00:00 | |
| RE: problem with 10bit serial adc ad7812 | 01/01/70 00:00 | |
| RE: problem with 10bit serial adc ad7812 | 01/01/70 00:00 | |
RE: problem with 10bit serial adc ad7812 | 01/01/70 00:00 |



