Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Teensy 2++ and AD5293 DigiPot

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    2

    [SOLVED] - Teensy 2++ and AD5293 DigiPot

    Hi @all,

    i'm currently working on a Project using the AD5293 DigiPot (http://www.analog.com/en/digital-to-...s/product.html).

    I connected the Teensy 2++ as followed:

    Teensy 2++ <-> AD5293
    B0 <-> SYNC (12)
    B1 <-> SCLK (11)
    B2 <-> DIN (10)

    I'm using the following arduino code:
    Code:
    const byte AD_CS_PIN = 20;
    
    // transfer 0x1802 to enable write to RDAC register
    digitalWrite(AD_CS_PIN,LOW);
    SPI.transfer(0x18);
    SPI.transfer(0x02);
    digitalWrite(AD_CS_PIN,HIGH);
    
    // Transfer 0x500 to set to 1/4 full-scale
    digitalWrite(AD_CS_PIN,LOW);
    SPI.transfer(0x05); // 1/4 fullscale
    SPI.transfer(0x00);
    digitalWrite(AD_CS_PIN,HIGH);
    
    // give some time
    delay(2000);
    
    // set to full-scale (1023)
    digitalWrite(AD_CS_PIN,LOW);
    SPI.transfer(0x07); // 1/4 fullscale
    SPI.transfer(0xFF);
    digitalWrite(AD_CS_PIN,HIGH);
    The Bit order is MSB first.

    I really could not get this piece of code working and would appreciate any helpfull hinds!

    BTW: SPI is working. I checked with AD5206 without any Problems.

    Thx a lot.
    Last edited by hematec; 02-24-2014 at 08:28 AM. Reason: solved

  2. #2
    Junior Member
    Join Date
    Feb 2014
    Posts
    2
    i finally got it working!!

    The magic is that the AD5293 uses SPI Mode 1 (CPOL=0, CPHA=1).
    So i simply had to add
    Code:
    SPI.setDataMode(SPI_MODE1);
    Finally the working code Looks as followed:
    Code:
    const byte AD_CS_PIN = 20;
    
    //Start SPI Stuff
    pinMode(AD_CS_PIN,OUTPUT); // SPI - CS
    SPI.begin();
    SPI.setBitOrder(MSBFIRST);
    SPI.setClockDivider(SPI_CLOCK_DIV2);
    SPI.setDataMode(SPI_MODE1);
    
    // transfer 0x1802 to enable write to RDAC register
    digitalWrite(AD_CS_PIN,LOW);
    SPI.transfer(0x18);
    SPI.transfer(0x02);
    digitalWrite(AD_CS_PIN,HIGH);
    
    // Transfer 0x500 to set to 1/4 full-scale
    digitalWrite(AD_CS_PIN,LOW);
    SPI.transfer(0x05); // 1/4 fullscale
    SPI.transfer(0x00);
    digitalWrite(AD_CS_PIN,HIGH);
    
    // give some time
    delay(2000);
    
    // set to full-scale (1023)
    digitalWrite(AD_CS_PIN,LOW);
    SPI.transfer(0x07); // 1/4 fullscale
    SPI.transfer(0xFF);
    digitalWrite(AD_CS_PIN,HIGH);

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,755
    Glad you got it.

    I've seen very few chips that use modes other than 0 or 3, so this would have been pretty much my last guess.

  4. #4
    Junior Member
    Join Date
    Dec 2017
    Posts
    1
    I only registered to thank you for posting the way to make it work. You saved mi life.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •