Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FDC1004 evm with Arduino Uno showing problem #2

Open
SanjeebanMaji opened this issue Apr 27, 2016 · 5 comments
Open

FDC1004 evm with Arduino Uno showing problem #2

SanjeebanMaji opened this issue Apr 27, 2016 · 5 comments

Comments

@SanjeebanMaji
Copy link

after loading FDC1004 code, it is showing error and -2,147,483,648. can you help?

@shockerty
Copy link

Thought I'd bump instead of repeating. I had this working fine and it suddenly stopped working about an hour ago with fdc.getCapacitance() returning -2,147,483,648 and "error" for each channel. I have not changed anything in either hardware or software. Any ideas what to do?

@beshaya
Copy link
Owner

beshaya commented Feb 14, 2017 via email

@shockerty
Copy link

shockerty commented Feb 15, 2017

I am using the central section of the FDC1004EVM kit as the "chip", and I have GND and 3.3V from an Uno connected to the chip, and the SDA and SCL lines connected through a level shifter (5V -> 3.3V) and I've checked connections and voltages with a multi-meter and all seems to be correct. I previously had it working consistently without the level shifter for the SDA and SCL lines, though I am now using another chip in case that damaged it somehow. I should add that both chips are working with the Sensing Solutions EVM GUI.

I wrote a sketch that just uses the Wire library to set and read the registers as an experiment, and it looks like it is establishing the connection as I can read the POR values off the chip, including correct manufacturer and device IDs. The sketch is below:

#include <Wire.h>

void setup() {
  Wire.begin();
  Serial.begin(9600);
  while (!Serial) {
    // do nothing
  }
  
  printSeconds();
  printAllRegisters();
  delay(1000);
  
  Serial.println("\nSetting register 0x08 to 0x1C...");
  setRegister(0x08, 0x1C);      // CONF_MEAS1 to CIN1
  
  printSeconds();
  printAllRegisters();
  delay(1000);
  
  Serial.println("\nSetting register 0x09 to 0x3C...");
  setRegister(0x09, 0x3C);      // CONF_MEAS2 to CIN2
  
  printSeconds();
  printAllRegisters();
  delay(1000);
  
  Serial.println("\nSetting register 0x0A to 0x5C...");
  setRegister(0x0A, 0x5C);      // CONF_MEAS3 to CIN3
  
  printSeconds();
  printAllRegisters();
  delay(1000);
  
  Serial.println("\nSetting register 0x0B to 0x7C...");
  setRegister(0x0B, 0x7C);      // CONF_MEAS4 to CIN4
  
  printSeconds();
  printAllRegisters();
  delay(1000);
  
  Serial.println("\nSetting register 0x0C to 0x01F0...");
  setRegister(0x0C, 0x01f0);
  
  printSeconds();
  printAllRegisters();
}

void loop() {
  
}

bool setRegister (byte reg, uint16_t value) {
  Wire.beginTransmission(80);     // transmit to device #80
  Wire.write(reg);                // sets "reg"...
  Wire.write(value);              // ...to "value"
  Wire.endTransmission(false);    // end transmission
}

bool printSeconds () {
  Serial.println("\n\n======================");
  Serial.println((float)millis() / 1000,  2);
  Serial.println("======================");
}

bool printAllRegisters () {
  for (int i = 0; i <= 255; i++) {
    if (i <= 20 || i >= 254) {
      Serial.print("0x");
      if (i < 16) {
        Serial.print("0");
      }
      Serial.print(i,HEX);
      Serial.print(":\t0x");
      printRegister(i);
    }
  }
}

unsigned int readRegister (byte reg) {
  Wire.beginTransmission(80);     // transmit to device #80
  Wire.write(reg);                // sets pointer to "i"
  Wire.endTransmission(false);    // end transmission
  
  Wire.requestFrom(80, 2);        // request 2 bytes from slave device #80
  unsigned int c = Wire.read();

  return c;
}

bool printRegister (byte reg) {
  Serial.println(readRegister(reg), HEX);
}

The serial output is as follows:



======================
0.00
======================
0x00:	0x0
0x01:	0x0
0x02:	0x0
0x03:	0x0
0x04:	0x0
0x05:	0x0
0x06:	0x0
0x07:	0x0
0x08:	0x1C
0x09:	0x1C
0x0A:	0x1C
0x0B:	0x1C
0x0C:	0x0
0x0D:	0x0
0x0E:	0x0
0x0F:	0x0
0x10:	0x0
0x11:	0x40
0x12:	0x40
0x13:	0x40
0x14:	0x40
0xFE:	0x54
0xFF:	0x10

Setting register 0x08 to 0x1C...


======================
1.26
======================
0x00:	0x0
0x01:	0x0
0x02:	0x0
0x03:	0x0
0x04:	0x0
0x05:	0x0
0x06:	0x0
0x07:	0x0
0x08:	0x1C
0x09:	0x1C
0x0A:	0x1C
0x0B:	0x1C
0x0C:	0x0
0x0D:	0x0
0x0E:	0x0
0x0F:	0x0
0x10:	0x0
0x11:	0x40
0x12:	0x40
0x13:	0x40
0x14:	0x40
0xFE:	0x54
0xFF:	0x10

Setting register 0x09 to 0x3C...


======================
2.57
======================
0x00:	0x0
0x01:	0x0
0x02:	0x0
0x03:	0x0
0x04:	0x0
0x05:	0x0
0x06:	0x0
0x07:	0x0
0x08:	0x1C
0x09:	0x3C
0x0A:	0x1C
0x0B:	0x1C
0x0C:	0x0
0x0D:	0x0
0x0E:	0x0
0x0F:	0x0
0x10:	0x0
0x11:	0x40
0x12:	0x40
0x13:	0x40
0x14:	0x40
0xFE:	0x54
0xFF:	0x10

Setting register 0x0A to 0x5C...


======================
3.87
======================
0x00:	0x0
0x01:	0x0
0x02:	0x0
0x03:	0x0
0x04:	0x0
0x05:	0x0
0x06:	0x0
0x07:	0x0
0x08:	0x1C
0x09:	0x3C
0x0A:	0x5C
0x0B:	0x1C
0x0C:	0x0
0x0D:	0x0
0x0E:	0x0
0x0F:	0x0
0x10:	0x0
0x11:	0x40
0x12:	0x40
0x13:	0x40
0x14:	0x40
0xFE:	0x54
0xFF:	0x10

Setting register 0x0B to 0x7C...


======================
5.17
======================
0x00:	0x0
0x01:	0x0
0x02:	0x0
0x03:	0x0
0x04:	0x0
0x05:	0x0
0x06:	0x0
0x07:	0x0
0x08:	0x1C
0x09:	0x3C
0x0A:	0x5C
0x0B:	0x7C
0x0C:	0x0
0x0D:	0x0
0x0E:	0x0
0x0F:	0x0
0x10:	0x0
0x11:	0x40
0x12:	0x40
0x13:	0x40
0x14:	0x40
0xFE:	0x54
0xFF:	0x10

Setting register 0x0C to 0x01F0...


======================
6.47
======================
0x00:	0x0
0x01:	0x0
0x02:	0x0
0x03:	0x0
0x04:	0x0
0x05:	0x0
0x06:	0x0
0x07:	0x0
0x08:	0x1C
0x09:	0x1C
0x0A:	0x1C
0x0B:	0x1C
0x0C:	0x0
0x0D:	0x0
0x0E:	0x0
0x0F:	0x0
0x10:	0x0
0x11:	0x40
0x12:	0x40
0x13:	0x40
0x14:	0x40
0xFE:	0x54
0xFF:	0x10

It's like when I try to set the value of 0x0C (FDC_CONF) it resets the chip? I've tried various other values as well. I have duplicated the process with the same FDC1004 used in the sketch above, but plugging into the FDC1004EVM I2C converter and modifying the registers via the Registers tab in the Sensing Solutions EVM GUI, and it behaves as expected (e.g. once I set 0x0C to 0x01F0, I see activity on registers 0x00 -> 0x07).

This is certainly a little out of my depth so I can't rule out making a rookie error somewhere. Can you spot anything that jumps out at you?

@mpantoja2765
Copy link

mpantoja2765 commented Jan 18, 2018

Hi! Has anybody gotten an update on what can be causing this error rather than loose wires? Because I have checked all the connections in my set up, and the same error appears. Also, I supplied the sensor with exactly 3.3 V from a variable power source, by measuring the voltage at VDD and GND pins of the chip. I have also tried changing the pull-up resistors of the SDA and SCL cables from 10K ohmns to different values down to 0 ohms and I still get the same error. Thanks in advance!

@nuwanprabhath
Copy link

I had the same issue. I was able to sort it out using the following code segment. Note Wire.begin(); should be uncommented.

#include <Wire.h>
#include <FDC1004.h>

int capdac = 0;

FDC1004 fdc;

void setup() {
  Wire.begin();
  Serial.begin(9600);
}

void loop() {
  uint8_t measurement = 0;
  uint8_t channel = 0;
  char result[100];

  fdc.configureMeasurementSingle(measurement, channel, capdac);
  fdc.triggerSingleMeasurement(measurement, FDC1004_100HZ);
  //wait for completion
  delay(15);
  uint16_t value[2];
  if (! fdc.readMeasurement(measurement, value)) {
    
    // calculate capacitance;
    // The absolute capacitance is a function of the capdac and the measurement
    // We only use the msb because the FDC1004 only has 16bits effective resolution;
    // the last 8 bits are more or less random noise. 
    int16_t msb = (int16_t) value[0];
    int32_t capacitance = ((int32_t)457) * ((int32_t)msb); //in attofarads
    capacitance /= 1000; //in femtofarads
    capacitance += ((int32_t)3028) * ((int32_t)capdac);

    sprintf(result, "Raw: %04X %04X @ %02X\n ->", msb, value[1], capdac);    
    Serial.print(result);
    Serial.print(capacitance);
    Serial.print(" fF\n");
    
    //adjust capdac
    int16_t upper_bound = 0x4000;
    int16_t lower_bound = -1 * upper_bound;
    if (msb > upper_bound) {
      if (capdac < FDC1004_CAPDAC_MAX) capdac++;
    } else if (msb < lower_bound) {
      if (capdac > 0) capdac--;
    }
  }
  delay(200);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants