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.

FDC2214EVM: Sensor only returns zeros to Arduino

Part Number: FDC2214EVM
Other Parts Discussed in Thread: FDC2214

I try to read the FDC2214 bricked out from the EVM with my Arduino MKRZero (runs on 3V).

Unfortunately I only receive "0"s for each channel. I also checked the errors, and the INTB pin is randomly high, when I then read out the status register it is always 0 on each bit. I noticed when I touch one of the copper plates I use as sensor plates, INTB never goes high anymore.

For the configuration I mainly followed the example in the datasheet.

Any help would be great!

Here is my code:

#include <Wire.h>

// Pin definitions
const byte INT_PIN = 9;
const byte ADR_PIN = 10;
const byte SDA_PIN = 11;
const byte SCL_PIN = 12;

// registers
const byte FDC = 0x2A;     // FDC address ADR_PIN=LOW: 0x2A; ADR_PIN=HIGH: 0x2B;
const byte CH0MSB = 0x00;  // Most significant bits of the conversion result on channel 0. [11:0]-->>[27:16]
const byte CH0LSB = 0x01;  // Less significant bits of the conversion result on channel 0. [15:0]-->>[15:0]
const byte CH1MSB = 0x02;
const byte CH1LSB = 0x03;
const byte CH2MSB = 0x04;
const byte CH2LSB = 0x05;
const byte CH3MSB = 0x06;
const byte CH3LSB = 0x07;

const byte ERR = 0x18;

// Configuring the FDC2214
void writeConfig(byte FDC_addr, byte reg, byte MSB, byte LSB) {
    Wire.beginTransmission(FDC_addr);
    Wire.write(reg);
    Wire.write(MSB);
    Wire.write(LSB);
    Wire.endTransmission();
}

// Set the parameters for the I2C
void Configuration(byte FDC_addr) {
    // Sensor frequency
    writeConfig(FDC_addr, 0x14, 0x20, 0x02);
    writeConfig(FDC_addr, 0x15, 0x20, 0x02);
    writeConfig(FDC_addr, 0x16, 0x20, 0x02);
    writeConfig(FDC_addr, 0x17, 0x20, 0x02);

    // Sensor drive current
    // Does not matter when 0x1A[11] is set to 0. (It is)
    writeConfig(FDC_addr, 0x1E, 0x7C, 0x00);
    writeConfig(FDC_addr, 0x1F, 0x7C, 0x00);
    writeConfig(FDC_addr, 0x20, 0x7C, 0x00);
    writeConfig(FDC_addr, 0x21, 0x7C, 0x00);

    // Settling time
    writeConfig(FDC_addr, 0x10, 0x00, 0x0A);
    writeConfig(FDC_addr, 0x11, 0x00, 0x0A);
    writeConfig(FDC_addr, 0x12, 0x00, 0x0A);
    writeConfig(FDC_addr, 0x13, 0x00, 0x0A);

    // Conversion time
    writeConfig(FDC_addr, 0x08, 0x83, 0x29);
    writeConfig(FDC_addr, 0x09, 0x83, 0x29);
    writeConfig(FDC_addr, 0x0A, 0x83, 0x29);
    writeConfig(FDC_addr, 0x0B, 0x83, 0x29);

    // Error config
    writeConfig(FDC_addr, 0x19, 0x38, 0x11);  // No errors will be reported

    // MUX_CONFIG, here is set how many channels are used
    writeConfig(FDC_addr, 0x1B, 0xC2, 0x0D);

    // General config
    // Needs to be set last, activates the sensor
    writeConfig(FDC_addr, 0x1A, 0x16, 0x01);  // external clock with 40 Mhz
}

void setup() {
    Wire.begin();
    Serial.begin(9600);
    Serial.println("Starting");
    // Set name and settings of FDC
    pinMode(ADR_PIN, OUTPUT);
    pinMode(INT_PIN, INPUT);
    digitalWrite(ADR_PIN, LOW);
    Configuration(FDC);
}

void loop() {
    Wire.beginTransmission(FDC);
    monitor();
    delay(10);
}

// Build the complete conversion result from the specific channel (0?)
unsigned long readChannel(byte FDC_addr, int chan) {
    unsigned long val = 0;
    word c = 0;
    word d = 0;
    if(chan == 0) {
        c = readValue(FDC_addr, CH0MSB);
        d = readValue(FDC_addr, CH0LSB);
    } else if(chan == 1) {
        c = readValue(FDC_addr, CH1MSB);
        d = readValue(FDC_addr, CH1LSB);
    } else if(chan == 2) {
        c = readValue(FDC_addr, CH2MSB);
        d = readValue(FDC_addr, CH2LSB);
    } else if(chan == 3) {
        c = readValue(FDC_addr, CH3MSB);
        d = readValue(FDC_addr, CH3LSB);
    }
    val = c;
    val <<= 16;
    val += d;
    return val;
}

// Read bytes from register channel specified
word readValue(byte FDC_addr, byte reg) {
    byte a = 0;
    byte b = 0;
    word value = 0;
    Wire.beginTransmission(FDC_addr);
    Wire.write(reg);
    Wire.endTransmission();
    Wire.requestFrom(FDC_addr, 2);
    while(Wire.available()) {
        a = Wire.read();
        b = Wire.read();
    }
    value = a;
    value <<= 8;
    value += b;
    return value;
}

void monitor() {
    checkError();

    long current0 = readChannel(FDC, 0);
    long current1 = readChannel(FDC, 1);
    long current2 = readChannel(FDC, 2);
    long current3 = readChannel(FDC, 3);
    Serial.print(current0);
    Serial.print("\t");
    Serial.print(current1);
    Serial.print("\t");
    Serial.print(current2);
    Serial.print("\t");
    Serial.println(current3);
}

void checkError(){
    int error = digitalRead(INT_PIN);
    if(error == 0){
        Serial.print("Error detected! ");
        byte error_msg = readValue(FDC, ERR);
        Serial.println(error_msg, HEX);
    }
}

  • Hi Jonas,

    Unfortunately, we are not actively supporting the FDC device with an Arduino - maybe you can take a look at this thread and see if it helps?
    e2e.ti.com/.../495744

    Thanks,
    Rachel
  • The Arduino is not the problem, since it can handle the I2C without problems.

    It's more important, are those registers set right for a read-out on all 4 channels:

    0x14: 0x2002
    0x15: 0x2002
    0x16: 0x2002
    0x17: 0x2002
    0x1E: 0x7C00
    0x1F: 0x7C00
    0x20: 0x7C00
    0x21: 0x7C00
    0x10: 0x000A
    0x11: 0x000A
    0x12: 0x000A
    0x13: 0x000A
    0x08: 0x8329
    0x09: 0x8329
    0x0A: 0x8329
    0x0B: 0x8329
    0x19: 0x3811
    0x1B: 0xC20D
    0x1A: 0x1601
    

    And what does it mean if the FDC always returns 0 on all channels?

  • Hi Jonas,

    Which example did you follow in the datasheet? Many of the reserved bits that were required to be set to 0 were set to 1 with the register configuration you've sent me. For example,

    - DRIVE_CURRENT registers reserve bits 10:0 and require them to be set to 0 whereas you have that 10th bit set to 1.
    - ERROR_CONFIG registers reserve bits 15:14 and 10:6

    Also, you have set the device (in the CONFIG register) to not use the DRIVE_CURRENT values, is that correct?

    Please check the register settings in the datasheet for more details.

    Thanks,
    Rachel
  • Hello Rachel,

    I used the example values from page 43 of the official documentation for the FDC2x1x.
    I did some better wiring and now it is working, even with the wrong registers. I update this of course.

    Maybe the arduino code will help some people.