Loading ...
Sorry, an error occurred while loading the content.

Using a digital Potentiometer with hc11

Expand Messages
  • jatin486
    Can anyone help me with programming/controlling a digital potentiometer that is programmed serially. More specifically, the Xicor X-9111 or any equivalent
    Message 1 of 2 , Jul 14, 2003
    View Source
    • 0 Attachment
      Can anyone help me with programming/controlling a digital
      potentiometer that is programmed serially. More specifically, the
      Xicor X-9111 or any equivalent 10-bit 100k digital potentiometer. If
      anyone has any suggestions for an easier digital potentiometer to use
      with equivalent resolution, it would be much appreciated. Also, I
      need help in controlling an external 12-bit A/D converter such as the
      Maxim 120. I would like to do both at the same time, thus, I would
      need to use as many ports as possible and juggle between the two. If
      anyone has any advice or previous experience with either the digital
      potentiometer or A/D converter, please let me know. Your help is
      greatly appreciated.

      Jatin
    • BobGardner@aol.com
      ... the Maxim 120. here s how I read the lt1293 12 bit a/d using imagecraft c //----------------- char readspi(void){ //return char from spi char cnt; cnt=0;
      Message 2 of 2 , Jul 14, 2003
      View Source
      • 0 Attachment
        >Also, I need help in controlling an external 12-bit A/D converter such as
        the Maxim 120.

        here's how I read the lt1293 12 bit a/d using imagecraft c

        //-----------------
        char readspi(void){
        //return char from spi
        char cnt;

        cnt=0;
        do{
        jnk=SPSR;
        if(jnk & 0x50){ //wcol or modf bits set?
        printf("%02x ",jnk);
        }
        cnt++;
        if(cnt==255){
        printf("timeout ");
        break;
        }
        }while(!(jnk & 0x80)); //keep checking until done bit
        return(SPDR); //clears done flag
        }

        //--------------------------
        void spiout8(char c){
        //send c out spi

        jnk=SPSR;
        if(jnk & 0x10) { //modf?
        SPCR=0x50; //reset modf
        putchar('m');
        DDRD=0x3a; //disable modf
        }
        SPDR=c;
        jnk=0;
        while(((jnk=SPSR) & 0x80)==0) {
        asm("nop"); //8us... shift time for 8 bits at 1MHz
        asm("nop");
        asm("nop");
        asm("nop");
        asm("nop");
        asm("nop");
        asm("nop");
        asm("nop");
        jnk++;
        if(jnk==255){
        printf("spi timeout! ");
        break;
        }
        }
        }

        //--------------------
        int readlt1293chan(char chn){
        //addat is 12 bit input from a/d +-2047 7ff..0..800
        //read 1 ch of external a/d into addat[chn]
        //12bit +-2.5v a/d reads 0x800-0x000-0x7ff
        unsigned char ctl;
        unsigned char dh,dl;
        int result;

        //code fmt: 11ccc011
        //to read pin 123456 read chan 031425
        //input channels baro 1 2 3
        //use this code to read ch 0 1 2 3 4 5
        static unsigned char chncod[6]={0xc3,0xf3,0xcb,0xeb,0xd3,0xf3};

        spiinuse=1;
        ctl=chncod[chn]; //get convert cmd for this channel
        SPCR=0x51; //slow clk down below 1mhz
        PORTD &=0xdf; //cs lo
        spiout8(ctl); //shift out ctl byte
        jnk=readspi(); //read in jnk from prev cnv

        spiout8(0xff); //dummy write to shake clk
        dh=readspi(); //read in hi 7 bits

        spiout8(0xff); //dummy write to shake clk
        dl=readspi(); //read lo 5 bits
        PORTD |= 0x20; //cs hi
        if(dh & 0x40) dh |=0x80; //sign extend
        result=((((int)dh) << 8) | dl) >> 3;
        SPCR=0x50;
        spiinuse=0;
        return(result);
        }


        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.