This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I am having trouble with a anlog to digital converter ads1256 where should I post my code and question?

Other Parts Discussed in Thread: ADS1256, ADS1282, ADS1298, MSP430F5529

I am having trouble with a anlog to digital converter ads1256 where should I post my code and question?

I am using the arduino microcontroler system.

I will reconfigure a extera arduino as a logic analiser and post the input and output graphs also.

  • Hi Josh,

    Please post your questions on the SPI interface here and we should be able to help you.  Are these questions also related to your post regarding the ADS1256?

    Regards,

    Tom Hendrick

  • Hi Josh,

    We may have a few code examples for the ADS1256 running on an MSP430, but we do not have the Arduino development system in our lab.  If you care to post your code and questions here, we'd be happy to try and help!

    Tom Hendrick

     


  •  
    //ads1256 initilisation and read and write to registers in arduino wiring.
    #include "ads1256.h"
    #include "extera.h"

    //define pin names for pin #
    #define CS 10 //Chip Select active low on pin 10
    #define NEG_RESET 9 //RESET PIN active low on pin 9 on uc
    #define DRDY 2 //DATA READY
    #define SYNC 8 //syncronisation power down active low
    #define DATAOUT 12//MOSI
    #define DATAIN  11//MISO
    #define SPICLOCK  13//sck

    // global variables
    int val=0; //a counter
    byte clr=0;//used to clear registers to bit trash bin.
    int r0=0;//REGISTER CONTAINERS FOR ADC
    int r1=0;
    int r2=0;
    int r3=0;
    int r4=0;

    //*************************setup for spi to ad
    void spi_to_AD_setup(){
      SPCR=0;//clear control register
      clr=SPCR; //coppy spi control register to clr to print out or clear it similar to clearing a status register
      SPSR=0;//clear control register
      clr=SPSR;//coppy spi status register to clr to print out or clear it similar to clearing a status register
    clr=SPDR;//coppy spi data register to clr to print out or clear it similar to clearing a status register

      /*SPCR
       SPIE  SPI interrupt disabled set to 0
       SPE - Enables the SPI set to 1
       DORD - most Significant Bit first when set to 0
       MSTR - Sets the Arduino in master mode set to 1
       CPOL - Sets the data clock to be idle when low set to 0
       CPHA - Samples data on the falling edge of the data clock set to 1
       SPR1 and SPR0 - Sets the SPI speed, 00 is fastest (4MHz) 11 is slowest (250KHz) set to 01
       SPSR=0;//makeing shure SPI is not going 2x speed.
       result = 01010011*/
      SPCR = (1<<SPE)|(1<<MSTR)|(1<<CPHA)|(1<<SPR0);
      delay(10);
    } //end of initilise spi
    //simple spi transfer function char in char out
    char spi_transfer(volatile char data)
    {
      SPDR = data;                    // Start the transmission
      while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
      {
      };
      return SPDR;                    // return the received byte
    }

    void setup()  {

      // initialize the communication port
      Serial.begin(9600);
      Serial.println("Serial Port Initilised.");

      Serial.println("set pins data direction");
      pinMode(CS,OUTPUT);//10 //Chip Select active low on pin 10
      pinMode(NEG_RESET,OUTPUT); //RESET PIN active low on pin 11
      pinMode(DATAOUT,OUTPUT);// MOSI
      pinMode(DATAIN,INPUT);//DATAIN MISO
      pinMode(SPICLOCK,OUTPUT);// sck
      pinMode(DRDY,INPUT);//Data is ready low
      pinMode(SYNC,OUTPUT);  //sync active low powerdown
      Serial.println("Done seting pins data direction");

      Serial.println("Initilise pins to defalt states");
      digitalWrite(CS,LOW); //enable device
      digitalWrite(SPICLOCK,LOW);//defalt CLOCK NO-RESET state
      digitalWrite(NEG_RESET,HIGH);//defalt reset state
      digitalWrite(SYNC,HIGH);//defalt POWER UP state
      Serial.println("Initiliseed pins to defalt states");

      Serial.println("setup spi port.");
      spi_to_AD_setup();
      Serial.println("spi port setup...");
      Serial.print("SPCR: ");
      Serial.println(SPCR, BIN);
      Serial.print("SPSR: ");
      Serial.println(SPSR, BIN);
     
    Serial.println("Reset chip by reset pin"); 
      digitalWrite(NEG_RESET,LOW); //disable device reset self calibration is performed
      delayMicroseconds(33);
      digitalWrite(NEG_RESET,HIGH); //enable device
    while((DRDY==0)) //wait for chip to be ready to acsept opcodes

      Serial.println("waiting");
    }
    Serial.println("write to register 0-4, DATA=1");
        spi_transfer(CMD_WREG);//write to register opcode
      spi_transfer(6);//6-1 number of registers to write to
      spi_transfer(1);
      spi_transfer(1);
      spi_transfer(1);
      spi_transfer(1);
      spi_transfer(1);
    while((DRDY==0)) //wait for chip to be ready to acsept opcodes

      Serial.println("waiting");
    }
       delayMicroseconds(10);//t6 in datasheet wait before reading.
      Serial.println("Read registers 0-4 then print them out");
        spi_transfer(CMD_RREG);//read register command.
        spi_transfer(6);//number of registers to write to -1  
        delayMicroseconds(10);//t6 in datasheet wait before reading.

        r0=spi_transfer(0xFF);
        r1=spi_transfer(0XFF);
        r2=spi_transfer(0XFF);
        r3=spi_transfer(0XFF);
        r4=spi_transfer(0XFF);
        Serial.println(r0, DEC);
        Serial.println(r1, DEC);
        Serial.println(r2, DEC);
        Serial.println(r3, DEC);
        Serial.println(r4, DEC);
    }//END OF SETUP

    void loop()  {
      val= digitalRead(DRDY);
      if (val==LOW){
      Serial.println("LOW data is ready?");
      }
      if (val==HIGH){
        Serial.println("HIGH data is not ready?");
      }
    }//END OF LOOP


     

  • Can you tell me what happens after you write this to the ADS1256?  Also, in your spi_transfer function, are the received and transmitted data both 'SPDR'?  Since SPI is a bi-directional synchronous transfer, I would think the transmit and receive buffers would have different naming conventions.  As I mentioned before though, I do not have your specific micro system here so I am not familiar with its register set.

    Josh and I had several e-mails off line after this posting.  He eventually got the code worked out and all is well.

  • Hi Tom,

    I searched for a link on the TI website for any examples of using the ADS1256 with the MSP430 but couldn't find one. Is there a URL to these examples and if so can you post it here please? I did find the MSP430 code page but didn't find those examples.

    I am interested in using the ADS1282 with the MSP430, a different ADC I realise, but hopefully this will help me get started as I have never used either of these devices before.

    Regards,

    Will.

     

     

     

  • Hi Will,

    Sorry for the delays here - I've been in Asia since the 4th and am only now getting caught up.  I'll be back in Dallas tomorrow night and will send you some example code for the ADS1256 working with the MSP430.

  • I am working on the ads1298 now ... it is such a interesting replacement for that chip & sections of the design for a EEG / EMG system. Opendous I am working with has a schematic using it on the free kicad software and board designed that is 2 layor.

  • Can you send some example code for the ADS1256 working with the MSP430 to me?  

    asusm6nb@gmail.com

  • Hello Josh,

     

    I wonder if could share the working code of the ads1256 with arduino.

    I tried studying datasheet and writing the code myself, using arduino tutorials, but the code is way out of my league :(

  • Hello Tom

    I write, because I am working with a MSP430F5529 and ads1256 connected but I could not read any data from the port SPI, when I send the comand for obtain the data from SPI output I get nothing, I read in the foro about yo have example yo can share the example please.

    ber.andresc@gmail.com

    Thanks



    Hola Tom

    Le wescribo porque estoy trabajando con ads1256 conectado a un MSP430F5529 pero no he podido leer ningun dato de el cuando le envio los comandos de lectura de los registros en la salida del SPI DI no me sale nada

  • Hi Bernardo,

    Can you post a schematic and screen shot of your SPI communication between the ADS1256 and the MSP430F5529?

  • Hi,TOM!

    I am a newer to MSP430 with ADS1256, I see your answers when i searched the TI E2E . Where Can I download the  code examples of ADS1256 running on an MSP430, Or can you send it to me :buaazyj@139.com?

    Thanks you very much.

    Zhang YJ

  • Hi Zhang,

    Welcome to the TI E2E Forums!

    Please reference the following E2E thread for ADS1256 example code:
    http://e2e.ti.com/support/data_converters/precision_data_converters/f/73/p/338399/1182307.aspx#1182307

    Best Regards,
    Chris

  • Chris,

           Thank you for your kindly help!  I really appreciate for that , Thanks.

     

    Best Wishes,
    Zhang YJ

  • Tom,

    I know this thread is kind of old, but I was hoping you still had those ADS1256 examples laying around or some code that works between either the MSPEXP430FR4133 or Arduino and the ADS1256? My team have been struggling with this for weeks and the only data we can get out of the ADC are zeros. If you have anything that can help, please send to dom.carrington@gmail.com ASAP.
  • Hi Dominique,

    There is a link above that gets you to some MSP430 example code.

    Additionally, there is a third-party project on GitHub with example code for an Arduino, found here:
    github.com/.../ADS12xx-Library

    Best Regards,
    Chris