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.

ADS1232: Ads1232 read data

Part Number: ADS1232

Hi everyone. I use ads1232 for load cell but ı can't read data from my adc. I only see in my display "88365" and it's not be changed.

I use these code logic read and spi read. Someone help me ?

#include <main.h>
#include <max7219.c>
#define buzzer pin_d7

#define dout pin_a5
#define clk  pin_a4
#define pwd  pin_a3
#define zero pin_b3
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
void yaz(int32 Val,int8 &a,int8 &b,int8 &c,int8 &d,int8 &e,int8 &f);
signed int32 oku(void);
int16 i=0;
int a,b,c,d,e,f;
int32 deger=0;
uint8 byte0,byte1,byte2,byte3;

signed int32 read(void){// this for logic read

signed int32 adc_bit;
while(dout){
for(i=0;i<24;i++){
adc_bit=adc_bit<<1;
adc_bit=dout;
output_high(clk);  
delay_ms(1);
output_low(clk);
delay_ms(1);
}
}
return(adc_bit);
}


void adc_read(){ // this for spi read
int i ; byte0 = 0;byte1 = 0;byte2 = 0;

for(i=0;i<24;i++){
output_low(clk); delay_ms(500);
byte0 = spi_read(0);
byte1 = spi_read(0);
byte2 = spi_read(0);
//byte3 = spi_read(0);
 //delay_ms(2);
output_high(clk);
output_low(clk);
output_high(clk);
delay_us(500);
}
deger=make32(byte0,byte1,byte3);
byte0 = 0;
byte1 = 0;
byte2 = 0;
}
//!

void yaz(int32 Val,int8 &a,int8 &b,int8 &c,int8 &d,int8 &e,int8 &f)
{   a=0;b=0;c=0;d=0;e=0;f=0;
    while(val>=100000){val-=100000,a++;}
    while(val>=10000){val-=10000,b++;}
    while(val>=1000){val-=1000,c++;}
    while(val>=100){val-=100,d++;}
    while(val>=10){val-=10,e++;}
    while(val>=1){val-=1,f++;}
    write7219(6,a);
    write7219(5,b);
    write7219(4,c);
    write7219(3,d);
    write7219(2,e);
    write7219(1,f);
 
}

void main() 
{
    //setup_spi(SPI_MASTER | SPI_MODE_3 | SPI_CLK_DIV_4 );
    init7219();
    for(i=0;i<10;i++){write7219(1,i);write7219(2,i);write7219(3,i);write7219(4,i);
    write7219(5,i);write7219(6,i);write7219(7,i);output_high(buzzer);delay_ms(100);
    output_low(buzzer);}
    output_low(pwd); delay_ms(10); output_high(pwd);
   while(TRUE)
   {
    deger=oku();
    if(input(zero)){while(input(zero));deger=0;output_high(buzzer);delay_ms(50);output_low(buzzer);}
    yaz(deger,a,b,c,d,e,f);
   }
}

  • Hi user4864313,

    Welcome to the forum!  I'm a little confused by the code.  It appears you have both a bit-banging scheme as well as SPI peripheral code.  Besides, it is always difficult to follow someone else's code and figure out why the data appears to be incorrect.

    I would suggest you get a hold of an oscilloscope or logic analyzer to determine if you are communicating correctly.  It would also be good debugging if you check the ADS1232 pins to make sure that each of the device pins are in the correct configuration and none of the pins are floating.  So I would suggest working in small steps and verify the device is operating and your code is doing what you think it is doing.

    Best regards,

    Bob B

  • Hi bob thanks for reply, 

    I found to my mistake. I forget to Vdd pin connect and ı can read data from ads1232.