Code Monkey home page Code Monkey logo

Comments (5)

beshaya avatar beshaya commented on September 14, 2024 1

from fdc1004.

mpantoja2765 avatar mpantoja2765 commented on September 14, 2024 1

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!

from fdc1004.

shockerty avatar shockerty commented on September 14, 2024

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?

from fdc1004.

shockerty avatar shockerty commented on September 14, 2024

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?

from fdc1004.

nuwanprabhath avatar nuwanprabhath commented on September 14, 2024

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);
}

from fdc1004.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.