Hi,
I have an issue with the Sample per second I got from the ADC.
when I choose to work in 1000 Sps I got only 790 Sps, but when I choose to work with 2000 Sps, I got only 1450 Sps.
Because of that the my MCU managed to get effective Sps working with 2000 Sps bigger than 1000 Sps so mainly it has no problem working in 1000 Sps but still there is no match between the requested Sps and the effective one.
for initialization the ADC I do the following:
// reset the ADC ads_reset(); HAL_Delay(10); //write status register ads_write_register(STATUS_REG, 0x02); HAL_Delay(1); //write ADCON register ads_write_register(ADCON_REG, 0x00); HAL_Delay(1); /* set data rate */ ads_write_register(DRATE_REG, data_rate); //data rate can be 0xA1 for 1000Sps, or 0B0 for 2000Sps HAL_Delay(1); /* select AnIn channels differential */ // here I set the first channel, and every time I got a new sample I change the channel to the next one. ads_write_register(MUX_REG, EAI_MUX_REG_VALUES[EAI_Channels_To_Sample[0]]); HAL_Delay(1); /* perform self calibration */ ads_self_cal(); HAL_Delay(30); //30 ms delay
I have to sample 8 channels one by one in a loop { 1, 2, 3, 4, 5, 6, 7, 8, 1 ,2, 3 ...)
So in the DRDY_ADC_Pin interrupt I do the following:
// set the ADC to sample the next channel ads_write_register(MUX_REG, channel_value); channel_value possible values: { 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78 }; // read the current channel sample. ads_send_cmd(SYNC_CMD); // sync command ads_send_cmd(WAKEUP_CMD); // wakeup command ads_send_cmd(READ_DATA_CMD); / read data Delay(6.52) //6.52 usec delay SPI_Receve(&tmp, 3); // receive 3 bytes over SPI adc_data= ((tmp & 0xff0000) >> 16) | (tmp & 0xff00) | ((tmp & 0xff) << 16); if ((adc_data & 0x800000) == 0x800000) adc_data = 0; last_channel_sample = adc_data;
Please help me to solve this issue.
Best Regards
JK