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.

ADS1230 Interfacing with 89v51rd2.

Other Parts Discussed in Thread: ADS1230

sir,

   I am interfacing ADS1230 (a to d) converter with microcontroller(89v51rd2) ,please can you give me some example code to interface ADS1230  with  microcontroller.

   thank you.

  • Amit,

    I do not have code that runs directly with your processor.  The MSP430 project code for the ADS1230REF is available from the TI ftp server:

    ftp://ftp.ti.com/pub/data_acquisition/ADS123xREF/ADS123x_CDROM/Firmware/Firmware_Source_Code/Source_for_123XREF_firmware-1.1.0d.zip

    Best regards,

    Bob B

  • thank you sir for your quick response ,

    i will understand this code and try to implement  with my processor..

  • Sir i written the following code according to my micro-controller( P89v51rd2 ).I am interfacing ADS1230.I am using milli volt source i/p signal to ads1230 and displaying on lcd.

    Sir when i applying the I/P +ve signal 0.00mv , it shows o/p 205 counts and varying with (+or-10 ) counts and when i applying the max i/p(in datasheet) 39mv signal (gain=0,speed=0) it shows 261942 counts,and this maximum count i got.In between signal (0.0mv to 39mv) i getting + or - 10 counts fluctuation .

    and on other hand when i applied -ve mv source signal i getting more fluctuation(+ or - 300 counts) compare to +ve signal. 

    i m not understanding why this kinds of output coming.i am not getting stable o/p,i am also using the averaging of 4 counts in my code for stable o/p.

    sir  please help me from this problem..............i given the code please check the code is written right or wrong.and any modification is required from your side please correct.

    i am waiting for your valuable reply.

    thank you.

      

    #include<reg51.h>
    #include"lcd2.h"
    #define max_avg 4
    sbit SCLK=P1^0; //sclk attached to p1.1
    sbit DATA=P1^1; //DRDY/DOUT attached to p1.3
    //sbit sw1=P1^3; //zero
    void delay_ms(unsigned int);
    void clock_4pulse(void);
    unsigned long get_adc1230(void);
    unsigned long offset_calibation_adc1230(void); //function prototypes
    void display(unsigned char,unsigned long);
    static int sign_extend1=0;
    void main()
    {
    unsigned long receive_data_2,offset_data_1,offset_data_2,display_value;
    unsigned char dummy_v,dummy_c;
    idata unsigned char avg_cnt=0;
    unsigned char val_1;
    idata long avg[max_avg];

    receive_data_2=0;

    init_lcd(); //initialisation of lcd
    delay_ms(25);


    lcd_cmd(0x80); //setting cursor on starting position
    put_string("Offset start");
    delay_ms(500);
    lcd_cmd(0x01);

    //offset_data_1=offset_calibation_adc1230();
    //calling offset function

    /////////////////////////////////////////////////////////////////////////


    while(1)
    {
    //receive_data_2=offset_calibation_adc1230();
    receive_data_2=get_adc1230(); //calling get_adc function
    clock_4pulse();
    avg[avg_cnt++] = receive_data_2;
    receive_data_2= 0;
    for(val_1=0;val_1<max_avg;val_1++)
    receive_data_2=receive_data_2 + avg[val_1];
    receive_data_2 =receive_data_2/max_avg;
    receive_data_2 =receive_data_2+650;
    if(avg_cnt >= max_avg)
    avg_cnt = 0;

    display(0x80,receive_data_2); //displaying data on lcd

    receive_data_2=0;
    offset_data_2=0;
    display_value=0; //again reseting all value
    delay_ms(500);
    }
    }

    void display(unsigned char pos,unsigned long receive_data_dis) //display function body
    {
    unsigned long display_value=0;
    lcd_cmd(pos);
    delay_ms(30);

    if ( receive_data_dis < 0x80000 )
    {
    display_value = receive_data_dis>>1;
    }
    else
    {
    display_value = (( ~( receive_data_dis - 1 ) ) & 0x000FFFFF )>>1;
    }
    lcd_cmd(0x82);
    // int_lcd(display_value);
    if (sign_extend1 == 0)
    {
    lcd_cmd(0x80);
    put_string("+");
    }
    if (sign_extend1 == 1)
    {
    lcd_cmd(0x80);
    put_string("-");
    sign_extend1 = 0;
    }
    lcd_cmd(0x81);
    int_lcd(((display_value/10000000))); //displaying on lcd
    int_lcd((((display_value/1000000)%10)));
    int_lcd((((display_value/100000)%10)));
    int_lcd(((display_value/10000)%10));
    int_lcd(((display_value/1000)%10));
    int_lcd(((display_value/100)%10));
    int_lcd(((display_value/10)%10));
    int_lcd((display_value % 10));
    }


    unsigned long get_adc1230() //get_adc function body
    {
    unsigned long receive_data=0;
    unsigned char clk=0;

    SCLK=0; // sclk low
    delay_50us();
    delay_50us();
    while(DATA); //while data is high loop will iterate here
    for(clk=0;clk<=19;clk++) // loop gatting 20 bit data
    {
    SCLK=1;
    delay_50us();

    SCLK=0;
    delay_50us();

    receive_data=receive_data<<1;

    if ( DATA == 1 )
    {
    if(clk == 0)
    sign_extend1 = 1; // if the MSB is high then the result is negative and we need to sign extend the result

    receive_data|= 0x00000001;//0000 0000 0000 0000 0001
    }
    else
    receive_data &= 0x000FFFFE;//1111 1111 1111 1111 1110

    }
    if (sign_extend1 == 1)
    receive_data |= 0xFFF00000; // this is where the sign extension is made


    return(receive_data);
    }

    ///////////////////////////////////////////////////////////////////
    ////////////offset calibaration

    unsigned long offset_calibation_adc1230() //offset function body
    {
    unsigned long offset_receive_data=0;
    unsigned char offset_clk=0;

    SCLK=0;
    delay_small();
    delay_small();
    delay_small();
    delay_50us();

    while(DATA);

    for(offset_clk=0;offset_clk<=25;offset_clk++) // 26 clock pulse is providing for callibration
    {
    SCLK=1;
    delay_50us();

    SCLK=0;
    delay_50us();


    if(offset_clk<=19)
    {
    offset_receive_data=offset_receive_data<<1;

    if ( DATA == 1 )
    offset_receive_data|= 0x00000001;//0000 0000 0000 0000 0001
    else
    offset_receive_data &= 0x000FFFFE;//1111 1111 1111 1111 1110
    delay_small();
    delay_small();

    if(offset_clk==19)
    {
    DATA=1;
    delay_ms(200);
    }
    }

    }

    return(offset_receive_data);
    }

    void delay_ms(unsigned dly_count)
    {
    register unsigned char z;

    do {
    z = 20; // 20 * 50 uS = 1 mS
    do {
    delay_50us();
    } while(--z);
    } while(--dly_count); // total delay = dly_count * 1 mS
    }

    void clock_4pulse(void) // this function is used to generate 4 clock pulse
    {
    unsigned int i;

    for(i=0;i<4;i++)
    {
    SCLK=1;
    delay_50us();
    SCLK=0;
    delay_50us();
    }
    }

  • Amit,

    Can you tell me a little more about your circuit and test measurement?  How are you applying the voltage to the inputs?  The ADS1230 has a buffered PGA with a common mode restriction.  The inputs must be within the specified range of at least 1.5V above ground and 1.5V below AVDD.  You cannot connect one input to ground and the other with voltage signal for example.

    What is your reference voltage?  What is your supply voltages?  Can you send me your schematic?  Your full scale voltage appears to be 1/2 of what I would have expected.  As far as the code is concerned, I would simplify it as much as possible.  It appears that you are trying to do a running average, but you have to be very careful as the output of the dataconverter is binary two's complement.  In essence the data is coming out a signed value.  In your code you are using unsigned values, which is ok as long as you interpret the values correctly.  I would initially skip the averaging routines and just display the raw data.

    What I do is keep everything as a signed value and manipulate the data according when it is read.  What I think you are doing in your code is to manipulate the data in a backwards method.  The ADS1230 transfers data MSB first (bit 19) and ends with bit 0.  The easiest way to manipulate the data is to analyze bit 19 to see if it is high, and if it is make the upper bits of the 32 bit signed value high as well.

    if(receive_data&0x80000) receive_data = receive_data | 0xFFF80000;

    This keeps the data in the correct format.

    Best regards,

    Bob B