Hi all,
I am in the process of setting up the AD5940 to interface with an electrochemical sensor. However, I would like to first test that the ADC is working in principle by configuring it to read from the internal temperature sensor.
Below is how I am currently configuring the registers, but I am not able to read the default raw temperature data. Could someone advise what I might be doing wrong?
read_adc() is being called once a second
void AD5940_setup(void) { // DEvice INT as per data sheet. AD5940_WriteRegister(0x00000908, 0x02C9, 1); AD5940_WriteRegister(0x00000C08, 0x206C, 1); AD5940_WriteRegister(0x000021F0, 0x0010, 1); AD5940_WriteRegister(0x00000410, 0x02C9, 1); AD5940_WriteRegister(0x00000A28, 0x0009, 1); AD5940_WriteRegister(0x0000238C, 0x0104, 1); AD5940_WriteRegister(0x00000A04, 0x4859, 1); // Power mode key part 1 AD5940_WriteRegister(0x00000A04, 0xF27B, 1); // Power mode key part 2 AD5940_WriteRegister(0x00000A00, 0x8009, 1); // PWRMOD register AD5940_WriteRegister(0x000022F0, 0x0000, 1); //Set up for 4 pin gas sensor AD5940_WriteRegister(0x00002120, 0x1A68B, 1); //LPDACDAT0 BIAS 0V (VZERO0 and VBIAS0) both set to 1.1 V. AD5940_WriteRegister(0x00002128, 0x00, 1); //LPDACCON0 AD5940_WriteRegister(0x000020EC, 0x1AE0, 1); // Set LPTIACON0: RTIA=160k, RLOAD=30?, TIAPDEN,PAPDEN AD5940_WriteRegister(0x000020E4, 0x302C, 1);// LPTIASW0 SWitches //Setup for Tempearture reading AD5940_WriteRegister(0x2000,(1 << 12), 1); // Enables sensor + starts conversion // Select temperature sensor as ADC input AD5940_WriteRegister(0x21A8, 0xB0B, 1); // ADCCON: MUXP = TEMPSENSP, MUXN = TEMPSENSN AD5940_WriteRegister(0x2000, (1 << 8) | (1 << 12) |(1 << 13), 1); // Enables sensor + starts conversion // Start ADC conversion AD5940_WriteRegister(0x000021F0, 1, 1); // Start 1 conversion } void read_adc(void) { temp_raw = AD5940_ReadRegister(0x2084, 1); // TEMPSENSDAT temperature_ic = ((float)temp_raw / (1.0f * 8.13f)) - 273.15f; // (Optional) Store or print the result AD5940_WriteRegister(0x2000, (1 << 8) | (1 << 12) |(1 << 13), 1); // Enables sensor + starts conversion AD5940_WriteRegister(0x000021F0, 0x0010, 1); // Start 1 conversion }
Updated Reg in code
[edited by: DJUK at 3:02 PM (GMT -4) on 4 May 2025]