zharijs/FDC2214

Using with FDC2112, 1st channel transmits only 0x40000, 0x30000 and 0x20000

Closed this issue · 2 comments

Hello!

Has anyone tested this on the FDC2112?

I've connected FDC2112 to an Arduino as follows:

Arduino | Level shifter | FDC2112
5V   ---| HV        LV  |--- 3.3V
3.3V ---|---------------|-'
GND  ---| GND      GND  |--- GND
A4   ---| HV1      LV1  |--- SDA
A5   ---| HV2      LV2  |--- SCL

I've run testFDC-Serial.ino:

// bool capOk = capsense.begin(0x3, 0x4, 0x5, false); //setup first two channels, autoscan with 2 channels, deglitch at 10MHz, external oscillator
// Start FDC2214 with 4 channels init
bool capOk = capsense.begin(0xF, 0x6, 0x5, false); //setup all four channels, autoscan with 4 channels, deglitch at 10MHz, external oscillator
// Start FDC2214 with 4 channels init
// bool capOk = capsense.begin(0xF, 0x6, 0x5, true); //setup all four channels, autoscan with 4 channels, deglitch at 10MHz, internal oscillator
if (capOk) Serial.println("Sensor OK");
else Serial.println("Sensor Fail");
}
// ### Tell aplication how many chanels will be smapled in main loop
#define CHAN_COUNT 4
// ###
void loop() {
unsigned long capa[CHAN_COUNT]; // variable to store data from FDC
for (int i = 0; i < CHAN_COUNT; i++){ // for each channel
// ### read 28bit data
capa[i]= capsense.getReading28(i);//
// ### Transmit data to serial in simple format readable by SerialPlot application.
Serial.print(capa[i]);

with the following modifications:

Uncomment

// bool capOk = capsense.begin(0x3, 0x4, 0x5, false); //setup first two channels, autoscan with 2 channels, deglitch at 10MHz, external oscillator

Comment out
bool capOk = capsense.begin(0xF, 0x6, 0x5, false); //setup all four channels, autoscan with 4 channels, deglitch at 10MHz, external oscillator

Change 4 to 2
Change 28 to 16
capa[i]= capsense.getReading28(i);//

Add HEX argument to print to see what's happening more clearly:

This results in the 2 channels only ever transmitting 0s. Setting intOsc to true on line 48 results in channel 0 transmitting 40000 , 30000, or 20000 (I am using this skin capacitance sensor (schematic)).

This is obviously a very low resolution, much less than the advertised 12 bits. I've tried changing the MSB address, but unfortunately all values between 0x00-0x07 are just FFFs (i.e. channel 0 transmits FFF0000 for FDC2214_DATA_CH0_MSB being set to any of 0x00-0x07).

Update: after having a good look at the datasheet, a solution is to change the gain flag to 0b11:

// Set the gain flag of the moisture sensor
    uint16_t gainFlag = capsense.read16FDC(0x1C);
    Serial.println(gainFlag, HEX);
    capsense.write16FDC(0x1C, 0x3 << 9);
    gainFlag = capsense.read16FDC(0x1C);
    Serial.println(gainFlag, HEX);

This results in a 6-bit resolution, which was good enough for my application. This only applies to the FDC2112 and FDC2114.

have you used moisture click that uses FDC2112 if yes please send me the full code you used to integrate FDC 2112