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.

LDC1614 Arduino I2C

Other Parts Discussed in Thread: LDC1614, FDC2214, LDC1314, LDC1612, LDC1614EVM

I am trying to access the sensor data from the LDC1614 using an Arduino over I2C. Following the "Typical Application" section in the LDc1614 data sheet, I am still not able to get the project working. I connected the SCL and SDA pins to the proper ones on the Arudino, and the ADDR pin to ground and the power to 3.3V. Can someone tell me if there is an issue with my code (I use the Wire Arduino Library). Also, even though the power supply is 3.3V, the pin voltage is 5V; is that too high? 

#include <Wire.h>
int ADDR_L=0x2A; //ADDR pin connected to ground; device address
#define DATA_MSB_CH0 0x00
#define DATA_LSB_CH0 0x01
#define CLOCK_DIVIDERS_CH0 0x14
#define CH0_SETTLECOUNT 0x10
#define CH0_RCOUNT 0x08
#define DRIVE_CURRENT_CH0 0x1E
#define MUX_CONFIG 0x1B
#define ERROR_CONFIG 0x19
#define CONFIG 0x1A
unsigned int M0,L0;

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

Wire.beginTransmission(ADDR_L);
Wire.write(CLOCK_DIVIDERS_CH0);
Wire.write(0x1002);
Wire.endTransmission();

Wire.beginTransmission(ADDR_L);
Wire.write(CH0_SETTLECOUNT);
Wire.write(0x000A);
Wire.endTransmission();

Wire.beginTransmission(ADDR_L);
Wire.write(CH0_RCOUNT);
Wire.write(0x04D6);
Wire.endTransmission();

Wire.beginTransmission(ADDR_L);
Wire.write(DRIVE_CURRENT_CH0);
Wire.write(0x9000);
Wire.endTransmission();

Wire.beginTransmission(ADDR_L);
Wire.write(MUX_CONFIG);
Wire.write(0x020C); //grammar inconsistentcy on data sheet... is it 0x020C or 0x820C
Wire.endTransmission();

Wire.beginTransmission(ADDR_L);
Wire.write(CONFIG);
Wire.write(0x1401); //datasheet says 0x1601, but I want to use internal clock source
Wire.endTransmission();

Wire.beginTransmission(ADDR_L);
Wire.write(ERROR_CONFIG);
Wire.write(0x0000);
Wire.endTransmission();

delay(100);
}

void loop()
{
Wire.beginTransmission(ADDR_L);
Wire.write(DATA_MSB_CH0);
Wire.endTransmission();
Wire.requestFrom(ADDR_L,1);
if(Wire.available()<=1)
{ M0=Wire.read();}
Serial.println(M0);

Wire.beginTransmission(ADDR_L);
Wire.write(DATA_LSB_CH0);
Wire.endTransmission();
Wire.requestFrom(ADDR_L,1);
if(Wire.available()<=1)
{ L0=Wire.read();}
Serial.println(L0);


}

  • Hello Kylie,

    I am sorry you are facing problems interfacing with LDC1614. Could you please provide me with more details about the issue you are facing? What exactly is not working? Are you able to talk to the part (try reading 0x7E, manufacturer_id). Without additional details it will be hard to tell if the problem is with the setup or the code.

    But, in regards to interfacing with LDC1614 with an arduino, check out this post regarding the FDC2214. Both FDC2214 and LDC1614 use the same programming interface and should provide you with a reasonable starting point.

    Let us know about your progress!

    Regards,

    Varn Khanna,

    Applications Engineer, Sensor Signal Path,
    Silicon Valley Analog,
    Texas Instruments,

  • I tried rewriting my Arduino code following the structure used in the FDC2214 example, but it still did not work (However the serial monitor displayed 0 instead of 65535). I also tried reading the manufacturer ID and it just printed 65535. 

    I am not sure of the issue I am facing, which is why I need help. I am pretty sure I connected everything correctly and the code is correct so I am not sure what the issue could be. 

  • Hello Kylie,

    It seems like you cannot establish I2C communications using the Arduino.

    Could you perhaps use an oscilloscope/logic analyzer to probe SCL and SDA lines and post the screenshots here? Pictures of your setup/schematics will be necessary as well.

    Regards,
    Varn.
  • I rewrote the code to make it as simple as possible. I am not 100% sure if the code is right, but I tried to follow the example shown for the FDC2214.

    //Kylie Chesner
    //04/30/16
    #include <Wire.h>
    byte LDC = 0x2A;
    byte CH0MSB = 0x00;
    byte CH0LSB = 0x01;

    void writeConfig(byte LDC, byte reg, byte MSB, byte LSB)
    {
    Wire.beginTransmission(LDC);
    Wire.write(reg);
    Wire.write(MSB);
    Wire.write(LSB);
    Wire.endTransmission();
    }

    void Configuration()
    {
    writeConfig(LDC, 0x14, 0x10, 0x02);//CLOCK_DIVIDERS_CH0
    writeConfig(LDC, 0x1E, 0x90, 0x00);//DRIVE_CURRENT_CH0
    writeConfig(LDC, 0x10, 0x00, 0x0A);//SETTLECOUNT_CH0
    writeConfig(LDC, 0x08, 0x04, 0xD6);//RCOUNT_CH0
    writeConfig(LDC, 0x19, 0x00, 0x00);//ERROR_CONFIG
    writeConfig(LDC, 0x1B, 0x02, 0x0C);//MUX_CONFIG
    writeConfig(LDC, 0x1A, 0x14, 0x01);//CONFIG
    }


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

    void loop()
    {
    byte a = 0;
    byte b = 0;
    Wire.beginTransmission(LDC);
    Wire.write(0); //never getting register to read
    Wire.endTransmission();
    Wire.requestFrom(LDC, 2);
    while (Wire.available())
    {
    a = Wire.read();
    b = Wire.read();
    }
    Serial.println(a);
    Serial.println(b);

    }

    I added pull-up resistors (4700 Ohm) to the SDA and SCL lines, each connected to 3.3V power.

    I tried running the new code on the Arduino while having a logic analyzer connected to the circuit. When I used the I2C analyzer tool on the logic analyzer software, it shows reading and writing being done to the wrong addresses. I took screen captures of what the logic analyzer shows, but how do I post the picture? My teacher thinks the Arduino is never getting the register address to read.
  • I just got the Arduino to be able to read the sensor data, but i did it by removing the ground pin connection on the LDC. Why does the sensor work with I2C without the ground pin on the LDC connected to ground on the Arduino?
  • Hey Kylie, 

    I just ordered the Evaluationboard and considered to use it with the arduino because of the I2C connection.  Did you manage full Access yet?

    I havent started yet but i would be interested how you wired it in your latest build. Can you supply some help? Did you have to connect the resistors for I2C connection? do you got an answer to your question?

    " i did it by removing the ground pin connection on the LDC. Why does the sensor work with I2C without the ground pin on the LDC connected to ground on the Arduino?"

    maybe you can give me an electric Diagramm and your latest code? Than i would have an easy start to coding.  
    kind regards 
    Frederic 
  • I managed to get it working! I used an Arduino Micro and soldered the connections directly between the Arduino and LDC. I soldered the SCL and SDA pins to their respective legs on the Arduino (can be found on Arduino's website); I soldered SD, ADDR, and GND to ground on the Arduinio, and power on the LDC to +3.3V on the Arduino. I also used pull-up resistors (4.7K Ohm) for the SCL and SDA lines. I left the interrupts pin floating. I will also paste the code I used below. 

    #include <Wire.h>

    int LDC = 0x2A;

    int CH0MSB = 0x00;

    int CH0LSB = 0x01;

    int CH1MSB = 0x02;

    int CH1LSB = 0x03;

    int CH2MSB = 0x04;

    int CH2LSB = 0x05;

    int CH3MSB = 0x06;

    int CH3LSB = 0x07;

    long initial2 = 0;

    long initial1 = 0;

    long initial0 = 0;

    long initial3 = 0;

     

    unsigned long readChannel0()

    {

      unsigned long val = 0;

      word c = 0; //a word stores a 16-bit unsigned number

      word d = 0;

      c = readValue(LDC, CH0MSB);

      d = readValue(LDC, CH0LSB);

      val = c;

      val <<= 16;

      val += d;

      return val;

    }

     

     

    unsigned long readChannel3()

    {

      unsigned long val = 0;

      word c = 0; //a word stores a 16-bit unsigned number

      word d = 0;

      c = readValue(LDC, CH3MSB);

      d = readValue(LDC, CH3LSB);

      val = c;

      val <<= 16;

      val += d;

      return val;

    }

     

     

    unsigned long readChannel1()

    {

      unsigned long val = 0;

      word c = 0; //a word stores a 16-bit unsigned number

      word d = 0;

      c = readValue(LDC, CH1MSB);

      d = readValue(LDC, CH1LSB);

      val = c;

      val <<= 16;

      val += d;

      return val;

    }

     

    unsigned long readChannel2()

    {

      unsigned long val = 0;

      word c = 0;

      word d = 0;

      c = readValue(LDC, CH2MSB);

      d = readValue(LDC, CH2LSB);

      val = c;

      val <<= 16;

      val += d;

      return val;

    }

     

    void Calibrate()

    {

      initial0 = readChannel0();

      initial1 = readChannel1();

      initial2 = readChannel2();

      initial3 = readChannel3();

    }

     

    word readValue (int LDC, int reg)

    {

      int a = 0;

      int b = 0;

      word value = 0;

      Wire.beginTransmission(LDC);

      Wire.write(reg);

      Wire.endTransmission();

      Wire.requestFrom(LDC, 2);

      while (Wire.available())

      {

        a = Wire.read();

        b = Wire.read();

      }

      value = a;

      value <<= 8;

      value += b;

      return value;

    }

     

     

    void writeConfig(int LDC, int reg, int MSB, int LSB)

    {

      Wire.beginTransmission(LDC);

      Wire.write(reg);

      Wire.write(MSB);

      Wire.write(LSB);

      Wire.endTransmission();

    }

     

    void Configuration()

    {

      writeConfig(LDC, 0x14, 0x10, 0x02);//CLOCK_DIVIDERS_CH0

      writeConfig(LDC, 0x1E, 0x90, 0x00);//DRIVE_CURRENT_CH0

      writeConfig(LDC, 0x10, 0x00, 0x0A);//SETTLECOUNT_CH0

      writeConfig(LDC, 0x08, 0x04, 0xD6);//RCOUNT_CH0

      writeConfig(LDC, 0x15, 0x10, 0x02);//CLOCK_DIVIDERS_CH1

      writeConfig(LDC, 0x1F, 0x90, 0x00);//DRIVE_CURRENT_CH1

      writeConfig(LDC, 0x11, 0x00, 0x0A);//SETTLECOUNT_CH1

      writeConfig(LDC, 0x09, 0x04, 0xD6);//RCOUNT_CH1

      writeConfig(LDC, 0x16, 0x10, 0x02);//CLOCK_DIVIDERS_CH2

      writeConfig(LDC, 0x20, 0x90, 0x00);//DRIVE_CURRENT_CH2

      writeConfig(LDC, 0x12, 0x00, 0x0A);//SETTLECOUNT_CH2

      writeConfig(LDC, 0x0A, 0x04, 0xD6);//RCOUNT_CH2

      writeConfig(LDC, 0x17, 0x10, 0x02);//CLOCK_DIVIDERS_CH3

      writeConfig(LDC, 0x21, 0x90, 0x00);//DRIVE_CURRENT_CH3

      writeConfig(LDC, 0x13, 0x00, 0x0A);//SETTLECOUNT_CH3

      writeConfig(LDC, 0x0B, 0x04, 0xD6);//RCOUNT_CH3

      writeConfig(LDC, 0x19, 0x00, 0x00);//ERROR_CONFIG

      writeConfig(LDC, 0x1B, 0xC2, 0x0C);//MUX_CONFIG

    }

     

     

    void setup()

    {

      Wire.begin();

      Serial.begin(9600);

      Configuration();

      delay(500);

      Calibrate();

    }

     

    void loop()

    {

      unsigned long data0 = readChannel0();

      unsigned long data1 = readChannel1();

      unsigned long data2 = readChannel2();

      unsigned long data3 = readChannel3();

      Serial.println(data0);

      Serial.println(data1);

      Serial.println(data2);

      Serial.println(data3);

      delay(200);

    }

  • Thats very nice of you, Thank you very much.

  • Hey Kylie, I tried your code and it works perfectly. But I don't understand what is the value its returning (64393320). I thought it would be returning a capacitance value. What is this 8 digit value and how do you convert it to capacitance. Any help would be appretiated. 

    Thanks

  • The digital value outputted is a ratio of two frequencies, and it is proportinal the the frequency of oscillation of the LC-tank circuit. Check the bottom of page 11 and bottom of page 37 of the LDC1314/1614 data sheet for the equations to use to find the frequency and capacitance of the circuit (hopefully TI didnt update the data sheets... if you can't find the equations, just reply to this and I'll help). So glad my code worked for you!!!
  • Hey, Kylie!

    I am trying to create an inductive encoder using the LDC1612 Evaluation Board and I am having a little trouble in generating 2 square wave outputs from the 2 sensors. I am relatively inexperienced in microcontrollers or Arduinos. Is there anyway that you could provide some help please?

    Thank you!
  • I am sorry, I am not familiar enough to help much, but if you have access to a logic analyzer, that can likely be of great help!

  • Dear Kylie Chesner,

    As a retired teacher who is very interested in the Arduino platform and learning about electronics, I wish to ask you a few question.

    In the code given above for the LDC1614EVM, I keep getting the fixed number 4,294,967,295 regardless of the position of my target (copper BB pellet). Should the numbers vary depending on he position of the target from the coil and not remain fixed?

    I am using the Arduino Uno and have not solder my connections but simple used jumper wires, could this be the cause?

    My project will eventually consist of firing a BB pellet and having the coils (about half meter in diameter), capture the x-y-z coordinates.

    Thank you very much for your time and effort.

    Sincerely,

    Alexander Luis

  • Hi Kylie,

    I tried your code with the same configuration. However, it gave me zeros no matter how I tried to approach the sensing coils. Could you advise on how to solve this issue? I am currently using the latest version of Arduino IDE.

    Thank you!