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.

FDC1004: Offset on CIN3 channel in liquid level sensor

Part Number: FDC1004
Other Parts Discussed in Thread: TIDA-00317

Hello, I am developing a remote liquid level sensor using the FDC1004. I followed the reference design closely, with CIN1 measuring the level electrode, CIN2 liquid electrode, and CIN3 environment electrode. 

All measurements are quite linear with water height, but for some reason the environment channel (CIN3) is offset. For example, with no water in the tank the capacitances are as follows:

Level: 8.75pF

Liquid: .88pF

Environment: 9.43pF

I was hoping you had some insight into what is causing the offset, it makes it impossible to compensate for temp/humidity.

Thank you,

Aidan 

  • Aidan,

    Thank you for your post.
    Can you share some more info on your design, like the sensor configuration/layout and schematic?
    Just to confirm, is the reference you mentioned TIDA-00317?

    Regards,
    John

  • Hey John, Thank you for getting back to me. Yes, TIDA-00317 is the reference I used. I have been triggering single differential measurements between CINx and CIN4 (floating, no electrode). Please let me know if you have any thoughts.

    I'm not sure how to upload files here, please see the imgur link below for schematic, layer, and code. Or let me know if there's another way I can send you the files, such as by email.

    Imgur Link to Design Pictures

    Thank you,

    Aidan 

  • Aidan,

    Please upload the files to this thread by clicking Insert/(Image/video/file). 

    Regards,
    John

  • Oops, I didn't see the grey "upload" button.

    float CapacitiveSensor::singleMeasurement(int measurementNumber) 
    {
    
      if (measurementNumber < 1 || measurementNumber > 4) 
        return -1000.0;
    
      // Trigger Measurement
      uint16_t sensorConfig = read16(FDC_CONF);
      sensorConfig |= 1 << (8 - measurementNumber); 
      write16(FDC_CONF, sensorConfig);
    
      long start_time = millis();
      while (millis() - start_time < TIMEOUT_MS) 
      {
        sensorConfig = read16(FDC_CONF);
        if (sensorConfig & (1 << (4 - measurementNumber))) // Check if measurement is completed
          return readMeasurement(measurementNumber);
          
      }
      return -3000.0;
    }
    
    float CapacitiveSensor::readMeasurement(int measurementNumber) 
    {
      // Returns the capacitance of the measurmenet in pF
        if (measurementNumber < 1 || measurementNumber > 4) 
          return -2000.0;
    
        uint16_t sensorConfig = read16(FDC_CONF); 
        if (!(sensorConfig & (1 << (4 - measurementNumber)))) // Check if measurement is completed
            return -3000.0;
    
        uint8_t registerMSB = (measurementNumber-1) * 2;
        uint8_t registerLSB = registerMSB + 1;
    
        // Read 24-bit measurement. Capacitance has a fixed decimal point with 5 bits before and 19 bits after
        uint16_t msb = read16(registerMSB); // D[15:0] contains the most significant 16 bits of the measurement
        uint16_t lsb = read16(registerLSB) >> 8; // D[15:8] contains the least significant 8 bits of the measurement
    
        // Serial.println(msb, BIN);
        // Serial.println(lsb, BIN);
    
        int32_t rawValue = (((uint32_t)(msb)) << 8) | lsb;
    
        int sign = 1;
        if (rawValue & 0x800000) { // Negative number
          sign = -1;
          rawValue |= 0xFF000000;
          rawValue = ~rawValue + 1;
        }
        
        uint16_t left_bits = rawValue >> 19;
        uint32_t right_bits = rawValue & 0x7FFFF;
    
        float capacitance = sign * (left_bits + (float)right_bits/524288.0);
         
        return capacitance;
    }

  • Aidan,

    Thanks for the info. I can't see anything obvious.
    Is it possible to disconnect the individual ENV sensor from the FDC1004 and see the effect on the capacitance reading?
    Also, is there a ground plane located near the ENV sensor?

    Regards,
    John