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 + Pic 18f452

Other Parts Discussed in Thread: ADS1232REF, ADS1232

I'm trying to use ads1232 with pic 18F452. I'm using gain of 128, with crystal frequency of 4 MHz and 5V Vref. I'm having some difficulty to check Dout. I need help 


#define a0 LATD0_bit
#define t LATD1_bit
#define speed LATD2_bit
#define g1 LATD3_bit
#define g0 LATD4_bit
#define rst LATD5_bit
#define exc LATD6_bit
#define d0 LATC4_bit
#define sck LATC3_bit


sbit Chip_Select_Direction at TRISC0_bit;
sbit Chip_Select at LATC0_bit;
// eof ADC click module connections

// Lcd module connections
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End Lcd module connections

char valor1[24];
long valor=0;


long read_reg(char adr)
{
union char_long {
long l;
char c[4];
} result;

Chip_Select = 1;

SPI1_Write(1);
SPI1_Write(adr | 0x80);
result.c[2]=SPI1_Read(0xFF);
result.c[1]=SPI1_Read(0xFF);
result.c[0]=SPI1_Read(0XFF);
Chip_Select = 0;
if (result.c[2] & 0x80)
result.c[3]= 0xff;
return result.l;

}
void settling_time (void){
if (speed=0){
d0=1;
delay_us(653);
}
else {
d0=1;
delay_us(83);
}
}

void offset (void){
sck=1;
delay_ms(300);
sck=0;

if (speed=0){
d0=1;
sck=0;
delay_us(1303760);
}
else{
d0=1;
sck=0;
delay_us(164860);
}
}

void main() {

LATD7_bit=1;
TRISD=0;
g1=1;
g0=1;
a0=0;
t=0;
speed=0;
exc=0;


Lcd_Init();

Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);


Chip_Select = 1;
Chip_Select_Direction = 0;


SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);


settling_time();
offset();
Lcd_Out(1,6,"Teste");
Lcd_Out(2,4,"ADS1232");
delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);

while(1){
int i;
long leitura[20];
long media;
valor=read_reg(0);
LongToStr(valor, valor1);
Lcd_Out(1,1,valor1);

}

}

  • RKI,

    Can you be a little more precise on what your actual problem is?  Can you send me your schematic?  Have you verified your communication with an oscilloscope?  Can you send me some scope pictures?

    Best regards,

    Bob B

  • Hi Bob,
    Thank you for your attention
    I have no schematic. I based the ADS1232REF. But I used the pic 18F452 and not the MSP430. I using the same ADC schematic ADS1232Ref (Fig A-3). I am using SPI communication and SCLK is in PORTC3, PDWN (Chip Select) in PORTC0 and Dout in PORTC4.
    I have some questions:
    I have no filters in high frequency, can replace by another component?
    -1 Appears on the LCD as a result, do not know if I'm doing the reading correctly. What is the correct procedure?

  • Hi RKI,

    Part of your problem may be in using the PDWN pin as chip select.  PWDN will reset the part and you must wait for the oscillator to start and the conversion to complete before it can be read out of the device.  See Figure 41 of the datasheet for the timing delay required.

    Best regards,

    Bob B

  • thanks bob,
    Now I'm in trouble Dout, is very unstable, values ​​are varying widely. how can I stabilize?

  • Hi RKI,

    If you are using a prototyping system you will have many issues with noise causing instability.  To get a high level of performance you need to have a PCB with a solid ground plane around the ADS1232 and the analog portion.  You need to be very careful with routing so that the analog and digital portions are separate from each other.  It is very easy for digital signal noise to transfer to the analog portion.  Any wiring external to the ADS1232 (such as load cell wires) can act as an antenna and pick up power line noise as well as RFI/EMI.  These wires should be shielded and the shield properly grounded (earth.)

    Best regards,

    Bob B